Dusan Kolesar wrote :
>Hello,
>I have one master table:
>CREATE TABLE "LOGFILE"
>(
> "ID" Integer NOT NULL DEFAULT SERIAL (1),
> "DESCR" Varchar (255) ASCII DEFAULT '',
> PRIMARY KEY ("ID")
>)
>and 2 detail tables
>CREATE TABLE "MSG_IN"
>(
> "ID" Integer NOT NULL DEFAULT SERIAL (1),
> "LOGFILE_ID" Integer DEFAULT -1,
> "MSG" Varchar (4096) BYTE,
> PRIMARY KEY ("ID")
>)
>CREATE TABLE "REQ_IN"
>(
> "ID" Integer NOT NULL DEFAULT SERIAL (1),
> "LOGFILE_ID" Integer DEFAULT -1,
> "REQ" Varchar (4096) BYTE,
> PRIMARY KEY ("ID")
>)
>When a new row is inserted into MSG_IN or REQ_IN, there is a trigger
>which decodes MSG or REQ into decsription and adds one new row into table
>LOGFILE.
>Inside this trigger I want to set collumn LOGFILE_ID into new inserted ID
>value of LOGFILE table.
>Is it posible, to find out new inserted ID?
>I think in MySql LAST_INSERT_ID () makes this.
Inside an insert trigger you have access to all inserted column values of the
triggering table.
So I think the following trigger does the job :
CREATE TRIGGER MSG_IN_TRIGGER FOR MSG_IN AFTER INSERT EXECUTE (
INSERT INTO <owner>.LOGFILE VALUES (:ID, 'something');
)
The variable :ID represents the value of column ID inserted into table MSG_IN.
Best Regards,
Thomas
--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]