Reputation: 582
CREATE QUERY ohQuery.
ohQuery:SET-BUFFERS(hBuffer).
OhQuery:QUERY-PREPARE("FOR EACH " + ip-tablename ).
ohQuery:QUERY-OPEN().
ohQuery:GET-FIRST().
ip-tablename = value from UI (combo box)
Now I need to create a temp-table for this query. How to create?
If I am using create-like method what value should I pass in this?
Upvotes: 0
Views: 2845
Reputation: 548
To create a temp-table dynamically at runtime, you need either a handle to a buffer of said table, or the table-name itself. Seeing as you already have the handle to the buffer of 'ip-tablename' (I am assuming hBuffer is a buffer to the table with name 'ip-tablename', otherwise your above statement won't work), you should use that handle instead of 'just' the table-name out of performance reasons. Here's how to do it:
DEF VAR ttH AS HANDLE NO-UNDO.
ttH:CREATE-LIKE(hBuffer).
Optionally, you can also use 'ip-tablename' for the create-like method, although it doesn't perform as well:
ttH:CREATE-LIKE(ip-tablename).
Don't forget that you'll need to use the temp-table prepare method before you can use your new temp-table:
ttH:TEMP-TABLE-PREPARE("myNewTempTable").
Hope that helps!
Upvotes: 2