Forums & Discussions Home

    A place for members, communities, and committees to have discussions online and via e-mail.
    Click a category or topic to below to start the conversation...

    You are currently in view only mode for this forum. Please click the appropriate below to login as a member and participate. If you are not a member, please CLICK HERE for more information.


    Dec 28
    2001

    Identity Column Value - Getting it from the table

    syed asif
    Hi Group,
    We are using Identity Column as primary key in our
    application. Since the Identity Column is defined as
    Generated by default. Since DB2 will take care of the
    generation of the primary key. The application team
    now wants to know what value did DB2 inserted in the
    Identity column since they have to insert that value
    in the foriegn keys in the child table. There are
    application that are coded in cobol and java also.
    Is there a way to get the value from the table using
    any function defined in DB2. If any of you in the
    group has come up with a solution to handle this issue
    and can help me will be just great.
    Looking forward to help from the group.
    Regards,
    Syed


    __________________________________________________
    Do You Yahoo!?
    Send your FREE holiday greetings online!
    http://greetings.yahoo.com



    Sithu Mathew
    Hi Syed,

    In DB2 there is a function called IDENTITY_VAL_LOCAL( ). This function
    will give you the value of the latest generated identity column value. You
    can find out this value immediately after the INSERT statement. Hope this
    will help you to solve the problem.

    example:
    INSERT INTO table_name VALUES(.....);

    SET variable_name = IDENTITY_VAL_LOCAL( );

    Regards
    Sithu Mathew
    HCL-Perot Systems
    Bangalore

    Legal desclaimer: All opinions are my own and are not the opinions of my
    employer.


    -----Original Message-----
    From: syed asif
    To: [login to unmask email]
    Sent: 12/29/01 7:15 AM
    Subject: Identity Column Value - Getting it from the table

    Hi Group,
    We are using Identity Column as primary key in our
    application. Since the Identity Column is defined as
    Generated by default. Since DB2 will take care of the
    generation of the primary key. The application team
    now wants to know what value did DB2 inserted in the
    Identity column since they have to insert that value
    in the foriegn keys in the child table. There are
    application that are coded in cobol and java also.
    Is there a way to get the value from the table using
    any function defined in DB2. If any of you in the
    group has come up with a solution to handle this issue
    and can help me will be just great.
    Looking forward to help from the group.
    Regards,
    Syed


    __________________________________________________
    Do You Yahoo!?
    Send your FREE holiday greetings online!
    http://greetings.yahoo.com



    the DB2-L webpage at http://www.ryci.com/db2-l. The owners of the list
    can



    Dil Pratheek
    [Keane]
    Syed,

    Check out this link. It would come handy .....

    http://publibz.boulder.ibm.com:80/cgi-bin/bookmgr_OS390/BOOKS/dsnsq0g3/4.2.32.1

    Dil

    syed asif wrote:

    > Hi Group,
    > We are using Identity Column as primary key in our
    > application. Since the Identity Column is defined as
    > Generated by default. Since DB2 will take care of the
    > generation of the primary key. The application team
    > now wants to know what value did DB2 inserted in the
    > Identity column since they have to insert that value
    > in the foriegn keys in the child table. There are
    > application that are coded in cobol and java also.
    > Is there a way to get the value from the table using
    > any function defined in DB2. If any of you in the
    > group has come up with a solution to handle this issue
    > and can help me will be just great.
    > Looking forward to help from the group.
    > Regards,
    > Syed
    >
    > __________________________________________________
    > Do You Yahoo!?
    > Send your FREE holiday greetings online!
    > http://greetings.yahoo.com
    >
    >
    >



    Deepak Kini M
    Syed,
    Check out this!
    http://www-4.ibm.com/cgi-
    bin/db2www/data/db2/udb/winos2unix/support/document.d2w/report?
    fn=db2v7irdb2ir19.htm

    Regards
    Deepak

    ----- Original Message -----
    From: syed asif <[login to unmask email]>
    Date: Saturday, December 29, 2001 7:45 am
    Subject: Identity Column Value - Getting it from the table

    > Hi Group,
    > We are using Identity Column as primary key in our
    > application. Since the Identity Column is defined as
    > Generated by default. Since DB2 will take care of the
    > generation of the primary key. The application team
    > now wants to know what value did DB2 inserted in the
    > Identity column since they have to insert that value
    > in the foriegn keys in the child table. There are
    > application that are coded in cobol and java also.
    > Is there a way to get the value from the table using
    > any function defined in DB2. If any of you in the
    > group has come up with a solution to handle this issue
    > and can help me will be just great.
    > Looking forward to help from the group.
    > Regards,
    > Syed
    >
    >
    > __________________________________________________
    > Do You Yahoo!?
    > Send your FREE holiday greetings online!
    > http://greetings.yahoo.com
    >
    >
    >
    > visit the DB2-L webpage at http://www.ryci.com/db2-l. The owners
    > of the list can
    >


    All Times America/New_York

    Copyright © 2014 IDUG. All Rights Reserved

    All material, files, logos and trademarks within this site are properties of their respective organizations.

    Terms of Service - Privacy Policy - Contact