tags:

views:

55

answers:

3

I would like to ask if anybody has any knows how to use the OPTION keyword.

I have encountered this on an old C source code that I have been reading.

OPTION SELECT ROWID
FROM TABLE_1
WHERE PRODUCT_CODE = ANY(SELECT PRODUCT_CODE FROM PRODUCT_TABLE WHERE PRODUCT_GROUP='value a')
FOR UPDATE NOWAIT;
SELECT ROWID
FROM TABLE_2
WHERE PRODUCT_CODE = 'value b'
FOR UPDATE NOWAIT;
UPDATE TABLE_3
SET ...
WHERE PRODUCT_CD = 'value b'

*Updated Query based on first comment. Basically the C code made an SQL statement with 3 sql statement. Then got a result from it. I was wondering what would the oracle return if you give two statement. Which select statement result would it return? or would it just return the second one because the first one was specified with OPTION keyword?

+2  A: 

Can you post any more of your code? OPTION is a reserved word so it can't be redefined.

It is typically used for operations such as:

GRANT CREATE INDEX TO user WITH ADMIN OPTION;
Colin Pickard
So you mean that the OPTION word is not relevant to any query? It is just an admin priviledge change tool? I modified the question and expanded the query.
Nassign
You've got a semi-colon after the first `select...` so I think the `OPTION` keyword would only work on that block. 11g just gives me an 'Invalid SQL Statement'. I can only assume `OPTION` must be a Pro*C keyword. Can you try tracing your session and seeing what SQL is actually being sent?
Colin Pickard
+2  A: 

Book "Oracle Database SQL Language Reference" contains the keyword "OPTION". http://download.oracle.com/docs/cd/B28359_01/network.111/b28531/authorization.htm#sthref821

dba.in.ua
+2  A: 

As an Oracle keyword that doesn't seem to make sense there. If this is a Pro*C file, is there a macro defined somewhere that sets OPTION to something like exec sql, or since this looks like it could be a cursor, exec sql declare something cursor for? Though the latter would make the cursor name fixed to something so you could only use it once per file; perhaps this is shorthand for declaring a cursor called option...

Seeing more code around this would be helpful though.

Alex Poole
I'm pretty sure you can't create a cursor called OPTION - due to it being reserved word.
Colin Pickard
True. I don't think there's anything stopping you having a macro with that name though. Doesn't seem like a good idea, if that is the case.
Alex Poole