Skip to Content
-2

How to Insert Value toFUNCTION'S TABLE

Mar 05 at 09:05 AM

15

avatar image

Hello;

My functions is here ;

CREATE FUNCTION "HS_getMaasHesapla"(EmpId INT,MaasTuru VARCHAR(1),Donem VARCHAR(50),SablonCode VARCHAR(50),
       Maas DECIMAL(18,6),Brut DECIMAL(18,6),Pek DECIMAL(18,6),NetEkKazanc DECIMAL(18,6),BrutEkKazanc DECIMAL(18,6), 
       EkKesinti DECIMAL(18,6),DvrGvMatrah DECIMAL(18,6),SonBrutMaas DECIMAL(18,6),HesaplananMatrah DECIMAL(18,6),
       IzinTutar DECIMAL(18,6),MesaiTutar DECIMAL(18,6),Agi DECIMAL(18,6),IsBes VARCHAR(1),IsIcra VARCHAR(1),
       donembasi DATE,donemsonu DATE)


RETURNS  TABLE
(
    EmpId INT, GVMatrah DECIMAL(18,6),Brut DECIMAL(18,6),SGKIsv DECIMAL(18,6),IszCal DECIMAL(18,6),
    IszIsv DECIMAL(18,6),SGKCal decimal(18,6),GV decimal(18,6),DV decimal(18,6),Net decimal(18,6),
    EkKazanc decimal(18,6),Pek decimal(18,6),IzinTutar decimal(18,6),Bes decimal(18,6),Icra decimal(18,6),
    Odenen decimal(18,6),Maliyet decimal(18,6),EkKesinti decimal(18,6),Mesai decimal(18,6)
    ,IcraOran decimal(18,6),DosyaNumarasi varchar(50)
)
LANGUAGE SQLSCRIPT
SQL SECURITY DEFINER AS
BEGIN
DV := "HS_DVTutar"(:Brut, :donembasi, :donemsonu);
IF (:MaasTuru = 'B') THEN Net := (:Brut) - :SGKCal - :IszCal - :GV - :DV;
EkKazanc := :BrutEkKazanc;
Pek := :Brut + :Pek;
ELSE Net := (:Brut) - :SGKCal - :IszCal - :GV - :DV;
EkKazanc := :BrutEkKazanc + :NetEkKazanc;
Pek := :Brut;
END IF;
Net := round(:Net, 2);
IF (:Icra > 0) THEN Icra := (:Net * :IcraOran) / 100.00;
END IF;
Odenen := :Net + :Agi - :Icra - :Bes - :EkKesinti;
Maliyet := :Brut + :SGKIsv + :IszIsv;
INSERT INTO TABLE("EmpId" , "GVMatrah", "Brut", "SGKIsv", "IszCal", "IszIsv", "SGKCal", "GV", "DV", "Net", "EkKazanc", "Pek", "IzinTutar", "Bes", "Icra", "Odenen", "Maliyet", "EkKesinti", "Mesai", "IcraOran", "DosyaNumarasi") VALUES (round("GvMatrah", 2), round(:Brut, 2), round(:SGKIsv, 2), round(:IszCal, 2), round(:IszIsv, 2), round(:SGKCal, 2), round(:GV, 2), round(:DV, 2), round(:Net, 2), round(:EkKazanc, 2), round(:Pek, 2), round(:IzinTutar, 2), round(:Bes, 2), round(:Icra, 2), round(:Odenen, 2), round(:Maliyet, 2), round(:EkKesinti, 2), round(:MesaiTutar, 2), round(:IcraOran, 2), round(:DosyaNumarasi, 2));
RETURN;
END;

But error is here:

Could not find table/view TABLE in schema SBODEMOTR: line 79 col 13 (at pos 3861)

On the other hand I can not use Select

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Lars Breddemann
Mar 05 at 09:42 AM
0

User defined functions are read-only constructs (as documented).

Maybe, if you describe what you want to achieve, we can recommend an alternative approach.

Share
10 |10000 characters needed characters left characters exceeded