... Instead of VALUES INTO a SET Statement can be used:
C/Exec SQL Set :LastId = Identity_Val_Local()
C/End-Exec
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Rick.Chevalier@xxxxxxxxxxxxxxx
Gesendet: Wednesday, November 05, 2008 20:11
An: rpg400-l@xxxxxxxxxxxx
Betreff: RE: Retrieving identity column value when adding a record
Thanks to everyone who replied.
I forgot to mention that we are at V5R4 so I can't get the value from an
insert statement.
I just want to clarify something. I saw Charles solution from the archives.
When I looked it up in the SQL reference manual it specifically states the
VALUES statement is only allowed in a trigger. I am not using a trigger and
doubt that will change. Is the manual wrong and the statement can be used
from a SQLRPGLE program?
From the V5R4 SQL reference manual:
VALUES
The VALUES statement provides a method for invoking a user-defined function
from a trigger. Transition variables can be passed to the user-defined
function.
Invocation
This statement can only be used in the triggered action of a CREATE TRIGGER
statement.
Rick
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Charles Wilt
Sent: Wednesday, November 05, 2008 11:18 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: Retrieving identity column value when adding a record
Use:
VALUES IDENTITY_VAL_LOCAL() INTO :IVAR
HTH,
Charles
Privileged and Confidential. This e-mail, and any attachments there to, is
intended only for use by the addressee(s) named herein and may contain
privileged or confidential information. If you have received this e-mail in
error, please notify me immediately by a return e-mail and delete this
e-mail. You are hereby notified that any dissemination, distribution or
copying of this e-mail and/or any attachments thereto, is strictly
prohibited.
As an Amazon Associate we earn from qualifying purchases.