Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> difficult query (returning into) ???
Hi,
I am developing a webpage using an Oracle 8i database and OCI calls and I want to minimise the number of queries to Oracle.
so....when I update a row in the database I want to use the 'returning into'
clause but now comes the challenge.
Question 1:
situation
user 1 retrieves a row (eg select field form table whereuniquekey= 1 and status = 10)
this will fail because user1 already updated that same row
In both update situations I want to give the user the new data (hence the
returning clause)
But because the second update returned '0 rows updated' the return fields
are empty!!!!.... so in my programme I now select the new data with an extra
select (remember I want to minimise the number of queries :-) )
so now the question : how to force Oracle to fill the return values with the current row data if an update fails?
Second question.....
when I update a row with a returning into clause I only seem to be able to
return fields from the table I update, but sometimes I want to join another
table.
eg:
data-table has two columns (key, field and status)
status-table has two columns (status and status_description)
something like this
update data-table
set data-table.field='value'
where data-table.key = uniquenumber
returning data-table.field, data-table.status,
status-table.status_description
into :var1, :var2, :var3
where status-table.status = data-table.status
So the status.description comes from the 'status-table'. That doesn't seem to work so now I need to do an extra query in the status table...
Nice mind-breakers for the weekend ?
Thanks for any information,
Roy
Received on Fri Nov 09 2001 - 03:38:47 CST
![]() |
![]() |