Correct, each sub-thread gets its own new copy of SQLCA and thus the dbHandle would be 0 initially until you either connect or pass in a pointer to the real SQLCA. For example:
of_init (ref transaction ao_trans)
SQLCA = ao_trans
---- However, I would personally recommend instead ------
of_init (ref transaction ao_trans)
ns_transaction io_trans // Instance pool
io_trans = ao_trans
Yes, this is the scenario I often encountered where each sub-thread gets its own connection via its own SQLCA - thus you have one DB thread per PB App sub-thread and its quite easy then for one DB thread to lock out another if you do not design your DML access properly. The alternatives are to a) use one copy of SQLCA as THE db access thread, b) let the main task handle all DBIO or c) let one sub-thread handle all DBIO.