user1788373
user1788373

Reputation: 39

powerbuilder datawindow update error

I am trying to insert a new record but sometimes datawindow not includes all the column .

All columns are selected in the update properties but i am not getting all the columns in the insert statement.

Upvotes: 1

Views: 3887

Answers (2)

oscs
oscs

Reputation: 41

Are you perhaps not calling accepttext() before the update?

Upvotes: 0

Terry
Terry

Reputation: 6215

The DataWindow isn't going to always include all columns in an INSERT statement that it generates. A column's inclusion on a given row is going to depend on that item's status that the DataWindow maintains. If the DataWindow sees that column as DataModified!, the column will be included in the INSERT. This way, it's not generating and sending unnecessary SQL.

The natural ways that a column's status will be set to DataModified! include data entry by the user, and if the column has an Initial value set in the DataWindow and another column has been data entered. (i.e. columns with Initial values are automatically set to DataModified!, but only after another column has been set to DataModified!). The synthetic way you can set a column to DataModified! is programmatically with the SetItemStatus() function. (Just be warned that I've often see people try to use this function, and they end up with unintended consequences; you need to carefully think through all the possibilities when using this function and test thoroughly.)

If there are still unexplained holes in your application's behaviour, I'd set a breakpoint in the SQLPreview event of the DataWindow and explore the columns' values, original value and item statuses. Looking at these three values will pretty much always explain the generated SQL. Explaining how these values got to their current state... often requires more digging.

Good luck,

Terry.

Upvotes: 1

Related Questions