cancel
Showing results for 
Search instead for 
Did you mean: 

PB Newbie - Fetch

Former Member
0 Kudos
78

Hi PB Gurus!

I need your expertise again.

I have a fetch statement, it is working fine. I am able to fetch it and put it into a ddlb.

Now, I have a proxy table, I executed my query on the DB painter and it is ok also.

But when I tried a fetch and put it in a ddlb, nothing happens. What am I doing wrong?

Here is my sample code:

connect using SQLCA_PIS;


DECLARE xy CURSOR FOR
SELECT distinct internal_org_unit_name FROM dbo.prxy_org_internal_org order by internal_org_unit_name ;
OPEN xy;
FETCH xy INTO :v_div ;
DO UNTIL sqlca.sqlcode <> 0
ddlb_2.AddItem(v_div);
FETCH xy INTO :v_div;
LOOP
CLOSE xy;

TIA,


Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Because your embedded SQL (except for the connect using SQLCA_PIS;) statements do not specify a connection it uses SQLCA by default.

Assume you wanted to use SQLCA_pis and not SQLCA ?

Former Member
0 Kudos

Perfect!

Thank you so much, Lars!

Former Member
0 Kudos

I have an app that uses two different transaction objects. Neither is SQLCA. So to avoid annoying quiet failures I actually DESTROY SQLCA. I'd rather get a null reference object if I have forgotten to specify which database I wanted to consult than spend hours wondering why the thing don't work.

Of course good practice is to check SQLCode < 0 every time.

I sometimes have a function on the transaction object called notok() returning a boolean:


return ( this.SQLCode < 0 )

And a method that displays error after rolling back called fail():

   


  string lsError

     lsError = this.SQLErrText

     ROLLBACK using this;

     MessageBox ( 'Database Problem', lsError )

     return -1

That enables


   Update ..... Using SQLCA;

     if SQLCA.NotOK() then return SQLCA.Fail()

Former Member
0 Kudos

This is so cool!

Thanks!

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ryan;

FWIW: I would suggest replacing all DDLB's with Drop Down DataWindow's (DDDW). No muss, no fuss, no cursors, no fetching, etc, etc.

Just my $0.02.

Regards ... Chris

Former Member
0 Kudos

Something to note on that, if the main and dropdown DataWindow need to use a different transaction object, he will need to use GetChild and then retrieve the dddw manually.

ricardojasso
Participant
0 Kudos

Absolutely. The dd datawindow does all the fetching, looping, and inserting in the drop down control for you.