动态执行sql语句 我有个存储过程
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;