|
Home > Archive > Unix Shell > September 2006 > script sh and sql query
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
script sh and sql query
|
|
|
| Hello,
i'm tring to execute a query in a sh script:
query_data_ieri=$((echo "select to_char((sysdate), 'DD/MM/YYYY') from
dual;" | sqlplus -S dsi_dpipe/dsi_dpipe@ovpi)|cut -c 23-32 )
now if i print query_date with echo $quey_date i obtain this result:
query_date=
i have to obtain query_date in this format: 20/09/2006
thanks
| |
| Radoulov, Dimitre 2006-09-20, 7:34 am |
| > i'm tring to execute a query in a sh script:
> query_data_ieri=$((echo "select to_char((sysdate), 'DD/MM/YYYY') from
> dual;" | sqlplus -S dsi_dpipe/dsi_dpipe@ovpi)|cut -c 23-32 )
>
> now if i print query_date with echo $quey_date i obtain this result:
>
> query_date=
>
>
> i have to obtain query_date in this format: 20/09/2006
"sysdate" is the OS date so you can do it directly in shell:
$ date '+%d/%m/%Y'
20/09/2006
For yesterday date you can find a solution in the group archive.
Regards
Dimitre
P.S. If you really need to use the OS date from within the database:
$ query_data_ieri=$(printf "set pages 0 feed off\n select to_char((sysdate),
'DD/MM/YYYY') from dual;\n" | sqlplus -S dsi_dpipe/dsi_dpipe@ovpi) && echo
$query_data_ieri
20/09/2006
| |
|
|
Radoulov, Dimitre ha scritto:
> P.S. If you really need to use the OS date from within the database:
>
> $ query_data_ieri=$(printf "set pages 0 feed off\n select to_char((sysdate),
> 'DD/MM/YYYY') from dual;\n" | sqlplus -S dsi_dpipe/dsi_dpipe@ovpi) && echo
> $query_data_ieri
> 20/09/2006
thank you this resolved my issue :D
|
|
|
|
|