Bonjour,

Mon probleme n'est pas tres simple à expliquer. Avec un script sql, je génère un autre script sql via un spool. C'est ce nouveau fichier qui contient la requete récuperant les infos dont j'ai besoin.

Voici mon 1er script:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 echo off ver off feed off pages 0
--set linesize 200
set termout off
set feedback off
set trimout off 
set heading off 
set sqlprompt ' '
set verify off
set space 0 
SET NEWPAGE none
SET PAGESIZE 0 
set trimspool on
spool &2
 
select 'set echo off ver off feed off pages 0 pagesize 0 termout off feedback off
spool &3 ' from dual union all
select 'select ' from dual union all
select * from (select decode(column_id,maxid,column_name,column_name||'|| ''|'' ||') from user_tab_columns a,(select max(column_id) maxid,table_name  from user_tab_columns where tabl
e_name='PRRT' group by table_name) b where a.table_name =b.table_name order by column_id) union all
select ' from PRRT where prrt_dateacnt=&1 and prrt_stus=7
and prrt_methpaym IN (4, 20, 21, 22)  ' from dual union all select 'union ' from dual union all
select 'select ' from dual union all
select * from (select decode(column_id,maxid,column_name,column_name||'|| ''|'' ||') from user_tab_columns a,(select max(column_id) maxid,table_name  from user_tab_columns where tabl
e_name='PRRT' group by table_name) b where a.table_name =b.table_name order by column_id) union all
select ' from PRRT, APIS_PRRT_RPT where prrt_dateacnt=&1 and prrt_stus=7
and prrt_methpaym NOT IN (4, 20, 21, 22) and prrt_oprf=reference ;' from dual;
select ' spool off
exit; ' from dual;
spool off
exit;
En sortie j'obtiens un truc de ce genre:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
select 
a || '|' ||
b|| '|' || 
.....
c|| '|' || 
d
where prrt_dateacnt=20070525 and prrt_stus=7
and prrt_methpaym IN (4, 20, 21, 22)
 
union
select 
a || '|' ||
b|| '|' || 
.....
c|| '|' || 
d
from PRRT, APIS_PRRT_RPT where prrt_dateacnt=20070525  and prrt_stus=7
and prrt_methpaym NOT IN (4, 20, 21, 22) and prrt_oprf=reference ;
spool off
exit;
Voila le message d'erreur que j'obtiens:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
SP2-0042: unknown command "union" - rest of line ignored.
Si je supprime le saut de ligne à la main entre la fin de la 1ere requete et le "union" ca fonctionne.
Donc ma question est Comment supprimer ce saut de ligne et pourquoi est ce qu'il est là?

Merci