db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Hill <Thomas.K.H...@t-online.de>
Subject after insert trigger calling a procedure - how can I retrieve NEW values inside the procedure?
Date Thu, 20 Aug 2009 11:47:05 GMT
Hi,

have created the following procedure and trigger:

CREATE PROCEDURE "TF_ClientsAI"()
LANGUAGE JAVA
  PARAMETER STYLE JAVA
  MODIFIES SQL DATA
  EXTERNAL NAME 'derbyPk.Functions.TF_ClientsAI'; 

-- DROP TRIGGER "TR_ClientsAI";

CREATE TRIGGER "TR_ClientsAI"
AFTER INSERT
ON rte."Clients"
REFERENCING NEW AS NEW
FOR EACH ROW 
CALL DERBY."TF_ClientsAI"();

What I cannot find out is how I can refer to and use the new values inserted
into the Clients table when wanting to log them on another table.

I have tried:
	public static void TF_ClientsAI()
    throws SQLException
{
Statement stmnt = conn.createStatement();
String    cSQL = "INSERT INTO rte.\"EntityAuditLog\" \n" +
                     "(\"ClientID\") \n" +
                     "VALUES (NEW."ClientID")";
}
but this didn't work.

I have tried:
public static void TF_ClientsAI()
    throws SQLException
{
 int iClientID = NEW."ClientID"
// and then the insert statement into which I wanted to pass the variable
}
before using any other SQL inside the procedure, but this doesn't work either.

Can someone please advise. Have searched the derby documentation and the web but
have not found an example where this is done.

Thanks


Mime
View raw message