1. Hans Groeneveld
  2. PowerBuilder
  3. Friday, 23 July 2021 13:10 PM UTC

Hi,

I have a SQL Anywhere 17 database with a lot of tables whit a "uniqueidentifier" as primairy key, with de default value newid(). In the the datawindow I set in the Update properties the "Identity Column" to the PK column.

When I insert a row in the datawindow (in Painter and in the program) and fill all the columns and press Update, the PK value is filled by a "0", not the Guid that is generated by the database.

How should I fix that problem?
When I retrieve the row first after the Insert then it works, but that is not how it shouls work and gives a lot off hassle.

 

Kind Regards
Hans

 

John Fauss Accepted Answer Pending Moderation
  1. Friday, 23 July 2021 14:04 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Hans -

If this column is defined as an Identity column (I'm not familiar with SQL Anywhere, so apologies if the terminology differs), then when editing the DataWindow in the DataWindow Painter, select menu: Rows -> Update Properties...

At the bottom of the dialog window that opens, choose the Identity column. Also, delete the initial value of newid() from the column specification. Once PB knows the table contains an Identity column, it should handle things properly, automatically.

Yet another reason to hug a DataWindow, as Chris is rightly fond of saying.

Regards,
John Fauss

Comment
  1. Hans Groeneveld
  2. Friday, 23 July 2021 14:34 PM UTC
I posted a screenshot. You can see it is filled correctly.

  1. Helpful
There are no comments made yet.
Hans Groeneveld Accepted Answer Pending Moderation
  1. Friday, 23 July 2021 14:33 PM UTC
  2. PowerBuilder
  3. # 2

I added a screenshot, makes it easier to make the problem clear.

The column 'guid' a database column with a default value 'newid()'. That generates a new guid.
The Identity Column in the datawindow is filled with the column 'guid'.

But when I add a row and enter some text in 'description' and press Update, the 'guid' is filled with a '0'.
When I retrieve the datawindow again then it is filled correctly with a guid.

There are now default valies set in the datawindow.

 

Comment
  1. John Fauss
  2. Friday, 23 July 2021 14:52 PM UTC
Thank you for clarifying, Hans. The "Initial Value" field in the Column Specifications pane is designed only for constants, not SQL functions or PowerScript functions. There are a couple of exceptions to this, listed in the PB Help topic "Initial Property".. If you wish to populate this column with generated GUID's, you're going to have to do that work yourself in code. I invite others in the Community with ideas to respond with their ideas.
  1. Helpful
  1. Hans Groeneveld
  2. Friday, 23 July 2021 15:00 PM UTC
I do nut use Initial value but Identity Property. In the Help I do not see that SQL functions should nog work.
  1. Helpful
  1. Hans Groeneveld
  2. Friday, 23 July 2021 15:01 PM UTC
Attached a printscren of the database settings.
  1. Helpful
There are no comments made yet.
Hans Groeneveld Accepted Answer Pending Moderation
  1. Friday, 23 July 2021 15:00 PM UTC
  2. PowerBuilder
  3. # 3

Printscreen of the database settings.

 

Comment
  1. Chris Pollach @Appeon
  2. Friday, 23 July 2021 15:09 PM UTC
Thanks Hans! Please try removing the GUID column from the *updatable columns* list as it's not the DWO providing the value for the GUID column but then DBMS instead at "Insert" time. HTH
  1. Helpful
  1. Hans Groeneveld
  2. Tuesday, 17 August 2021 14:08 PM UTC
(Sorry for my late feedback, another project take my fully concern, the project was called 'holiday')



I removed the column GUID from the update but that did not work.

And I need the new GUID value for the child datawindows, if I insert row in the child datawindows I want to set the parent_id.

It seems to be a bug. I will create a ticket at Appeon.

Thanks for help.

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.