If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Trigger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-17-04, 11:32
jortiz jortiz is offline
Registered User
 
Join Date: Jun 2003
Posts: 294
Trigger

Hello,

I'm creating a trigger that is trying to call an Stored procedure, but I think It's not able to do It.

So I Created the trigger with a Function inside, and the function calls the trigger, but I recive an error when the function is Invoking the procedure.

How do I call a procedure from a Trigger, or how do I call a procedure from a Function.

Do you have any example???? (please attach the file)

Thanks !!!!
Reply With Quote
  #2 (permalink)  
Old 02-17-04, 11:35
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: Trigger

Not possible, AFAIk

Cheers
Sathyaram

Quote:
Originally posted by jortiz
Hello,

I'm creating a trigger that is trying to call an Stored procedure, but I think It's not able to do It.

So I Created the trigger with a Function inside, and the function calls the trigger, but I recive an error when the function is Invoking the procedure.

How do I call a procedure from a Trigger, or how do I call a procedure from a Function.

Do you have any example???? (please attach the file)

Thanks !!!!
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 02-17-04, 11:38
jortiz jortiz is offline
Registered User
 
Join Date: Jun 2003
Posts: 294
Re: Trigger

I have to call the procedure, Is there no solution ?????

So what do I have to do ????
Reply With Quote
  #4 (permalink)  
Old 02-17-04, 11:48
jortiz jortiz is offline
Registered User
 
Join Date: Jun 2003
Posts: 294
Re: Trigger

Is It not posible to call the procedure from a SQL UDF function made in Java ??


How to do It?
Reply With Quote
  #5 (permalink)  
Old 02-17-04, 14:24
Sudamericano Sudamericano is offline
Registered User
 
Join Date: Jan 2004
Location: Argentina
Posts: 6
Read my post "DB2 UDF C TRIGGER problem", maybe it helps you in any way

I cant understand why a SP cant be still triggered in DB2 too ...

Greetings,
Sudamericano.
Reply With Quote
  #6 (permalink)  
Old 02-17-04, 14:40
Sudamericano Sudamericano is offline
Registered User
 
Join Date: Jan 2004
Location: Argentina
Posts: 6
Reply With Quote
  #7 (permalink)  
Old 02-17-04, 15:28
jortiz jortiz is offline
Registered User
 
Join Date: Jun 2003
Posts: 294
Gracias hermano !!!

Definitivamente sigamos trabajando con Oracle
Reply With Quote
  #8 (permalink)  
Old 02-18-04, 04:03
Walter Janissen Walter Janissen is offline
Registered User
 
Join Date: Nov 2003
Location: Germany
Posts: 62
Hi

Here is an example for DB2 V7 z/OS that works:

CREATE TRIGGER DB2.VATI0026
AFTER INSERT ON DB2.VATB0026 REFERENCING NEW AS N
FOR EACH ROW MODE DB2SQL WHEN(N.HERK_KZ = 'V')
BEGIN ATOMIC CALL VAUD0095
(N.ZUG_ID ,N.INSERT_TIMESTAMP ,N.ZUG_STS ,N.HERK_KZ ) ; END
Reply With Quote
  #9 (permalink)  
Old 02-18-04, 10:12
Sudamericano Sudamericano is offline
Registered User
 
Join Date: Jan 2004
Location: Argentina
Posts: 6
...

"A Java stored procedure is defined in the database using the following statement:

CREATE PROCEDURE PARTS_ON_HAND (IN PARTNUM INTEGER,
OUT COST DECIMAL(7,2),
OUT QUANTITY INTEGER)
EXTERNAL NAME 'parts!onhand'
LANGUAGE JAVA PARAMETER STYLE DB2GENERAL;



A Java application calls this stored procedure using the following code fragment:
...
CallableStatement stpCall ;
String sql = "CALL PARTS_ON_HAND ( ?,?,? )" ;
stpCall = con.prepareCall( sql ) ; /* con is the connection */
stpCall.setInt( 1, variable1 ) ;
stpCall.setBigDecimal( 2, variable2 ) ;
stpCall.setInt( 3, variable3 ) ;

stpCall.registerOutParameter( 2, Types.DECIMAL, 2 ) ;
stpCall.registerOutParameter( 3, Types.INTEGER ) ;

stpCall.execute() ;

variable2 = stpCall.getBigDecimal(2) ;
variable3 = stpCall.getInt(3) ;
... "
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On