To bzszp(SongZip): 版主,如果是to_date,那么ddsendtime字段小时分秒就没有记录了
select * from table_name where truncate(ddsendtime)> to_date('2004-08-17','yyyy-mm-dd') and truncate(ddsendtime)<=to_date('2004-08-19','yyyy-mm-dd')
select * from table1 where ddsendtime between to_date('xxxxxxxx','yyyymmdd') and to_date('xxxxxxxx','yyyymmdd');
请问这条存储过程那里有错误? proc.......(pcstarttime in varchar2.pcendtime in varchar2); as ipcstarttime date; ipcendtime date; csql varchar(2000); begin ipcstarttime:=to_date(pcstarttime,'yyyy-mm-dd hh24:mi:ss') ipcendtime :=to_date(pcendtime,yyy-mm-dd hh24:mi:ss') sql:=select .... from ... where ddsendtime>ipcstarttime and ddsendtime <iendtime;end; 在这里between ... and ... 也不能用 分数只给解答对问题的人?
这是正确的写法,一定要注意日期格式的转换。 create or replace procedure Pr_Temp (pcstarttime in varchar2,pcendtime in varchar2) is ipcstarttime date; ipcendtime date; csql varchar(2000); begin ipcstarttime:=to_date(pcstarttime,'yyyy-mm-dd hh24:mi:ss'); ipcendtime :=to_date(pcendtime,'yyyy-mm-dd hh24:mi:ss');
csql:='select * from HOLIDAY_INFO where BEGINDATE >''' || ipcstarttime ||''' and BEGINDATE < ''' || ipcendtime ||''''; execute immediate csql;end;
版主,如果是to_date,那么ddsendtime字段小时分秒就没有记录了
from table_name
where truncate(ddsendtime)> to_date('2004-08-17','yyyy-mm-dd')
and truncate(ddsendtime)<=to_date('2004-08-19','yyyy-mm-dd')
proc.......(pcstarttime in varchar2.pcendtime in varchar2);
as
ipcstarttime date;
ipcendtime date;
csql varchar(2000);
begin
ipcstarttime:=to_date(pcstarttime,'yyyy-mm-dd hh24:mi:ss')
ipcendtime :=to_date(pcendtime,yyy-mm-dd hh24:mi:ss')
sql:=select .... from ... where ddsendtime>ipcstarttime and ddsendtime <iendtime;end;
在这里between ... and ... 也不能用
分数只给解答对问题的人?
是语法错,
“ipcstarttime:=to_date(pcstarttime,'yyyy-mm-dd hh24:mi:ss')”没有“;”
.....
你的那个sql查询没有返回给变量嘛。
单记录返回给变量,多条记录返回给游标......
create or replace procedure Pr_Temp (pcstarttime in varchar2,pcendtime in varchar2)
is
ipcstarttime date;
ipcendtime date;
csql varchar(2000);
begin
ipcstarttime:=to_date(pcstarttime,'yyyy-mm-dd hh24:mi:ss');
ipcendtime :=to_date(pcendtime,'yyyy-mm-dd hh24:mi:ss');
csql:='select * from HOLIDAY_INFO where BEGINDATE >''' || ipcstarttime ||''' and BEGINDATE < ''' || ipcendtime ||'''';
execute immediate csql;end;