function - Comparison between my day in table and the sysdate in server -
i'm trying write function return day_id after comparing current day name on server , day name on table contents
**my code is
create or replace function getsysdate return char v_day char(20) ; v_day_id days.day_id%type ; v_day_name days.day_name%type ; begin select day_id, to_char(sysdate, 'day', 'nls_date_language=arabic'), day_name v_day_id,v_day,v_day_name days v_day_name = v_day ; return v_day_id ; end; but unfortunately,it's no data found !
note ! : datatype of day_name varchar (20 byte)
**the error connecting database admin. ora-01403: no data found ora-06512: @ "admin.getsysdate", line 9 ora-06512: @ line 5 process exited. disconnecting database admin. ** table day_id number day_name varchar2(20 byte)
your filter using local variables have not been initialised; in fact you're trying set them , use them filter @ same time, doesn't make sense.
where v_day_name = v_day ... never going match records table.
i think want:
create or replace function getsysdate return days.day_id%type v_day_id days.day_id%type; begin select day_id v_day_id days day_name = to_char(sysdate, 'day', 'nls_date_language=arabic'); return v_day_id; end; / i don't know how days table populated, i'm guessing day_id 1-7 , day_name corresponding day, , in region can't simple to_char. this sql fiddle shows function based on assumption, ids in wrong order. i've shown both assignment in anonymous block, , used plain sql.
Comments
Post a Comment