If you want your second transaction to be global you have to declare it as a global variable. This is done like this:
// Global Variables
Transaction gnv_sqlca // or whatever name you want. This will be the equivallent of sqlca for the second transaction...
If you want it as an instance (or shared - static) in a specific object then you have to declare it to the appropriate variables declaration of your object. Or if you want it available to a specific script, the above declaration should be done to that script.
For Global Declaration:
In you application's open object:
gnv_sqlca = create transaction
gnv_sqlca.DBMS = "Your DBMS"
gnv_sqlca.LogPass = "Password" // should be provided by user...
gnv_sqlca.ServerName = "Server Name"
gnv_sqlca.LogId = "username" // should be provided by user...
gnv_sqlca.AutoCommit = False // or true depending of what you want to do.
gnv_sqlca.DBParm = "" // Additional params if needed.
connect using gnv_sqlca;
if gnv_sqlca.sqlcode <> 0 then // Connection failed!
messagebox("Error:", gnv_sqlca.sqlerrtext) // See why...
halt close
end if
Attention: in any sql command that should not execute to sqlca, you should state what transaction it has to use. Example:
select count(*)
into :ll_counter
from dummy
using gnv_sqlca;
Also for datawindows:
dw_1.settransobject(gnv_sqlca) // or dw_1.settrans(gnv_sqlca) depending of what you want.
When the application ends you should disconnect and destroy your object:
// Probably your application's close event.
disconnect using gnv_sqlca;
if isvalid(gnv_sqlca) then destroy gnv_sqlca
In case your didn't create your object as a global object then you should disconnect and destroy your object from the appropriate object - script.
Andreas.