oracle - sysdate and current_date have different types? -
the oracle docs sysdate , current_date claim both return dates:
this test, though:
alter session set plsql_warnings = 'enable:all'; create table test(x date); create or replace procedure test1 authid definer cursor s select x test current_date > x; begin x in s loop null; end loop; end; / show errors drop table test; drop procedure test1;
produces output:
errors procedure test1: line/col error 3/42 plw-07204: conversion away column type may result in sub-optimal query plan
using sysdate not give same warning. suspect substituting current_date sysdate in queries runs risk of altering query plan, if date columns indexed.
edit:
select dump(current_date) dual; select dump(sysdate) dual;
gives:
dump(current_date) typ=13 len=8: 223,7,7,9,11,23,55,0 dump(sysdate) typ=13 len=8: 223,7,7,9,11,23,55,0
1) current_date returns current date in session time zone. need current_date? if not, stick sysdate. work procedure
2) if still need current_date, following solution. store value of current_date variable , resolve problem. let me if answers question.
drop table test; create table test(x date); create or replace procedure test1 authid definer datevar date; cursor s select x test datevar > x; begin datevar:=current_date; x in s loop null; end loop; end; / sql> show errors no errors.
Comments
Post a Comment