Other ways of achieving the result
1. Create an NVO [ nc_dynamic_sql ]
2. Insert a datastore [ ds_store ] in it.
3. Write a function, to create datawindow from dynamic SQL [ of_result_from_sql [value string as_query, ref datastore as-result_ds, ref string as_msg, value transaction at_transaction]
************* Function of_result_from_sql () ****************
Parameter(s)
Sl. PassBY Argument Type ArgumentName
1. Value String as_query
2. reference datastore as_result_ds
3. reference string as_msg
4. value transaction at_transaction
*************
String ls_present_str
String ls_syntax_str
Long ll_return, ll_ret
ll_return = 0
ls_present_str = "style(type=tabular)"
ls_syntax_str = at_transaction.SyntaxFromSQL(as_query, ls_present_str, as_msg)
If ls_syntax_str = "" Then
Messagebox('Elifa', 'Syntax Error~r~n' + as_msg)
Return -1
End If
ds_store.Create(ls_syntax_str, as_msg)
ll_ret = ds_store.SetTransObject(at_transaction)
ds_store.Retrieve()
as_result_ds = ds_store
Return 1
*****************************
To call this function:
ls_sql = " Select (a.field1) as field1 "
ls_sql += " From table1 a "
ls_sql += " Join table2 b "
ls_sql += " On b.field2 = a.field2 "
io_sql.of_result_from_sql(ls_sql, ds_1, ls_msg, Sqlca)
If ds_1.RowCount() > 0 and Len(Trim(ls_msg)) = 0 Then
For i = 1 To ds_1.RowCount()
// Process the result here
Next
Else
If Len(ls_msg) > 0 Then io_message.Messagebox('Error in Query', ls_msg)
End If
With the above function(s), one can read result from dynamically created queries.
HTH
Happiness Always
BKR Sivaprakash