Update columns having a composite primary key

Avatar

Avatar
Boost 1
Level 1
abhiseks1679239
Level 1

Likes

2 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
abhiseks1679239
Level 1

Likes

2 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile
abhiseks1679239
Level 1

02-05-2019

Hi Experts,

I'm facing an issue while updating a table. Below's the log (Namespace & tablename masked):

05/02/2019 11:33:32 AM QUE-370007 Unable to find key values for element 'TABLE_NAME' (document with schema 'TABLE_NAME')

05/02/2019 11:33:32 AM XSV-350023 Unable to save document of type 'NAMESPACE_:TABLE_NAME'.

05/02/2019 11:33:32 AM SOP-330011 Error while executing the method 'Write' of service 'xtk:persist|xtk:session'.

Key is based on 4 columns & I've verified that, data exits on all those columns & they're unique when put together.

Below is the key declaration xml:

<element label="TABLE_NAME" name="TABLE_NAME">

    <key internal="true" name="PrimaryKey">

      <keyfield xpath="@COL1"/>

      <keyfield xpath="@COL2"/>

      <keyfield xpath="@COL3"/>

      <keyfield xpath="@COL4"/>

    </key>

Below is the update statement:

xtk.session.Write(

            <TABLE_NAME

            xtkschema="NAMESPACE_:TABLE_NAME" _operation="update" _key="@COL1,@COL2,@COL3,@COL4"

             <<columns that required update>>

            />);

Pls. let e know. TIA

Replies

Avatar

Avatar
Validate 1
Level 4
pierrec70731455
Level 4

Likes

62 likes

Total Posts

59 posts

Correct reply

14 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 4
pierrec70731455
Level 4

Likes

62 likes

Total Posts

59 posts

Correct reply

14 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
pierrec70731455
Level 4

02-05-2019

Hi,

in the doc (Elements and attributes  : <key> element) it explicitly says :

"A key is known as composite if it includes several fields (i.e. several <keyfield> children). Do not use a composite key to define a primary key."

I would recommand using the autopk="true" and a creating a unique index constraint for the fields you wanted as a composite primary key :

<dbindex name="myIndex" label="My index on my 4 fields" unique="true">

  <keyfield xpath="@COL1"/>

  <keyfield xpath="@COL2"/>

  <keyfield xpath="@COL3"/>

  <keyfield xpath="@COL4"/>

</dbindex>

Kind regards,

Pierre

Avatar

Avatar
Boost 1
Level 1
abhiseks1679239
Level 1

Likes

2 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
abhiseks1679239
Level 1

Likes

2 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile
abhiseks1679239
Level 1

02-05-2019

What i observed in ACM was that if we created any custom PK (single/composite),

it actually creates an Unique index on the columns.

But having autopk="true" will add another column to the table & if it's a huge table, we're going consume extra space for it.

I was able to solve this by modifying the JS update code.

Thanks for the reply

Avatar

Avatar
Validate 1
Level 2
iambhosale
Level 2

Likes

6 likes

Total Posts

23 posts

Correct reply

7 solutions
Top badges earned
Validate 1
Give Back 3
Give Back
Boost 5
Boost 3
View profile

Avatar
Validate 1
Level 2
iambhosale
Level 2

Likes

6 likes

Total Posts

23 posts

Correct reply

7 solutions
Top badges earned
Validate 1
Give Back 3
Give Back
Boost 5
Boost 3
View profile
iambhosale
Level 2

14-11-2019

Can you help us with solution. I am facing same issue.