Hm, well, if it were me, I'd denormalize and squash all of your
various types of action tables into a single action table, and then
depending on the type of action some of the columns are null and
others are filled in. Then the insert would be a lot simpler. If you
wanted a cleaner view of the various types of actions, you could set
up three views into the same table...
Generally conditional logic is hard to do in SQL, which is for the
most part a declarative language. Doing this in a stored procedure
sounds like the way I would go. But then what do the parameters of
the stored procedure look like? They'd have to be the union of all
the various parameters of all the various types of actions, right?
David
On 10/20/06, Sebastian Stepien <[EMAIL PROTECTED]> wrote:
Hi,
I am a newbie and in urgent help with Derby SQL
Having the tables below
How would I insert data based on the following pseudo code? Should I be
using Stored procedures?
Insert into EVENT TABLE and ACTION table data and
If ACTIONTYPE = Reminder
INSERT INTO Reminder table data
Else If ACTIONTYPE = Launch
INSERT INTO Launch table data
Else If ACTIONTYPE = EMAIL
INSERT INTO EMAIL table data
private static final String strCreateEventTable =
"CREATE TABLE APP.EVENT (" +
" EVENTID INTEGER NOT NULL PRIMARY KEY GENERATED
ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1)," +
" EVENTDATE DATE , " +
" EVENTTITLE VARCHAR(30), " +
" EVENTDESCRIPTION VARCHAR(50), " +
" ACTIONID INTEGER " +
")";
private static final String strCreateActionTable =
"CREATE TABLE APP.ACTION (" +
" ACTIONID INTEGER NOT NULL PRIMARY KEY GENERATED
ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1)," +
" ACTIONTYPE VARCHAR(8) " +
")";
private static final String strCreateReminderTable =
"CREATE TABLE APP.REMINDER (" +
" ACTIONID INTEGER NOT NULL PRIMARY KEY," +
" REMINDERMSG VARCHAR(100) " +
")";
private static final String strCreateLaunchTable =
"CREATE TABLE APP.LAUNCH (" +
" ACTIONID INTEGER NOT NULL PRIMARY KEY," +
" LAUNCHCMD VARCHAR(50), " +
" LAUNCHARG VARCHAR(50) " +
")";
private static final String strCreateEmailTable =
"CREATE TABLE APP.EMAIL (" +
" ACTIONID INTEGER NOT NULL PRIMARY KEY," +
" EMAILSUBJECT VARCHAR(50), " +
" EMAILMSG VARCHAR(200), " +
" CONTACTID INTEGER " +
")";
Thanks,
Sebastian
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.7/488 - Release Date: 19/10/2006