I have a database table Land with colums:
serial, seller_name, sell_date, sell_price
I am using a datablock named land. To update the table I am using the same datablocks field. I am using a lov to take the already saved values and I am dropping those values in the datablock land.
I want to update the values based on the serial number. I am using on button pressed trigger under a button and used the commit_form. But every time new data is inserted with the same serial number. I am looking for a way to update the table for that specific serial number.
To load the right row into the data block, you have to do the following in your trigger:
enter_query(no_validate);
:serial := your_lov.whatever;
execute_query;
This will connect the datablock with the correct row, instead of overwriting another row.
Related
I Have populated master detail block from Data based want to change some values in data block and save it as a new record in Both master and child tables.
To Populate used execute query
Changed values as record
Save by commit
But as i used execute query to populate existing data on commit it is trying to update already saved data in table. But i want to create new records in DB with new primary key
That won't work, as you noticed. Records you fetched are database records so - once you update their values and commit, you overwrite data.
If you want to insert new records, then
add them into new rows - you can do that manually (by typing those values), or
you can duplicate one of previous records into a new record (use Forms menu for that or a shortcut key; look for "duplicate record" option) and modify that duplicated record.
Alternatively, don't use data block but control block (the one that isn't based on a database table). Populate it, somehow (e.g. you could create a button which calls the procedure; it uses a loop and populates record-by-record). Modify values you want and create your own procedure which will insert new rows into the database table. As of the primary key, it depends on how you do it; if it is a database trigger which uses a sequence, it (the trigger) will do the job. Otherwise, you'll have to create a primary key yourself (during the insert process).
Hi any one can help me on this issue which i have problem insert a dynamic value which is from previous database table value to pass to another table in Katalon.
Please find my information below:-
This screenshot is ab.dbo.DOCUMENT table which DOCUMENT_ID is auto populate with value
which mean it will appear random number by itself.
Another screenshot is bc.dbo.DOCUMENT_IC table which i need to manually key in DOCUMENT_ID in
the value base on on what it is given from ab.dbo.DOCUMENT table DOCUMENT_ID.
Attached of a screenshot for bc.dbo.DOCUMENT_IC
In Katalon i am using a keyword to connect my database, insert query and close
connection. I am aware of this step and able to connect to database with katalon. But i
am not very sure how to pass a dynamic value from ab.dbo.DOCUMENT table DOCUMENT_ID which
it can randomly appear a number value to bc.dbo.DOCUMENT_IC table DOCUMENT_ID which i need to
manually key in a value base on the value given.
Below is my Katalon script:-
Hopefully someone can help me on this
Thank you.
If I have a table with an auto incrementing ID in one table and I need that value elsewhere I would typically write sql like this :
insert into firsttable (Document_Type) values ('PDF');
insert into secondtable (Document_ID, App_ref_Num) values (##Identity, 'somenumber')
In the databases I have worked with ##Identity will give you the integer or id of the last inserted row. If you can't run multiple statements most connection libraries will have something like a $conn->insert_id that will do the same thing as running select ##identity.
I am trying to generate a unique ID on Oracle Apex Forms field while Enter/Tab button is pressed like we do in Oracle Forms using the Key-Next-Item And Post-Change triggers on a field.
This is not Forms, this is Apex.
Basically, you shouldn't allow users to modify such an item (keep it hidden or display only).
In Apex, we usually create a process which sets the primary key item's value, such as
:P1_PK_ITEM := NVL(:P1_PK_ITEM, sequence_name.nextval);
Or, set that item's default value to fetch sequence's next value.
Or, create a database trigger which will populate column value before insert.
Or, if your database version is high enough (12c and later), create an identity column.
I have one field on my form (field example name "completion_date"). This data is stored to table column "completion_date". When users edits the detail, data is overwritten in the backend table field as a default way of storing the data. How can I pass on the existing data in this column to a new column (completion_date_a) when the user saves a new date in the field.
One option is to create a database trigger, e.g.
create or replace trigger trg_bu_date
before update on your_table
for each row
begin
:new.completion_date_a := :old.completion_date;
end;
/
Littlefoots' answer is correct, but you could also do this in apex with very little work. Suppose your form items are P1_COMPLETION_DATE and P1_COMPLETION_DATE_A, both mapped to their respective database column. P1_COMPLETION_DATE_A is hidden. Add a computation to P1_COMPLETION_DATE_A with point "After Header" and type "Item". Pick P1_COMPLETION_DATE as item.
Now when you save the form, the value of P1_COMPLETION_DATE_A will be set to the value of P1_COMPLETION_DATE when it was selected.
I have a Form, and I create a trigger pre-insert in the data block
select Investor_Seq.nextval into :INVESTOR.INVESTOR_NUMBER from dual;
all the data is valid,
I only use two trigger, PRE-INSERT AND WHEN BUTTON IS PRESS
press save button:
FRM-40508 Unable to insert the record
i am using the save button the trigger WHEN BUTTON IS PRESS:
commit_FORM;
it seem the PRE-INSERT statment error? but the new Investor number is show up on the text item.
ORA-01400: cannot insert NULL into ("ORCL5_10"."INVESTOR"."INVESTOR_NUMBER")
SQL statment ERROR
INSERT INTO INVESTOR (FIRST_NAME,LAST_NAME,STREET_ADDRESS,CITY,PROVINCE,POSTAL_CODE,
AREA_CODE,PHONE_NUMBER,EMAIL_ADDRESS,ACCOUNT_NUMBER)
VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10)
If you check the column list of the INSERT statement, you'll see that investor_number isn't among those columns.
It means that - although PRE-INSERT trigger fetched the next sequence value into a field on the screen, it is not part of that table. I guess that its database column property isn't correctly set, i.e. that form field doesn't belong to the investor table.
Should be easy to fix; inspect :investor.investor_number field's property palette and map it to the table column.