|
returned through output parameters.To create the stored procedure, run a query like the following. create procedure testproc(in1 in number, in2 in number, in3 in varchar2, out1 out number, out2 out number, out3 out varchar2) is
begin
out1:=in1;
out2:=in2;
out3:=in3;
end;
To execute the stored procedure from an SQL Relay program, use code like the following. sqlrcur_prepareQuery(cur,"begin testproc(:in1,:in2,:in3,:out1,:out2,:out3); end;");
sqlrcur_inputBindLong(cur,"in1",1);
sqlrcur_inputBindDouble(cur,"in2",1.1,2,1);
sqlrcur_inputBindString(cur,"in3","hello");
sqlrcur_defineOutputBind(cur,"out1",20);
sqlrcur_defineOutputBind(cur,"out2",20);
sqlrcur_defineOutputBind(cur,"out3",20);
sqlrcur_executeQuery(cur);
char *out1=sqlrcur_getOutputBind(cur,"out1");
char *out2=sqlrcur_getOutputBind(cur,"out2");
char *out3=sqlrcur_getOutputBind(cur,"out3");
To drop the stored procedure, run a query like the following. drop procedure testproc
Sybase and Microsoft SQL Server
To create the stored procedure, run a query like the following. create procedure testproc @in1 int, @in2 float, @in3 varchar(20), @out1 int output, @out2 int output, @out3 int output as
select @out1=convert(varchar(20),@in1),
@out2=convert(varchar(20),@in2),
@out2=convert(varchar(20),@in2)
To execute the stored procedure from an SQL Relay program, use code like the following. sqlrcur_prepareQuery(cur,"exec testproc");
sqlrcur_inputBindLong(cur,"in1",1);
sqlrcur_inputBindDouble(cur,"in2",1.1,2,1);
sqlrcur_inputBindString(cur,"in3","hello");
sqlrcur_defineOutputBind(cur,"out1",20);
sqlrcur_defineOutputBind(cur,"out2",20);
sqlrcur_defineOutputBind(cur,"out3",20);
sqlrcur_executeQuery(cur);
char *out1=sqlrcur_getOutputBind(cur,"out1");
char *out2=sqlrcur_getOutputBind(cur,"out2");
char *out3=sqlrcur_getOutputBind(cur,"out3");
To drop the stored procedure, run a query like the following. drop procedure testproc
Interbase and Firebird
To create the stored procedure, run a query like the following. create procedure testproc(in1 integer, in2 float, in3 varchar(20)) returns (out1 integer, out2 float, out3 varchar(20)) as
begin
out1=in1;
out2=in2;
out3=in3;
suspend;
end;
To execute the stored procedure from an SQL Relay program, use code like the following. sqlrcur_prepareQuery(cur,"select * from testproc(?,?,?)");
sqlrcur_inputBindLong(cur,"1",1);
sqlrcur_inputBindDouble(cur,"2",1.1,2,1);
sqlrcur_inputBindString(cur,"3","hello");
sqlrcur_executeQuery(cur);
char *out1=sqlrcur_getFieldByIndex(cur,0,0);
char *out2=sqlrcur_getFieldByIndex(cur,0,1);
char *out3=sqlrcur_getFieldByIndex(cur,0,2);
Alternatively, you can run a query like the following and receive the result using a output bind variables. Note that in Interbase/Firebird, input and output bind variable indices are distict from one another. The index of the first output bind variable is 1 rather than 4, even though there were 3 input bind variables. sqlrcur_prepareQuery(cur,"execute procedure testproc ?, ?, ?");
sqlrcur_inputBindLong(cur,"1",1);
sqlrcur_inputBindDouble(cur,"2",1.1,2,1);
sqlrcur_inputBindString(cur,"3","hello");
sqlrcur_defineOutputBind(cur,"1",20);
sqlrcur_defineOutputBind(cur,"2",20);
sqlrcur_defineOutputBind(cur,"3",20);
sqlrcur_executeQuery(cur);
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >> [Access]sql随机抽取记录 [Access]ASP&SQL让select查询结果随机排序的实现方法 [办公软件]在sybase中插入图片、PDF、文本文件 [办公软件]安装Sybase ASE [办公软件]linux指令大全(完整篇) [办公软件]Linux新手入门常用命令大全 [办公软件]在RedHat Linux 9里安装gaim0.80 [办公软件]浅谈Linux 下Java 1.5 汉字方块问题解决方法 [办公软件]Linux程序员必读:中文化与GB18030标准 [办公软件]linux指令大全
|