Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Generate unique on iSeries DB2

249 views
Skip to first unread message

Sergey Stepanenko

unread,
Oct 17, 2002, 3:40:42 PM10/17/02
to
Hi,

Is there such a function?
Or sequence that is available on UOW versions of DB2?

Have not found anything like that in docs and do need one for more than
100 operations per second.

Thanks in advance!

Denny Davis

unread,
Oct 17, 2002, 5:30:00 PM10/17/02
to
I don't recall where I got this but maybe it will help.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/* GENUUID : Set &UUID parameter to universal unique identifier. */
/* On error: Set SQLSTATE to '38U99' */
/* &UUID parameter is undefined */
/* &UUID_Ind is -1 */
/* &MsgText contains error message */

Pgm &uuid_io
/* Parm( &UUID /* Out -- Return value +
&UUID_Ind /* Out -- Return value indicator +
&SqlState /* Out -- SQLSTATE +
&FuncName /* In -- Fully qualified function name +
&SpecName /* In -- Function specific name +
&MsgText ) /* Out -- Message text */

Dcl &UUID_io *Char ( 16 )
Dcl &UUID *Char ( 16 )
Dcl &UUID_Ind *Char ( 2 ) /* SmallInt */
Dcl &SqlState *Char ( 5 )
Dcl &FuncName *Char ( 519 ) /* VarChar (517) */
Dcl &SpecName *Char ( 130 ) /* VarChar (128) */
Dcl &MsgText *Char ( 72 ) /* VarChar ( 70) */

Dcl &Template *Char ( 32 )

Dcl &NullInd *Char ( 2 ) Value( X'FFFF' ) /* -1 SmallInt */
Dcl &NotNullInd *Char ( 2 ) Value( X'0000' ) /* 0 SmallInt */
Dcl &SqlStateOK *Char ( 5 ) Value( '00000' )
Dcl &SqlStateEr *Char ( 5 ) Value( '38U99' )
Dcl &MsgStr *Char ( 62 ) Value( +
'Failed call to _GENUUID system procedure in GENUUID CL program' )
Dcl &MsgStrLen *Dec ( 3 0 ) Value( 62 )

ChgVar &Template +
X'0000002000000000000000000000000000000000000000000000000000000000'

CallPrc '_GENUUID' Parm( &Template )
MonMsg ( MCH0000 CPF0000 ) Exec( Do )
ChgVar &UUID_Ind &NullInd
ChgVar &SqlState &SqlStateEr
ChgVar %Bin( &MsgText 1 2 ) &MsgStrLen
ChgVar %SST( &MsgText 3 &MsgStrLen ) &MsgStr
Return
EndDo

ChgVar &UUID ( %SST( &Template 16 16 ) )
ChgVar &UUID_Ind &NotNullInd
ChgVar &SqlState &SqlStateOK
SNDPGMMSG MSG(&UUID)
chgvar &uuid_io &uuid
monmsg mch0000
Return
EndPgm
On Thu, 17 Oct 2002 22:40:42 +0300, Sergey Stepanenko <s...@viaduk.net>
wrote:

Ugo Gagliardelli

unread,
Oct 18, 2002, 9:08:29 AM10/18/02
to
Sergey Stepanenko wrote:
>
> Hi,
>
> Is there such a function?
It's new in V5 OS400.

--
Dr.Ugo Gagliardelli,Modena,Italy-Certified uindoscrasher-AlcoolInside
Spaccamaroni andate a cagare/Spammers not welcome
Spamers iros a la mierda/Spamers allez vous faire foutre
Spammers loop schijten/Spammers macht Euch vom Acker

Kent Milligan

unread,
Oct 21, 2002, 4:29:51 PM10/21/02
to
Closest thing on iSeries is the Identity Column Attribute and ROWID data types
added in V5R2.

You can find a Generate_Unique UDF in the DB2 to DB2 porting guide at:
www.iseries.ibm.com/developer/db2/porting.html

--
Kent Milligan, DB2 & BI team
PartnerWorld for Developers, iSeries
km...@us.removethis.ibm.com GO HAWKEYES!!
>>> www.iseries.ibm.com/db2
(opinions stated are not necessarily those of my employer)

0 new messages