Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: For update issues in subquery

Re: For update issues in subquery

From: Nigel Thomas <nigel_cl_thomas_at_yahoo.com>
Date: Wed, 14 Feb 2007 14:26:26 -0800 (PST)
Message-ID: <271081.92888.qm@web58710.mail.re1.yahoo.com>


Harvinder asked: >>Is there any way we can use the for update clause in subquery? No. Look at the syntax diagrams here: http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_103a.htm select ::= subquery [for_update_clause]; and then all the remaining goodness - NOT including for update - is under the definition of subquery subquery ::= [ subquery_factoring_clause ] SELECT [ hint ] [ { DISTINCT | UNIQUE } | ALL ] select_list FROM table_reference [, table_reference]... [ where_clause ] [ hierarchical_query_clause ] [ group_by_clause ] [ HAVING condition ] [ { UNION | UNION ALL | INTERSECT | MINUS } ( subquery )] [ order_by_clause ] And anyway, you wouldn't want to have Oracle potentially lock all the rows in your subquery, and then only select the first few by rownum? I guess that must just be a simple example. Why do you need to select for update? Any rows you update will become locked anyway; do you have a timing issue? What's the real issue you are trying to solve? For the nitpickers, I think the BNF is inaccurate; you can also have brackets around even a single simple subquery; this BNF incorrectly states that the brackets can only be (and MUST be) around the second subquery in a compound query. This next statement (((((((((((((select 1 from dual))))))))))))) for update is a perfectly valid query (try it)... HTH Regards Nigel

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Feb 14 2007 - 16:26:26 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US