Executer un script sql à partir d'un script shell
j'essaie de lancer un script sql à partir d'un script shell.
Je rentre en argument le nom de la table "nom_table":
voici le contenu du script shell (essai.sh) que j'utilise:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| #!/usr/bin/csh
sqlplus bb/bb <<EOF
set wrap off
set echo off
set feedback off
set heading on
set verify off
spool /var/test/fich.log
start script_t.sql $1
spool off
exit
EOF |
voici également, un extrait du "script script_t.sql":
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| set pagesize 50000
set linesize 2700
set wrap off
set echo off
set feedback off
set heading on
set verify off
set colsep ';'
set numwidth 19
column MSC_ID noprint
column PERIOD_START_TIME_h format a17
column PERIOD_START_TIME noprint
column PERIOD_DURATION heading "DURATION"
col sysd noprint new_value sysd
select to_char(sysdate-1, 'dd.mm.yyyy') sysd from dual;
spool /var/test/test_&sysd..txt;
select CO_NAME as NAME,
to_char(PERIOD_START_TIME,'dd.mm.yyyy hh24:mi') as PERIOD_START_TIME_h,
$1.* from $1,
utp_mo
where $1.MSC_ID=utp_mo.CO_GID
and to_char(PERIOD_START_TIME,'dd.mm.yyyy hh24:mi')>=to_char(sysdate-1,'dd.mm.yyyy') ||' 00:00'
order by PERIOD_START_TIME;
spool off; |
pour executer mon script shell: je lance
sh essai.sh nom_table
sauf qu'il plante lorsque le $1 est remplacé par nom_table à la ligne $1.* dans le script sql. Alors que lorsque nom_table est rentré en dure dans le script sql, cela fonctionne.
Quelqu'un pourrait m'aider à debugger ce pb ?
Merci