还是昨天的那个存储过程:
create or replace procedure shop_sale_receive(
userAutoId IN number,
shopAutoId in number,
startDate in varchar2,
endDate in varchar2,
r_cur out SYS_REFCURSOR
)
IS
sqls VARCHAR2(1000);
r_cur SYS_REFCURSOR;
BEGIN
sqls:='select ORDER_T.CREATEDATE,
ORDER_T.ID,
ORDER_T.PAIDACCOUNT,
ORDER_T.CASH,
ORDER_T.CHEQUE,
ORDER_T.CREDIT,
ORDER_T.CHARGEUP,
ORDER_T.CURRENCYEXCHANGE,
ORDER_T.OTHERRECEIVE,
ORDER_T.STATUSID,
ORDER_T.REMARK,
ORDER_T.ORDERTYPE,
ORDER_T.CUSTOMERNAME
from ORDER_T where ORDER_T.ENABLE=1 and ORDER_T.shopAutoId='||shopAutoId||'
and ORDER_T.ORDERTYPE in ('||'''sale.receives'''||','||'''sale.receives.red'''||')
and ORDER_T.STATUS ='||'''ACCEPT''';
IF userAutoId!=0 THEN
sqls:=sqls||' and order_t.customerAutoId='||userAutoId;
END if;
dbms_output.put_line(startDate) ;
if startDate is not null then
sqls:=sqls||' and to_char(ORDER_T.createDate,'||'''yyyy-MM-dd'''||')>='||''''||startDate||'''';
end if;
if endDate is not null then
sqls:=sqls||' and to_char(ORDER_T.createDate,'||'''yyyy-MM-dd'''||') <='||'''' ||endDate||'''';
end if; dbms_output.put_line(sqls);
open r_cur for sqls;
end; 这个存储过程 怎么去执行 还有就是我想打印下 看下 有没有执行SQLS 这个变量 打印下我查出来的东西
create or replace procedure shop_sale_receive(
userAutoId IN number,
shopAutoId in number,
startDate in varchar2,
endDate in varchar2,
r_cur out SYS_REFCURSOR
)
IS
sqls VARCHAR2(1000);
r_cur SYS_REFCURSOR;
BEGIN
sqls:='select ORDER_T.CREATEDATE,
ORDER_T.ID,
ORDER_T.PAIDACCOUNT,
ORDER_T.CASH,
ORDER_T.CHEQUE,
ORDER_T.CREDIT,
ORDER_T.CHARGEUP,
ORDER_T.CURRENCYEXCHANGE,
ORDER_T.OTHERRECEIVE,
ORDER_T.STATUSID,
ORDER_T.REMARK,
ORDER_T.ORDERTYPE,
ORDER_T.CUSTOMERNAME
from ORDER_T where ORDER_T.ENABLE=1 and ORDER_T.shopAutoId='||shopAutoId||'
and ORDER_T.ORDERTYPE in ('||'''sale.receives'''||','||'''sale.receives.red'''||')
and ORDER_T.STATUS ='||'''ACCEPT''';
IF userAutoId!=0 THEN
sqls:=sqls||' and order_t.customerAutoId='||userAutoId;
END if;
dbms_output.put_line(startDate) ;
if startDate is not null then
sqls:=sqls||' and to_char(ORDER_T.createDate,'||'''yyyy-MM-dd'''||')>='||''''||startDate||'''';
end if;
if endDate is not null then
sqls:=sqls||' and to_char(ORDER_T.createDate,'||'''yyyy-MM-dd'''||') <='||'''' ||endDate||'''';
end if; dbms_output.put_line(sqls);
open r_cur for sqls;
end; 这个存储过程 怎么去执行 还有就是我想打印下 看下 有没有执行SQLS 这个变量 打印下我查出来的东西
也可以用第三工具的调试功能执行下,比如TOAD
不过需要你的用户有调试存储过程的权限
问题是 过程中最后一个参数 我该怎么传调用的时候是不是 应该写declare
a SYS_REFCURSOR;
begin
shop_sale_receive(7105,311,'2009-12-01','2009-12-30' a)
end;
如果我要打印返回来的那个 a
该怎么样搞
你在该过程上右键,弹出菜单里有“test”
选择之,就有一个测试窗口出来。
窗口下方可以输入过程参数值(参数名自动显示)。
输好参数值,点击开始按钮初始化。接下来可以单步调试,也可以一次运行。
运行完毕,点游标输出参数右边的按钮,在新窗口里显示游标结果数据集。
如果是普通输出值,则已直接显示。至于“还有就是我想打印下 看下 有没有执行SQLS 这个变量”,这个就是异常捕捉了。
如设置一个输出参数,若执行了,输出“执行成功”;若执行失败,输出“执行失败”。
var a REFCURSOR;
exec shop_sale_receive(7105,311,'2009-12-01','2009-12-30',:a);执行完毕后
print :a;
即可看见游标取出的结果内容。
在存储过程右键点击 测试
在下面那个框 值那一列 填写数据值
让后运行(F8);
已执行
点击 游标 那一行 右边的那个... 按钮
让后就说无结果集
弹出个框就说 提取违反顺序