09-24-2013 12:03 PM
i have this Dcl
$ set ver
$ Ws := "Write Sys$output"
$ Com_Totreg == 5
DECLARE :Sql_Totreg INTEGER;
atta 'f bdcesantia';
set tran read o;
select Count(*) into :Sql_Totreg from ctabcuo;
PRINT :Sql_Totreg ;
$ Ws "Registros Leidos(Com):''Com_Totreg'"
$ Ws "Registros Leidos(Sql):''Sql_Totreg'"
....the question is : how can "rescue" the result of select count(*) to a variable of Dcl.......i need somethin like this :
Thanks very much.
09-24-2013 12:40 PM
I don't think there is a provisioned method.
Typically you would redirect the SQL output into a file or pipe, and parse the output.
You may want to check out the RDB facilty to call external function such as LIB$SET_SYMBOL or LIB$SET_LOGICAL
09-25-2013 01:00 AM
The best you can do is to define a job logical name (assumed you have SQL$DATABASE pointing to your database), like:
$ pipe ( write sys$output "set display no row counter" ; write sys$output "select '$ def/job Sql_Totreg ',Count(*) from ctabcuo;" ) | mc sql$ | @sys$pipe
$ Sql_Totreg = f$log("Sql_Totreg")
Sure enough, you can use a DCL script instead of the two write statements in parentheses.