error in query [message #346943] |
Wed, 10 September 2008 02:44 |
waqasbhai
Messages: 118 Registered: August 2008 Location: Pakistan
|
Senior Member |
|
|
Guys look at the following code
DECLARE
TYPE AUTHOR_CUR IS REF CURSOR;
C1 AUTHOR_CUR;
R_C1 VARCHAR2(50);
QRY VARCHAR2(50);
BEGIN
QRY := 'SELECT DISTINCT Abc FROM table';
OPEN C1 FOR QRY;
FETCH C1 INTO R_C1;
IF C1%ISOPEN THEN
DBMS_OUTPUT.PUT_LINE('CURSOR OPEN');
END IF;
DBMS_OUTPUT.PUT_LINE(C1%ROWCOUNT);
CLOSE C1;
END;
This code works fine in the database procedure. But i want to use it at form level (FORMS 6i). When i use it in the form it gives an error:
ERROR 103: ENCOUNTERED THE SYMBOL "QRY" WHEN EXPECTING ONE OF THE FOLLOWING SELECT
Any solution for this??? or is there any alternate way to do it??? [EDITED by DJM: added [code] tags]
[Updated on: Wed, 10 September 2008 02:53] by Moderator Report message to a moderator
|
|
|
|
Re: error in query [message #346947 is a reply to message #346943] |
Wed, 10 September 2008 03:01 |
waqasbhai
Messages: 118 Registered: August 2008 Location: Pakistan
|
Senior Member |
|
|
Actually sir i want to make this query dynamic. I want to change the FROM clause at run time by taking the table name from the user.
I am gonna use the same idea at report as well.
Thats why i am doing it like this.
|
|
|
Re: error in query [message #346990 is a reply to message #346943] |
Wed, 10 September 2008 06:08 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Do you really need to do this?
Becuase this sort of dynamic sql is generally regarded as being a bad idea as:
a) It hurts performance.
b) It's a pain to maintain.
If you really do need to do it then I would suggest putting the dynamic sql in a procedure in the database and basing the block in the form on that.
Have a look in form builder help if you're not sure how to do this.
|
|
|
Re: error in query [message #346992 is a reply to message #346943] |
Wed, 10 September 2008 06:19 |
waqasbhai
Messages: 118 Registered: August 2008 Location: Pakistan
|
Senior Member |
|
|
Thanks
But i actually want it to use in report. If i make a database procedure then how will i call it from a report???
|
|
|
Re: error in query [message #346999 is a reply to message #346943] |
Wed, 10 September 2008 06:48 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
You can base oracle reports on procedures that return ref cursors.
Have a look in report builder help for details
|
|
|
|
|