I am use unix shell script to called an sql Script to query data in my shell program.
sqlplus -S /nolog @update.sql
but my script on function "sysdate" not work !!
Could you tel me,How can i use function "sysdate" on unix or can replace the other function in my script to get data in system date.
Ex. my pl update.sql
connect user/pass@server
begin
insert into table_X
select * from table_aaa m
where m.insert_date = to_date(sysdate,'dd/mm/yyyy');
commit;
update table_X set x_flag = 'complete'
where x.insert_date = to_date(sysdate,'dd/mm/yyyy');
commit;
end
/
exit
Hi,
What errormessage do you receive?
Are you working against an Oracle-database?
If its Oracle then you do not need the to_date function, sysdates return value is already datatype date.
Actually, the Unix date can be formatted and even passed as a parameter to an Oracle script.
$
$ cat -n fetch.sql
1 connect user/password@database
2 set verify off timing off
3 select 'The date passed from Unix is ' || &1 as msg
4 from dual
5 /
6 exit
$
$
$ sqlplus -S /nolog @fetch.sql "DATE '`date '+%Y-%m-%d'`'"
MSG
--------------------------------------
The date passed from Unix is 21-OCT-11
1 row selected.
$
$
However, you must understand that this is the client's date, whereas Oracle's SYSDATE is the server's date. If the server is physically located in a place that has a different timezone than the client, then these two will not be the same.