Home » SQL & PL/SQL » SQL & PL/SQL » PLS-00103 (Oracle, 10g,Windows Server 2003)
PLS-00103 [message #449824] Thu, 01 April 2010 03:56 Go to next message
getritesh
Messages: 235
Registered: July 2006
Location: INDIA
Senior Member

Hi,

I executed the following procedure and got error

SQL> Create Or Replace Procedure proc Is
  2  v_rec_cnt  Number := 0;
  3  g_cur_count   sys_refcursor;
  4  v_query1  Varchar2(10000):=
  5         'Select Count(*)
  6         From ( SELECT To_CHAR(SYSDATE,'DD/MM/YYYY')
  7         FROM   DUAL';
  8  Begin
  9       Open g_cur_count For v_query1||')';
 10  End;
 11  /

Warning: Procedure created with compilation errors.

SQL> SHOW ERR
Errors for PROCEDURE PROC:

LINE/COL ERROR
-------- -----------------------------------------------------------------
6/39     PLS-00103: Encountered the symbol "DD" when expecting one of the
         following:
         * & = - + ; < / > at in is mod remainder not rem
         <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
         LIKE4_ LIKEC_ between || multiset member SUBMULTISET_
         The symbol "*" was substituted for "DD" to continue.

6/49     PLS-00103: Encountered the symbol ")
         FROM   DUAL" when expecting one of the following:
         . ( * @ % & = - + ; < / > at in is mod remainder not rem
         <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_

LINE/COL ERROR
-------- -----------------------------------------------------------------
         LIKE4_ LIKEC_ between || member SUBMULTISET_
         The symbol "*" was substituted for ")
         FROM   DUAL" to continue.


Oracle doc. says

PLS-00103: %s
Cause: This error message is from the parser. It found a token (language element) that is inappropriate in this context.
Action: Check previous tokens as well as the one given in the error message. The line and column numbers given in the error message refer to the end of the faulty language construct.


But i didn't understand

Please tell a solution for this error

Regards,
Ritesh
Re: PLS-00103 [message #449826 is a reply to message #449824] Thu, 01 April 2010 04:02 Go to previous messageGo to next message
cookiemonster
Messages: 13975
Registered: September 2008
Location: Rainy Manchester
Senior Member
To get a quote in a string you need to use two quotes together:
From ( SELECT To_CHAR(SYSDATE,''DD/MM/YYYY'')

Re: PLS-00103 [message #449827 is a reply to message #449826] Thu, 01 April 2010 04:15 Go to previous messageGo to next message
getritesh
Messages: 235
Registered: July 2006
Location: INDIA
Senior Member


Thanks cookiemonster


Regards,
Ritesh
Re: PLS-00103 [message #449828 is a reply to message #449826] Thu, 01 April 2010 04:20 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
For 10g and above, I prefer the quoted string delimiter:

v_query1  Varchar2(10000):=
  5         q'!Select Count(*)
  6         From ( SELECT To_CHAR(SYSDATE,'DD/MM/YYYY')
  7         FROM   DUAL!';

but each to their own

[Edit: cannae spell]

[Updated on: Thu, 01 April 2010 04:37]

Report message to a moderator

Re: PLS-00103 [message #449858 is a reply to message #449824] Thu, 01 April 2010 10:29 Go to previous messageGo to next message
Kevin Meade
Messages: 2103
Registered: December 1999
Location: Connecticut USA
Senior Member
and I prefer not to wrap lines when constructing strings.

v_query1  Varchar2(10000):=
   'select Count(*)'||' '||
   'from ( SELECT To_CHAR(SYSDATE,''DD/MM/YYYY'')'||' '||
   'FROM   DUAL!';

Kevin
Re: PLS-00103 [message #449859 is a reply to message #449858] Thu, 01 April 2010 10:54 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
So when your DBA has to debug/tune the production and look in v$sqltext(_with_new_lines) he/she get a one line query of thousand characters, I think I disagree.

Regards
Michel
Re: PLS-00103 [message #449861 is a reply to message #449824] Thu, 01 April 2010 12:26 Go to previous messageGo to next message
Kevin Meade
Messages: 2103
Registered: December 1999
Location: Connecticut USA
Senior Member
Guys who wrap code like this are unix guys. They figure all O/S's treat wrapped lines of text the same way (or more likely don't think about how it will port to other environments at all). This is not a negative comment to unix developers as this kind of thinking is normal and natural.

But the reality is that text wrapping as shown by the other posts will in the best of cases embed meaningless characters in the sql and in the worse case will generate a sql statement that does the wrong thing.

I know that what I posted is portable to all environments and O/S's without issue (at least all O/S's that I have worked on), and that the posts from those who wrap the lines is not. In my many years I have personnaly experienced code that was wrapped this way, which would not port with out syntax errors, and code that ported but because of the embedded characters, was interpreted incorrectly and inserted/updated/deleted/selected the wrong rows.

As for getting a thousand character sql statement, if it is 1000 characters long then it is 1000 characters long. That is what code formatting is for. Use TOAD, (ORAFAQ used to have one but we removed it for some reason), or find a free one online.

Kevin
Re: PLS-00103 [message #450292 is a reply to message #449861] Tue, 06 April 2010 04:39 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Never thought about it that way Kevin. Great tip, banked for the future (for when I actually start working with Oracle again!).
Re: PLS-00103 [message #450359 is a reply to message #449859] Tue, 06 April 2010 12:30 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Michel Cadot wrote on Thu, 01 April 2010 17:54
So when your DBA has to debug/tune the production and look in v$sqltext(_with_new_lines) he/she get a one line query of thousand characters, I think I disagree.

I agree with Kevin. Besides, if a DBA cannot tune a statement because it is not formatted, for GOODNESS sake, let him/her stay away from my statement (and my db as well actually)
Re: PLS-00103 [message #450407 is a reply to message #450359] Wed, 07 April 2010 01:26 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
A DBA has many other things to do than to format spend time to format queries and being able to detect an error in a bad written (or wrong) query at first sight in SGA is far better (even for clients) than getting the root of problem after spending a couple of days to format dozen of queries of thousand characters.

Regards
Michel

[Updated on: Wed, 07 April 2010 07:40]

Report message to a moderator

Re: PLS-00103 [message #450463 is a reply to message #449824] Wed, 07 April 2010 07:33 Go to previous messageGo to next message
Kevin Meade
Messages: 2103
Registered: December 1999
Location: Connecticut USA
Senior Member
If you think when you look into the v$SQL views that code is going to be beautifully formatted then the only thing I can say is... You are spending way too much time behind the cat... (very muffled "I WAS SO CLOSE").

Kevin
Re: PLS-00103 [message #450466 is a reply to message #450463] Wed, 07 April 2010 07:44 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
SQL> select sql_fulltext from v$sql where sql_fulltext like '%fga$%';
SQL_FULLTEXT
---------------------------------------------------------------------------------------
Declare
  nb pls_integer := 0;
Begin
  dbms_output.put_line (' ');
  For rec in (
    select owner, view_name, text
    from dba_views
    where text_length < 32*1024
    order by 1, 2
  ) loop
    If upper(rec.text) like '%'||upper('fga$')||'%' then
      dbms_output.put_line (rec.owner||'.'||rec.view_name);
      nb := nb + 1;
    End if;
  End loop;
  If nb > 1 then
    dbms_output.put_line (' ');
    dbms_output.put_line (nb||' views found');
  Elsif nb > 0 then
    dbms_output.put_line (' ');
    dbms_output.put_line (nb||' view found');
  Else
    dbms_output.put_line ('No view found');
  End if;
  dbms_output.put_line (' ');
  nb := 0;
  For rec in (
    select owner, view_name, text_length
    from dba_views
    where text_length >= 32*1024
    order by 1,2
  ) loop
    If nb = 0 then dbms_output.put_line ('Skipped view(s):'); End if;
    dbms_output.put_line
      ('  '||rec.owner||'.'||rec.view_name||': '||rec.text_length);
    nb := nb + 1;
  End loop;
  If nb > 0 then
    dbms_output.put_line (' ');
  End if;
End;
select sql_fulltext from v$sql where sql_fulltext like '%fga$%'

2 rows selected.

When input is formatted output is.

Regards
Michel

[Updated on: Wed, 07 April 2010 07:45]

Report message to a moderator

Re: PLS-00103 [message #450467 is a reply to message #449824] Wed, 07 April 2010 07:46 Go to previous message
Kevin Meade
Messages: 2103
Registered: December 1999
Location: Connecticut USA
Senior Member
Exactly
Previous Topic: encoding
Next Topic: Query using dblink returns more rows than direct query
Goto Forum:
  


Current Time: Mon May 04 17:02:37 CDT 2026