WorkerName in Varchar2, --参数
Starttime in Varchar2,
Endtime in Varchar2, strSql:='';
strSql:=strSql || 'insert into tempStat ' || chr(10);
strSql:=strSql || 'select recvid,id,case when c.inputonetime is not null then 1 else 0 end input1,' || chr(10);
strSql:=strSql || 'case when c.inputtwotime is not null then 1 else 0 end input2,' || chr(10);
strSql:=strSql || 'case when c.xiaoduitime is not null then 1 else 0 end xiao,' || chr(10);
strSql:=strSql || 'case when c.relationtime is not null then 1 else 0 end relat' || chr(10);
strSql:=strSql || 'from viewYeWu c ' || chr(10);
strSql:=strSql || 'where ' || chr(10);
strSql:=strSql || '(c.inputoneren=:1 and c.inputonetime>=to_date(:2,''yyyy-mm-dd hh24:mi:ss'') ' || chr(10);
strSql:=strSql || ' and c.inputonetime<=to_date(:3,''yyyy-mm-dd hh24:mi:ss''))' || chr(10);
strSql:=strSql || ' or (c.inputtworen=:1 and c.inputtwotime>=to_date(:2,''yyyy-mm-dd hh24:mi:ss'')' || chr(10);
strSql:=strSql || ' and c.inputtwotime<=to_date(:3,''yyyy-mm-dd hh24:mi:ss''))' || chr(10);
strSql:=strSql || ' or (c.xiaoduiren=:1 and c.xiaoduitime>=to_date(:2,''yyyy-mm-dd hh24:mi:ss'')' || chr(10);
strSql:=strSql || ' and c.xiaoduitime<=to_date(:3,''yyyy-mm-dd hh24:mi:ss''))' || chr(10);
strSql:=strSql || ' or (c.guanlianren=:1 and c.relationtime>=to_date(:2,''yyyy-mm-dd hh24:mi:ss'')' || chr(10);
strSql:=strSql || ' and c.relationtime<=to_date(:3,''yyyy-mm-dd hh24:mi:ss''))' || '';-- open myCur for strSql;
execute immediate strSql using Workername,Starttime,Endtime;执行后提示:
ORA-01008: 并非所有变量都已关联
Starttime in Varchar2,
Endtime in Varchar2, strSql:='';
strSql:=strSql || 'insert into tempStat ' || chr(10);
strSql:=strSql || 'select recvid,id,case when c.inputonetime is not null then 1 else 0 end input1,' || chr(10);
strSql:=strSql || 'case when c.inputtwotime is not null then 1 else 0 end input2,' || chr(10);
strSql:=strSql || 'case when c.xiaoduitime is not null then 1 else 0 end xiao,' || chr(10);
strSql:=strSql || 'case when c.relationtime is not null then 1 else 0 end relat' || chr(10);
strSql:=strSql || 'from viewYeWu c ' || chr(10);
strSql:=strSql || 'where ' || chr(10);
strSql:=strSql || '(c.inputoneren=:1 and c.inputonetime>=to_date(:2,''yyyy-mm-dd hh24:mi:ss'') ' || chr(10);
strSql:=strSql || ' and c.inputonetime<=to_date(:3,''yyyy-mm-dd hh24:mi:ss''))' || chr(10);
strSql:=strSql || ' or (c.inputtworen=:1 and c.inputtwotime>=to_date(:2,''yyyy-mm-dd hh24:mi:ss'')' || chr(10);
strSql:=strSql || ' and c.inputtwotime<=to_date(:3,''yyyy-mm-dd hh24:mi:ss''))' || chr(10);
strSql:=strSql || ' or (c.xiaoduiren=:1 and c.xiaoduitime>=to_date(:2,''yyyy-mm-dd hh24:mi:ss'')' || chr(10);
strSql:=strSql || ' and c.xiaoduitime<=to_date(:3,''yyyy-mm-dd hh24:mi:ss''))' || chr(10);
strSql:=strSql || ' or (c.guanlianren=:1 and c.relationtime>=to_date(:2,''yyyy-mm-dd hh24:mi:ss'')' || chr(10);
strSql:=strSql || ' and c.relationtime<=to_date(:3,''yyyy-mm-dd hh24:mi:ss''))' || '';-- open myCur for strSql;
execute immediate strSql using Workername,Starttime,Endtime;执行后提示:
ORA-01008: 并非所有变量都已关联
嗯,说的不错,是变量问题啊!恭喜楼主自己搞定问题了!自己动手,丰衣足食啊!