EXECUTE IMMEDIATE pas exécuté immédiatement
Cela fait quelque temps que je me pose une question par rapport à un fait que j' ai constaté.
Prenons le code suivant:
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
|
declare
i number;
begin
select count(*)
into i
from user_tables
where table_name = 'RATE_RC_BKP';
if i=0
then
execute immediate
'create table rate_rc_bkp as '||
'select * from rate_rc '||
'where active_date = ''01/01/2075'' '||
'and rate_class > 30705 '||
'and class_of_service_code between 3321 and 3332';
update rate_rc_bkp
set active_date = '01/01/1975';
delete rate_rc
where active_date = '01/01/2075'
and rate_class>30705
and class_of_service_code between 3321 and 3332;
commit;
end if;
end;
/ |
Si je l'exécute dans un .sql sous Unix il me renvoie l'erreur suivante:
la table Rate_rc_bkp n'existe pas...
pour que çà marche, il faut que j'utilise ce code ci:
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
|
declare
i number;
begin
select count(*)
into i
from user_tables
where table_name = 'RATE_RC_BKP';
if i=0
then
execute immediate
'create table rate_rc_bkp as '||
'select * from rate_rc '||
'where active_date = ''01/01/2075'' '||
'and rate_class > 30705 '||
'and class_of_service_code between 3321 and 3332';
end if;
end;
/
update rate_rc_bkp
set active_date = '01/01/1975';
delete rate_rc
where active_date = '01/01/2075'
and rate_class>30705
and class_of_service_code between 3321 and 3332;
commit;
/ |
Et là plus de soucis de table inexistante.
Pourquoi donc ce EXECUTE IMMEDIATE n'est il pas pris en compte immédiatement???
Pour info je suis en 9.2 et Oracle est instrallé sur Solaris 2.6