Skip to Content
avatar image
Former Member

How to genarate Primary Key for each record in XI Mapping

Hi,

I need to genarate primary key for each record in the paylod in mapping..

Eg: if i have a 10 reacords i need to have a primary key for each record..starting with the

Record Primary key

First 001

Secound 002

.

.

.

.

Tenth 010

If i need to write any user defined funtion... can any one provide the code for it.

Thanks

Amaresh

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • Oct 03, 2007 at 08:11 PM

    Well normally if you are calling a insert in a database then you create a Sequence that does that.

    in XI this field will have SEQUENCENAME.NEXTVAL with attribute hasQuot = No and this will call the sequence in the database and put the value in.

    Regards

    Bhavesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 03, 2007 at 08:16 PM

    Hi Bavesh,

    Thanks for the Quick replay,

    What you said is right....but here i am using File to proxy.

    I want to genarate the primary or unique key for each record and that will add to the privous record with in the XI Mapping. I guess this is done in user defined funtions... can one provide the coding..or any other way to do this...

    If your answer solves my problem it will be appriciated by points...

    Thanks

    Amaresh

    Add comment
    10|10000 characters needed characters exceeded

    • Correct me if I am wrong, but is your requirement to have a sequential Record Id for each message / Record in a file?

      Is this sequential integrity to be maintained across files or is specific to files?

  • avatar image
    Former Member
    Oct 03, 2007 at 08:28 PM

    Hi Bavesh,

    I will explain with the example:

    XML:

    <Record 1>

    <Primary key>

    <value1>

    <value2>

    </Record 1>

    <Record 2>

    <Primary Key>

    .

    .

    </Record 2>

    like above i will be getting n number of recored and in each record i need to genarate primary key in XI.and the key sould be in sequence...

    like for the first record 1 secound 2 like that primary key should add to the privous Primary key.

    and this is for each payload.

    Thanks

    Amaresh

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Amaresh,

      Your question is clear on how it should be generated? But wha will happen if one more than one message comes in to XI. Is your requirement to generate primary keys only for a single message or across multiple messages.

      For example say File1 has come with 3 records now in mapping XI can generate 3 numbers in a sequence. But if a second file comes XI will again assign the same numbers to the records in this file also. Hope i am clear.

      Regards,

      Sudheer.

  • avatar image
    Former Member
    Oct 04, 2007 at 06:40 AM

    Hi Amaresh

    if you want to generate the primary key for each record so for that you can use the standard counter function that is avialable in the airtmetic functions.the counter function will generate the sequentials no

    Thanks

    Rinku

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 04, 2007 at 06:50 AM

    Hi,

    I have 2 solutions in my mind to create the Primary Key..from XI.

    1. Get the message ID, for that u have to create the UDF to get the message ID that can be mapped in the target field(that is acting as a Primary key)

    2. write the UDF which will generate the YYYY-MM-DD-SS-mmss format. that will be always unique.

    <b>Thanks</b>

    Farooq.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 04, 2007 at 07:05 AM

    Hi pandari,

    here I have two solutions.

    1. use the standard "count" function in the message mapping.

    2. use the "container" object of the UDF to store the primary key. increase the primary key every time if it is read.

    regards

    Bin

    Add comment
    10|10000 characters needed characters exceeded