在PL/SQL创建procedure如下,关于变量v_lottype的使用,请高手指点指点!create or replace procedure test_procedure is v_lottype varchar2(40);
v_eoh number;
v_eoh1 number;begin
v_lottype:='(''P'',''R'',''M'')';
v_cuthour:='00'; --v_eoh
select nvl(sum(componentqty),0) into v_eoh from table1 ----返回结果为0,不正确 where lottype in v_lottype
and histdate=to_char(sysdate,'yyyymmdd')
and hour= v_cuthour ;
select nvl(sum(componentqty),0) into v_eoh1 from table1 ----返回正确结果1500 where lottype in ('P','R','M')
and histdate=to_char(sysdate,'yyyymmdd')
and hour= v_cuthour ;end;
v_eoh number;
v_eoh1 number;begin
v_lottype:='(''P'',''R'',''M'')';
v_cuthour:='00'; --v_eoh
select nvl(sum(componentqty),0) into v_eoh from table1 ----返回结果为0,不正确 where lottype in v_lottype
and histdate=to_char(sysdate,'yyyymmdd')
and hour= v_cuthour ;
select nvl(sum(componentqty),0) into v_eoh1 from table1 ----返回正确结果1500 where lottype in ('P','R','M')
and histdate=to_char(sysdate,'yyyymmdd')
and hour= v_cuthour ;end;
解决方案 »
- oracle中密码为加密。如果密码忘记如何处理
- Oracle导入导出
- JDBC连接ORACLE时怎么样在代码中修改连接用户名的登陆身份 如SYS必须以SYSDBA身份登陆
- Oracle安装完后忘记给用户解锁该怎么办?
- 求每天千万数据量的插入或更新一张大表高效存储过程
- 如何将A表一天中最后一条记录插入到B表
- java.sql.SQLException: Io 异常
- 安装oracle 9i 时出现tns 包写入失败错误,请帮忙!今天解决200分!明天解决100分!:)
- 高分求 weblogic与websphere性能比较 ,oracle与sybase性能比较文档
- oracle8.1.7字符查找
- 求救:如何将2条数据合并?
- 代码表的sql语句
而
v_lottype:='(''P'',''R'',''M'')'却只能理解为一个字符串
EXECUTE IMMEDIATE 'select nvl(sum(componentqty),0) from table1 where lottype in ' || v_lottype ||
'and histdate=to_char(sysdate,''yyyymmdd'') and hour= v_cuthour' INTO v_eoh;