你pro*c都会,别说存储过程了
但不明白你说的“就组包tcp通讯发送到服务器处理”
create or replace procedure test(mypara number)
as
type ref_cursor is ref cursor;
your_cursor ref_cursor;
var1 varchar2;
var2 varchar2;
begin
if mypara=100 then
open your_cursor for select currtype,productno from table where status='0';
elsif mypara=101 then
open your_cursor for select currtype,productno from table where status='1';
end if;
loop
fetch your_cursor into var1,var2;
exit when your_cursor%notfound;
end loop;
close your_cursor;
end test;
/
但不明白你说的“就组包tcp通讯发送到服务器处理”
create or replace procedure test(mypara number)
as
type ref_cursor is ref cursor;
your_cursor ref_cursor;
var1 varchar2;
var2 varchar2;
begin
if mypara=100 then
open your_cursor for select currtype,productno from table where status='0';
elsif mypara=101 then
open your_cursor for select currtype,productno from table where status='1';
end if;
loop
fetch your_cursor into var1,var2;
exit when your_cursor%notfound;
end loop;
close your_cursor;
end test;
/
sprintf(sendbuf,"%s%s",var1,var2)组包,write到服务器上,等服务器处理完后,read服务器处理结果信息,将这条记录的处理结果写入日志文件,然后再循环读下一条记录,继续做如上的事情,直到读完所有记录为止。楼上的这个存储过程好像对我来说没有什么用途吧,不过还是谢谢你的心意!
#define FETCH_COUNT 10000strcpy(lsSql,"select currtype,productno from table where status=");
switch(i_input)
{
case 100:
sprintf(lsSql,"%s'0'"lsSql);
break;
case 101:
sprintf(lsSql,"%s'1'"lsSql);
break;
...
default:
break;
}/*不管参数如何,下面部分相同*/
EXEC SQL prepare sc from :lsSql;EXEC SQL declare mycur for sc;EXEC SQL open mycur;while(sqlca.sqlcode!=1403)
{
EXEC sql for :FETCH_COUNT fetch ... into ...
.....
}
第二种写法:
#define FETCH_COUNT 10000
strcpy(lsSql,"select currtype,productno from table where status=:ph001");
switch(i_input)
{
case 100:
strcpy(ph1,"0");
break;
case 101:
strcpy(ph1,"1");
break;
...
default:
break;
}/*不管参数如何,下面部分相同*/
EXEC SQL prepare sc from :lsSql;EXEC SQL declare mycur for sc EXEC SQL open mycur using :ph1;;while(sqlca.sqlcode!=1403)
{
EXEC sql for :FETCH_COUNT fetch ... into ...
.....
}
如果你e文好,可以看oracle文档,比我解释得强得多