Oracle Proc: ref param and FetchDataReader

Posts   
 
    
ianvink
User
Posts: 393
Joined: 15-Dec-2006
# Posted on: 21-Dec-2020 22:19:46   

I have a Proc that returns many cursors and ref params.

When I call the **AsQuery ** I only get the Ref Cursors, not the ref params:

        using var query = RetrievalProcedures.GetAccountDetailsCallAsQuery(username,
            ref accountTypeId,
            ref userNameOut,
            adapter);

        using (var reader = adapter.FetchDataReader(query, CommandBehavior.CloseConnection))
        {     .......
         }

**userNameOut **is "null"

But when I call it via this, I get the ref params:

RetrievalProcedures.AccountDetails(username, ref accountTypeId, ref userNameOut, adapter);

How can I get both in 1 call ?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 22-Dec-2020 08:35:24   

The parameters are returned by the datareader after the cursors are read and closed, which is why they aren't filled when you open the reader. Besides, output parameters are to be read on the IRetrievalQuery object, the values aren't magically filled into the variables you passed in.

Frans Bouma | Lead developer LLBLGen Pro
ianvink
User
Posts: 393
Joined: 15-Dec-2006
# Posted on: 18-Nov-2021 00:05:31   

Once the query is done and I close the Reader, how do I get the param values from the IRetrievalQuery ?

       using var adapter = new DataAccessAdapter();
        using var query = RetrievalProcedures.GetVasCodesCallAsQuery(userName, null, ref returnStatus);
        using var reader = await adapter.FetchDataReaderAsync(query, CommandBehavior.Default, new CancellationToken());

.....

   reader.close();

How do I get "returnStatus" from query ?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 18-Nov-2021 10:00:37   

A RetrievalQuery has a Parameters property which contains all parameters used in the DbCommand. You can obtain the value from there. Be aware tho that output parameters often are filled after the resultset has been consumed, at least on Oracle. So if you try to read output parameters before the resultset has been consumed they'll appear empty

Frans Bouma | Lead developer LLBLGen Pro