0

The Query behind datawindow is Select * from MyTable. I changed the table and added another column. When i retrieve the datawindow in design mode, it does not show me the new column i added in MyTable

I assume that Select * from MyTable will not require editing datawindow in design mode and every change in database table will update the datawindow design as well.

How do i get all the columns in column specifications without changing datawindow in design mode to manually add the column in detail area of the datawindow?

PowerBuilder 12.5 / MSSQL Server 2008

2 Answers 2

1

If you want to do this, you can use the create method of your datawindow control:

String new_sql, new_syntax, errorsyntaxfromSQL, errorcreate

new_sql = 'SELECT * from Mytable'
new_syntax = SQLCA.SyntaxFromSQL(new_sql, 'Style(Type=Form)', error_syntaxfromSQL)
// Generate new DataWindow
dw_new.Create(new_syntax, error_create)

It is up to you to test the possible errors.

Sign up to request clarification or add additional context in comments.

4 Comments

What Marc said. The reason the DW doesn’t update at runtime is that it’s trying to save you a round trip to the database to Describe the result set by caching it at design time. Marc’s solution will get you the flexibility you want, at the cost of runtime performance. (How much performance depends on your database, network, and how often you’re pulling the data set definition.)
Runtime performance will not be effected because that solution will be applied on hidden datawindow controls which i believe are not many in one window. This solution will not work on already designed datawindows because of columns on the left side of grid datawindows should not lost proper look. Still it will work in most cases where look is not the issue because designing newly added columns at runtime is sure expensive for performance. i have no other solution in my mind.
when there is where clause and retrieval arguments just the query change is not enough.
I am sorry, i passed a query to the SyntaxFromSQL that had retrieval arguments in it. like "Where dep_id = :depid" which was wrong way. i was supposed to prepare query with exact value like "Where dep_id = '123' " and then pass it to SyntaxFromSQL function. That was mistake i made in my previous attempt while testing your solution. It is working fine. Thanks a lot.
0

I assume that Select * from MyTable will not require editing datawindow in design mode and every change in database table will update the datawindow design as well.

This is not a valid assumption. If you change the underlying table columns either by adding, removing, or datatypes, you have to bring any datawindow objects which reference that table (by reference I mean you want to use the new column or had used an old column or one with the changed datatype) back into the editor to have them reflected in that dwo.

Another option is to edit the source of the datawindow object but this would only be for trivial updates (like you expanded a varchar field from 10 to 20).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.