Hi to All,
could Someone resolve this problem?
If I execute the following function I have the following ERROR
HERE IS THE ERROR MESSAGE:
Tanks in advance.
Gianni Pinna
could Someone resolve this problem?
If I execute the following function I have the following ERROR
Code:
do
$body$
declare
week_nr integer;
anno_nr integer;
stmt text;
begin
week_nr := 1;
anno_nr := extract(year from current_date);
--Nel Mentre che il valore settimana e' minore di 53 : 1)Esegui l'inserzione; 2) Aumenta di 1 il valore di settimana e
--riesegui l'inserzione. Quando sei arrivato a week=53 esci
--Per gli anni da quello attuale, a ritroso, sino al 2009 inserisci in una tabella(generata automaticamente) per
--ogni anno i dati della settimana . Vale per articoli, reparti, sottoreparti
for anno_nr in reverse anno_nr..2009 loop
for week_nr in 1..53 loop
stmt := 'insert into anno'||anno_nr::text||
' select fkid_reparto, SUM(totale), settimana '||
'from righe_scontrino '||
'where settimana = '||week_nr::text||
' and anno= '||anno_nr::text||
' GROUP BY fkid_reparto, settimana';
execute stmt;
week_nr := week_nr + 1;
end loop;
anno_nr := anno_nr -1;
week_nr := 1;
end loop;
end;
$body$
HERE IS THE ERROR MESSAGE:
Code:
SQL ERROR: syntax errorat or near "do"
**********************Errore****************************
ERROR: syntax erro rat or near "do"
Stato SQL: 42601
Gianni Pinna