0

I'm trying to Insert a double precision (ilosc_zlec) value into a table (M_ZAMWLASNEPOZ). First I use a select statement to get the value. After I run this part of code, I can see the correct value in the variable ( 39 ). Next I'm trying to insert the selected values in the table and most of them get inserted but field ILOSC with should become the value of ilosc_zlec shows NULL. Both ILOSC, ilosc_zlec are double precision variables.

for select t.strumet_katzw,a.kategoria,a.rok_zam,a.symbol_zam,a.indeks,a.nazwa,a.wyroznik,a.ilosc_zlec,a.lp_zam from m_zlecenia a
     left join  m_przewod_gl g
     on g.kat_zlec= a.kategoria and g.rok_zlec= a.rok_zam and g.symb_zlec= a.symbol_zam and g.lp_zlec= a.lp_zam
     left join  m_przewod_op p
     on p.kat_zlec= a.kategoria and p.rok_zlec= a.rok_zam and p.symb_zlec= a.symbol_zam and p.lp_zlec= a.lp_zam and p.nr_przew=g.nr_poz
     left join m_kot t
     on t.kod_oper= p.kod_oper
     where  a.wyroznik=:wyroznik and  a.grupa_zl= 'KOP' and  a.data_wykon is null and f_mid(p.kod_oper,1,4)='KOOD' and t.strumet_katzw is not null
     into: strumet_katzw,:kategoria, :rok_zam, :symbol_zam, :indeks, :nazwa, :wyroznik, :ilosc_zlec,:lp_zam
     do begin
       select symbol_zam from m_zamwlasne where kategoria=:strumet_katzw and F_MID(symbol_zam,1,8) = (:symbol_zam||f_mid(:indeks,5,3)) into: symb_szukan_nagl ;
    -- wypelniasz pozycje naglowka
      INSERT INTO M_ZAMWLASNEPOZ (KATEGORIA, ROK_ZAM, SYMBOL_ZAM, LP_ZAM, INDEKS, ILOSC, TERMIN, CENA_ZAM, POBRANO_IL, ZREALIZOWANO, DATA_ZM, OPER, KOD_KONTRO, ZAKUP_DLA, NA_PRZEWOD, IL_PO_KONTROLI, JM, ILOSC_ZAK, REL_JM_ZAK, NR_ZAPOTRZEB, DATA_POTW, OPIS_POZ2, OPIS_POZ, KOOP_WYROB, KOOP_WYROB_ILOSC, POBRANO_KOOP, SKAD_KOPIA, TYP_INDEKSU, SUMA_DOST, DATA_REALIZ, LP_OFERTY, KONTO_KOSZT, NA_NADRZ, PRZEDMIOT, RABAT, PR_RABAT, CENA_JEDN, LP_OPER, ILOSC_REJOP_KOOP, ROZLICZONE)
      VALUES (:strumet_katzw, :rok_zam, :symb_szukan_nagl, :lp_zam, :indeks, :ilosc_zlec, 'now', 0, 0, 'T', 'now', user, 'NN', NULL, NULL, 0, 'SZT', 0, 0, NULL, 'NOW', NULL, NULL, NULL, 0, 0, NULL, 'I', 0, 'NOW', 1, NULL, NULL, 'a', 0, 0, 0, NULL, NULL, NULL);
     suspend;
     end 
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Why not `insert into targettable select ... from s1 join s2 ...`? – jarlh Feb 11 '20 at 09:05
  • Please provide a [mre]. Provide a minimal table with sample data, and a minimized stored procedure (or execute block) to reproduce the problem. As it stands we cannot execute your code and reproduce it, and there are too many fields and variables to make an educated guess. As an added bonus, creating such a [mre] might help you find the problem yourself. – Mark Rotteveel Feb 11 '20 at 14:06
  • 1
    Can you verify if there are any BEFORE INSERT triggers on that TABLE that would update the ILOSC field back to a NULL? – Ed Mendez Feb 11 '20 at 18:31
  • I have doubts what we see is the real code of the application, rather than some doctored extract, somewhat similar to the real code: `into: strumet_katzw` – Arioch 'The Feb 12 '20 at 08:17
  • Hi guys, The problem was a trigger that I didn't know about on the table that I was trying to insert the data in. Thanks for the help. – Oliver Sznapka Feb 12 '20 at 11:14

0 Answers0