Apex page process - update two tables
944332Jun 18 2012 — edited Jun 18 2012Okay, I know there are tons of similar topics - I've already been through about 500, and while I figured out how to do it, I still can't get it working, so~
I'm learning Oracle Apex on my own, so it's a bit tricky to figure things out...
I've got two tables - People - with info about their names, hometowns (fk to Towns' town(PK), etc - PK for it is people_id; and Towns - name of town (pk), location of town, population of town.
I've made links in my report so that when you click on the Hometown it gets you to the row about that town with the info about it from Towns.
For the Towns' report I've got a form with editing and making new entries, but when I try to edit a given town's name, the PK, it gives me an error about the FK in People - normal.
So I want to be able to edit the town's name, and get the change in People as well - I can do it with triggers, but I can't figure out how to make it with processes.
So table
People
P_ID | Name | etc. | Homeown(FK)
Towns
Town(PK) | location | etc
I've tried to create a page Process -> Pl/sql, that's on the page with the form for Towns, but then what I write is most probably wrong
begin
update people
set hometown = :p_town;
end;
which to be triggered by the Apply Changes bit, but it gives me the mistake for the FK, again.
So, I'm either not setting something write inside the process bit and the button bit, that I cannot figure out, or... the code is wrong...
It IS wrong I know, as there is no WHERE clause, which also confuses me... how can I figure out how to find that exact people with that exact old hometown in people?
if it was a trigger I'd have it
begin
update "people" p
set p.hometown = :new.town where p.hometown = :old.town;
end;
and it works... but... there is no new/old :p_towns, right?
Help?