1. Pam Koch
  2. PowerBuilder
  3. Tuesday, 20 April 2021 18:41 PM UTC

Is it possible to create a dynamic datastore, with a stored procedure as the data source, without executing the stored procedure twice?   

Given the below code, the stored procedure executes once for the SyntaxfromSQL and once for the retrieve.

ls_sp = "execute " + <stored procedure name with parameters>
ls_dwsyntax = SQLCA.SyntaxFromSQL(ls_sp, "", ps_errors)
ps_datastore.Create(ls_dwsyntax, ps_errors)
ps_datastore.SetTransObject(ps_sqlca)
ll_retrieve = ps_datastore.retrieve()

We are trying to avoid creating a datawindow each time we need to run a stored procedure to retrieve data, as we only use stored procedures instead of SQL selects.

Thanks.

John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 20 April 2021 20:39 PM UTC
  2. PowerBuilder
  3. # 1

Greetings, Pam -

I suspect the answer is no. When the composition of the result set (number of columns and datatype of each column) is not known, PB has to ask the DBMS for a description. That's relatively easy when the data source is a SELECT statement. When the data source is a stored procedure, the DBMS may have to execute the stored procedure in order to obtain the result set description. That is what I suspect is occurring.

If you can manage to utilize DataWindow objects in your DataStore instead of dynamically creating from syntax, you can avoid this overhead.

Regards, John

Comment
  1. Pam Koch
  2. Tuesday, 20 April 2021 21:24 PM UTC
Thanks John, that's what I suspected. I was secretly hoping that there was some magical, undocumented feature that would retrieve the schema and data at the same time. :)
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.