Chris M.
Chris M.

Reputation: 5

PLSQL form insert error, can someone help me? I have no clue

I have this code where I want to add some inserted values, sum them and insert in a specific column. But I am getting an error after an error. And I think this is the final one, but I have no clue. Good someone help me out? Added a screenshot with more information.

My code:

DECLARE 
BEGIN   
INSERT INTO thuiswerk_declaratie    (MNR, WNR, UREN_GEWERKT, TOTAAL_BEDRAG)
                
VALUES                  (:P8_MNR, 
                         :P8_WNR, 
                         :P8_TOTAAL_AANTAL_UREN (:P8_MAANDAG_UREN +
                                              :P8_DINSDAG_UREN +
                                              :P8_WOENSDAG_UREN +
                                              :P8_DONDERDAG_UREN + 
                                              :P8_VRIJDAG_UREN), 
                         :P8_TOTAAL_BEDRAG (:P8_TOTAAL_AANTAL_UREN * 0.2)
                    );
END;

Printscreen of code and error

Upvotes: 0

Views: 52

Answers (1)

Koen Lostrie
Koen Lostrie

Reputation: 18705

what is " :P8_TOTAAL_AANTAL_UREN" and ":P8_TOTAAL_BEDRAG" ? They are bind variables in apex, so they contain a string (not a function name) However, looking at your code, it seems you are trying to reference a function in a bind variable which will give that error you see. Most probably this is just a syntax error, you could give this a try:

DECLARE 
BEGIN   
INSERT INTO thuiswerk_declaratie    (MNR, WNR, UREN_GEWERKT, TOTAAL_BEDRAG)
                
VALUES                  (:P8_MNR, 
                         :P8_WNR, 
                         :P8_MAANDAG_UREN + :P8_DINSDAG_UREN + :P8_WOENSDAG_UREN + :P8_DONDERDAG_UREN + :P8_VRIJDAG_UREN, 
                         :P8_TOTAAL_AANTAL_UREN * 0.2
                    );
END;

If you really want a function, then you could do one of the following: Note that these are more complex solutions.

Option 1:

You're using apex. Best practice to handle this is to create a computation that would calculate the page item for column UREN_GEWERKT and another one for for column TOTAAL_BEDRAG. Your pl/sql block would then be:

DECLARE 
BEGIN   
INSERT INTO thuiswerk_declaratie    (MNR, WNR, UREN_GEWERKT, TOTAAL_BEDRAG)
                
VALUES                  (:P8_MNR, 
                         :P8_WNR, 
                         :P8_TOTAAL_AANTAL_UREN, 
                         :P8_TOTAAL_BEDRAG 
                    );
END;

You could also use the build-in form region to do all the magic for you in this case.

Option 2:

Assuming you have (1) a pl/sql function total_hours that return a value of the same datatype as thuiswerk_declaratie.UREN_GEWERKT and takes 5 arguments (1 per day of the week and (2) another function total_amount that returns a value of the same datatype as thuiswerk_declaratie. TOTAAL_BEDRAG and takes 1 argument you could write your pl/sql block as:

DECLARE 
BEGIN   
INSERT INTO thuiswerk_declaratie    (MNR, WNR, UREN_GEWERKT, TOTAAL_BEDRAG)
                
VALUES                  (:P8_MNR, 
                         :P8_WNR, 
                         total_hours (:P8_MAANDAG_UREN +
                                              :P8_DINSDAG_UREN +
                                              :P8_WOENSDAG_UREN +
                                              :P8_DONDERDAG_UREN + 
                                              :P8_VRIJDAG_UREN), 
                         total_amount (:P8_TOTAAL_AANTAL_UREN * 0.2)
                    );
END;

Upvotes: 1

Related Questions