Home » SQL & PL/SQL » SQL & PL/SQL » Conditional copmilation question (11G /WINDOWS 7)
Conditional copmilation question [message #575108] Sat, 19 January 2013 10:50 Go to next message
one973
Messages: 7
Registered: January 2013
Junior Member
hi all,
has any one tried to use conditional complilation with plsql_code_type?
i have tried to do the following but i got errors , where is my mistake if you have an idea?
CREATE OR REPLACE PROCEDURE PROC1
AS
BEGIN
$IF $$plslql_code_type = INTERPRETED $THEN
DBMS_OUTPUT.PUT_LINE('INTERPRETED');
$END
NULL;
END;
/
Warning: Procedure created with compilation errors.

SQL> SHOW ERRORS
Errors for PROCEDURE PROC1:

LINE/COL ERROR
-------- -----------------------------------------------------------------
3/37 PL/SQL: Statement ignored
4/5 PLS-00174: a static boolean expression must be used
4/25 PLS-00201: identifier 'INTERPRETED' must be declared
SQL>

[Updated on: Sat, 19 January 2013 10:59]

Report message to a moderator

Re: Conditional copmilation question [message #575109 is a reply to message #575108] Sat, 19 January 2013 10:56 Go to previous messageGo to next message
Michel Cadot
Messages: 58605
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Maybe plsql_code_type not pslql_code_type.

Regards
Michel
Re: Conditional copmilation question [message #575110 is a reply to message #575108] Sat, 19 January 2013 10:57 Go to previous messageGo to next message
Michel Cadot
Messages: 58605
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Also, Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" or "Preview Quick Reply" button to verify.

Use SQL*Plus and copy and paste your session, the WHOLE session.

And FEEDBACK to those that help you.
I am still waiting for you in your previous topic.

Regards
Michel
Re: Conditional copmilation question [message #575114 is a reply to message #575110] Sat, 19 January 2013 11:43 Go to previous messageGo to next message
one973
Messages: 7
Registered: January 2013
Junior Member
thank you michel for cooperation and for your efforts, it is the same even when i wrote it plsql_code_type , it was mistake writing the code,

Re: Conditional copmilation question [message #575116 is a reply to message #575114] Sat, 19 January 2013 11:59 Go to previous messageGo to next message
Michel Cadot
Messages: 58605
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is why I said: "Use SQL*Plus and copy and paste your session, the WHOLE session.".
So do it.

Regards
Michel
Re: Conditional copmilation question [message #575117 is a reply to message #575116] Sat, 19 January 2013 12:03 Go to previous messageGo to next message
Michel Cadot
Messages: 58605
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Is $$plsql_code_type a valid precompiler variable?
Where did you see it exists?

Regards
Michel
Re: Conditional copmilation question [message #575119 is a reply to message #575117] Sat, 19 January 2013 12:18 Go to previous messageGo to next message
BlackSwan
Messages: 22515
Registered: January 2009
Senior Member
http://www.orafaq.com/node/953
http://www.oracle.com/technetwork/database/features/plsql/overview/plsql-conditional-compilation-133587.pdf
Re: Conditional copmilation question [message #575124 is a reply to message #575108] Sat, 19 January 2013 14:04 Go to previous messageGo to next message
Solomon Yakobson
Messages: 1962
Registered: January 2010
Senior Member
INTERPRETED must be enclosed in quotes - it is a string literal. But it will not do you any good. You'll get:

SQL> CREATE OR REPLACE PROCEDURE PROC1
  2   AS
  3   BEGIN
  4   $IF $$plsql_code_type = 'INTERPRETED' $THEN
  5   DBMS_OUTPUT.PUT_LINE('INTERPRETED');
  6   $END
  7   NULL;
  8   END;
  9  /

Warning: Procedure created with compilation errors.

SQL> show err
Errors for PROCEDURE PROC1:

LINE/COL ERROR
-------- -----------------------------------------------------------
4/6      PLS-00174: a static boolean expression must be used
SQL>


String literals may not appear in $IF directive. So all you can do is something like:

SQL> CREATE OR REPLACE PROCEDURE PROC1
  2   AS
  3   BEGIN
  4   IF $$plsql_code_type = 'INTERPRETED' THEN
  5   DBMS_OUTPUT.PUT_LINE('INTERPRETED');
  6   END IF;
  7   NULL;
  8   END;
  9  /

Procedure created.

SQL> exec proc1;
INTERPRETED

PL/SQL procedure successfully completed.

SQL> alter session set plsql_code_type = 'native';

Session altered.

SQL> exec proc1;
INTERPRETED

PL/SQL procedure successfully completed.

SQL> alter procedure proc1 compile;

Procedure altered.

SQL> exec proc1;

PL/SQL procedure successfully completed.

SQL>


SY.

[Updated on: Sat, 19 January 2013 14:08]

Report message to a moderator

Re: Conditional copmilation question [message #575126 is a reply to message #575124] Sat, 19 January 2013 14:55 Go to previous message
one973
Messages: 7
Registered: January 2013
Junior Member
@michel
Check page 143 4th line from down up
thank you all,


[EDITED by LF: Whoa! You can't attach copyrighted materials to your messages. Therefore, I deleted "Oracle PL/SQL Language Pocket Reference" PDF from your message. You can, though, describe what you learnt from studying that book]

[Updated on: Sun, 20 January 2013 12:23] by Moderator

Report message to a moderator

Previous Topic: QUERYING SESSION PARAMETERS THAT I CHANGED [merged 4 by jd]
Next Topic: Update table with join
Goto Forum:
  


Current Time: Mon Jul 28 14:05:31 CDT 2014

Total time taken to generate the page: 0.10190 seconds