define temp-table ttfoo ... // was foo
define bufer bufoo for ttfoo. // was foo
Hello Stefan, could you please tell me what you mean by "why not just rename the temp-table and put it in its own namespace?" At the moment, I have a define temp-table in my program and all queries use the temp-table. Now the temp-table is in the database like any other table.Yes, a dynamic temp-table can only be queried dynamically. A static temp-table can be queried statically or dynamically.
You can also pass a dynamic temp-table as table-handle to a static receiver (I think).
But why not just rename the temp-table and put it in its own namespace?
Code:define temp-table ttfoo ... // was foo
All use of the temp-table should be referencing buffers on the temp-table, so you only need to refactor the buffer definitions:
Code:define bufer bufoo for ttfoo. // was foo
I have to replace static temp-table with a dynamic temp-table in my application because the table will now exist in the database.
Now the temp-table is in the database like any other table.
I mean that temp-table is being removed. Instead, a table to database is added having the same fields as temp-table. my screen (used for display) and its queries, still use the temp-table as defined earlier. Now, I intend to remove the temp-table and have it as a database table."The temp-table is in the database" doesn't make sense to me. Database tables are in the database. Temp-tables are client-side.
Do you mean that data that you previously wrote to and read from a static temp-table will now reside in a database table? And that you are going to cache that table's data in a temp-table?
Or do you mean something else?
Present tense.that temp-table is a database table now.
Future tense.I intend to remove the temp-table and have it as a database table.
define temp-table ttQuote no-undo
field quote-date as date
field risk as character
field client-name as character
field address as character
field product-code as character
field risk-num as integer
field risk-version as integer
field risk-det-num as integer
field state as character.
/* getdyn.p
*
* run ./getdyn.p ( "customer", "where custNum = 1", "name,custNum,state,xyzzy", output resultList ).
*
*/
define input parameter tableName as character no-undo.
define input parameter whereClause as character no-undo.
define input parameter fieldList as character no-undo.
define output parameter resultList as character no-undo.
define variable b as handle no-undo.
define variable q as handle no-undo.
define variable qs as character no-undo.
define variable fv as character no-undo.
define variable i as integer no-undo.
resultList = ?.
qs = substitute( "for each &1 &2", tableName, whereClause ).
/* message qs. */
create query q.
create buffer b for table tableName.
q:set-buffers( b ).
q:query-prepare( qs ).
q:query-open.
if q:get-next( no-lock ) = false then
do:
message "record not found: " qs.
return.
end.
do i = 1 to num-entries( fieldList ):
resultList = resultList + ( if i > 1 then "," else "" ).
assign
fv = ?
fv = b:buffer-field( entry( i, fieldList )):buffer-value()
no-error.
resultList = resultList + quoter( fv ).
end.
return.