firebird 2.1.3
Ciao a tutti,
ho questo problemuccio che mi sta mettendo a tappeto da oltre 10giorni!
all'origine doveva essere una Stored Procedure ricorsiva, che ho ridotto ad una stored procedure che effettua 4/5 volte lo stesso tipo di ricerca.
il problema è che non riesco ad ottenere il risultato che ''dovrei''. mi spiego:
la stored che attinge dati da 1 sola tabella,
se la eseguo con il debug ottengo (correttamente) un risultato di 9 righe,
se invece la eseguo normalmente ottengo (erroneamente) un risultato di 7 righe.
![]()
![]()
![]()
![]()
per eseguire la stored in modalità debug ho scaricato la versione free di EMS sql firebird...
non so dove sbaglio e non so se sbaglio.... e non capisco perchè la stessa stored restituisce un dataresoult diverso.
spero in Voi!![]()
grazie
questa è la mia tabella:
codice:CREATE TABLE DISTINTABASE ( ID INTEGER NOT NULL, IDARTICOLO INTEGER NOT NULL, IDARTICOLODISTINTA INTEGER NOT NULL);
questi i dati
codice:INSERT INTO DISTINTABASE (ID, IDARTICOLO, IDARTICOLODISTINTA) VALUES (9906, 4, 3); INSERT INTO DISTINTABASE (ID, IDARTICOLO, IDARTICOLODISTINTA) VALUES (6, 4, 2); INSERT INTO DISTINTABASE (ID, IDARTICOLO, IDARTICOLODISTINTA) VALUES (4, 4, 1); INSERT INTO DISTINTABASE (ID, IDARTICOLO, IDARTICOLODISTINTA) VALUES (9908, 1, 6); INSERT INTO DISTINTABASE (ID, IDARTICOLO, IDARTICOLODISTINTA) VALUES (7, 2, 3); INSERT INTO DISTINTABASE (ID, IDARTICOLO, IDARTICOLODISTINTA) VALUES (9909, 1, 7); INSERT INTO DISTINTABASE (ID, IDARTICOLO, IDARTICOLODISTINTA) VALUES (12, 3, 6); INSERT INTO DISTINTABASE (ID, IDARTICOLO, IDARTICOLODISTINTA) VALUES (9901, 1, 2); INSERT INTO DISTINTABASE (ID, IDARTICOLO, IDARTICOLODISTINTA) VALUES (9902, 1, 3); INSERT INTO DISTINTABASE (ID, IDARTICOLO, IDARTICOLODISTINTA) VALUES (19, 3, 5);
questa la stored procedure:
codice:CREATE PROCEDURE ARTICOLIFIGLI ( idpadrein integer, idarticoloin integer) returns ( out_id integer, out_idarticolopadre integer, out_idpadre integer, out_idarticolo integer) as begin /* Procedure Text */ for select :idpadrein, distintabase.idarticolo, distintabase.idarticolodistinta from distintabase where distintabase.idarticolo=:idarticoloin into out_idpadre, out_idarticolopadre, out_idarticolo do begin if (out_id is null) then out_id=1; else out_id=out_id+1; suspend; for select :out_id, distintabase.idarticolo, distintabase.idarticolodistinta from distintabase where distintabase.idarticolo=:out_idarticolo into out_idpadre, out_idarticolopadre, out_idarticolo do begin if (out_id is null) then out_id=1; else out_id=out_id+1; suspend; for select :out_id, distintabase.idarticolo, distintabase.idarticolodistinta from distintabase where distintabase.idarticolo=:out_idarticolo into out_idpadre, out_idarticolopadre, out_idarticolo do begin if (out_id is null) then out_id=1; else out_id=out_id+1; suspend; for select :out_id, distintabase.idarticolodistinta from distintabase where distintabase.idarticolo=:out_idarticolo order by distintabase.idarticolodistinta into out_idpadre, out_idarticolo do begin if (out_id is null) then out_id=1; else out_id=out_id+1; suspend; end end end end end

Rispondi quotando