Home > Blockchain >  How to find the primary and foreign key of a form in APEX?
How to find the primary and foreign key of a form in APEX?

Time:10-22

I'm working on a weekly assignation system on APEX, and i have to use a form in order to submit the working hours of employees to a calendar. I'm using a Dynamic action in order to insert 365 entries for the table, instead of the submit button. The problem is that when i want to link my query to the form ID it's not working because it says the field is a null.

DECLARE
Start_work_date TIMESTAMP(6);
End_work_date TIMESTAMP(6);
Start_break_date TIMESTAMP(6);
End_break_date TIMESTAMP(6);
Day_name Varchar(20);

BEGIN
Start_work_date := :P2_START_WORK_TIME;
End_work_date := :P2_END_WORK_TIME;
Start_break_date := :P2_START_BREAK_TIME;
End_break_date := :P2_END_BREAK_TIME;

FOR I IN 1..365
LOOP
    INSERT INTO TS_SCHEDULE (USER_ID, START_WORK_TIME, END_WORK_TIME,START_BREAK_TIME,END_BREAK_TIME)
    VALUES (:P2_USER_ID, Start_work_date, End_work_date, Start_break_date, End_break_date);

Start_work_date := Start_work_date   interval '1' day;
End_work_date := End_work_date   interval '1' day;
Start_break_date := Start_break_date   interval '1' day;
End_break_date := End_break_date   interval '1' day;

select to_char(Start_work_date, 'DAY') into Day_name from dual;

IF Day_name = 'SATURDAY' THEN
Start_work_date := Start_work_date   interval '2' day;
End_work_date := End_work_date   interval '2' day;
Start_break_date := Start_break_date   interval '2' day;
End_break_date := End_break_date   interval '2' day;
END IF;
END LOOP;
END;

After i get all the input, i try to use :P2_USER_ID for the insert, but it say's it's a null value

How can i get the value that i'm looking for in order to have my custom inserts?

CodePudding user response:

If you're using a dynamic action, then you should be able to supply the item in the 'Page items to submit' parameter.

Alternatively, you could try changing the item 'Maintain Session State' property to 'Per Session (Disk)'

item source properties

Though I'm trying this on a PK in my form and there's still no value in session state, as opposed to the non-pk items I have in my form with that setting.

CodePudding user response:

This is where it fails, right?

INSERT INTO TS_SCHEDULE (USER_ID, START_WORK_TIME, ...)
VALUES (:P2_USER_ID, Start_work_date, ...);
        -----------

As it is dynamic action you're using, did you put P2_USER_ID into dynamic action's Items to submit property? If not, I'd suggest you to do so.

  • Related