0

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

1 Answer 1

0

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).

Sign up to request clarification or add additional context in comments.

2 Comments

is this possible to duplicate record using my own code. I actually have 3 blocks of almost 250 fields of database not possible to create control block
I guess it is; when you write your own procedure, you're the "boss" and can do anything you want. Won't look pretty, though ... 250 fields is quite a lot to handle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.