我有个存储过程
create or replace procedure shop_sale_receive(
userAutoId IN number,
shopAutoId in number,
startDate in varchar2,
endDate in varchar2
)
as
sqls VARCHAR2(1000);
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);
EXECUTE IMMEDIATE sqls; //这句执行sql语句 但是执行了 怎么没有返回结果;
end;
------解决方案--------------------
返回一个游标 试试
------解决方案--------------------
CREATE OR REPLACE procedure selectAllEmployments
(r_cur OUT SYS_REFCURSOR)
IS
r_cur SYS_REFCURSOR;
BEGIN
OPEN r_cur FOR
SELECT EMPLOYEE, EMPLOYER,
STARTDATE, ENDDATE,
REGIONCODE, EID, VALUE, CURRENCY
FROM EMPLOYMENT;
END;
------解决方案--------------------
数据集赋给游标,还要将游标里的数据读出来才行
------解决方案--------------------
楼主可以通过建视图来查询结果
EXECUTE IMMEDIATE sqls; -->
execute immediate 'create or replace view view_tmp as '
------解决方案--------------------
sqls;
执行完过程后查询select * from view_tmp
------解决方案--------------------