Wrapped code with comment line became invalid

32 views
Skip to first unread message

A Sundar

unread,
Nov 7, 2014, 10:18:42 AM11/7/14
to oracle...@googlegroups.com
Hi,
 
 Wrapped source with comment line gives compalation error ORA-24344 and staus became invalid. I would like to know whether we can't use comment like in the wrapped code or any other way to use comment line in wrapped code.
 
 Testcase:
***********

DECLARE
  l_status    VARCHAR2(128);
  l_unwrapped VARCHAR2(4000) := 'create or replace procedure SYSTEM.wrap_test
is
begin  
if/* test */true then    
null;  
end if;
end wrap_test;';
  l_wrapped   VARCHAR2(4000);
BEGIN
  l_wrapped := dbms_ddl.wrap(l_unwrapped);
  EXECUTE immediate l_unwrapped;
  SELECT status
  INTO l_status
  FROM dba_objects
  WHERE owner     = 'SYSTEM'
  AND object_name = 'WRAP_TEST';
  dbms_output.put_line('unwrapped status:'||l_status);
  BEGIN
    EXECUTE immediate l_wrapped;
  EXCEPTION
  WHEN OTHERS THEN
   dbms_output.put_line('sql error message'||sqlerrm);
  END;
  SELECT status
  INTO l_status
  FROM dba_objects
  WHERE owner     = 'SYSTEM'
  AND object_name = 'WRAP_TEST';
  DBMS_OUTPUT.PUT_LINE('wrapped status:'||L_STATUS);
END;
  
Output:
*********

Created!
unwrapped status:VALID

Created!
sql error message ORA-24344: success with compilation error
wrapped status:INVALID


select text from USER_ERRORS where NAME = 'WRAP_TEST'; 

"PLS-00103: Encountered the symbol "THEN" when expecting one of the following:

   := . ( @ % ;
"   

Regards,
Sundar  

Michael Moore

unread,
Nov 7, 2014, 1:55:43 PM11/7/14
to oracle-plsql
This seems to work
DECLARE
   l_status      VARCHAR2(128);
   l_unwrapped   VARCHAR2(4000) := 'create or replace procedure QSN_APP.wrap_test
is
begin
--test comment goes here  
if true then    
null;  
end if;
end wrap_test;';
   l_wrapped     VARCHAR2(4000);
BEGIN
   l_wrapped := DBMS_DDL.wrap(l_unwrapped);

   EXECUTE IMMEDIATE l_unwrapped;

   SELECT status
     INTO l_status
     FROM dba_objects
    WHERE owner = 'QSN_APP' AND object_name = 'WRAP_TEST';

   DBMS_OUTPUT.put_line(   'unwrapped status:'
                        || l_status);

   BEGIN

      EXECUTE IMMEDIATE l_wrapped;
   EXCEPTION
      WHEN OTHERS THEN
         DBMS_OUTPUT.put_line(   'sql error message'
                              || SQLERRM);
   END;

   SELECT status
     INTO l_status
     FROM dba_objects
    WHERE owner = 'QSN_APP' AND object_name = 'WRAP_TEST';

   DBMS_OUTPUT.put_line(   'wrapped status:'
                        || l_status);
END;


--
--
You received this message because you are subscribed to the Google
Groups "Oracle PL/SQL" group.
To post to this group, send email to Oracle...@googlegroups.com
To unsubscribe from this group, send email to
Oracle-PLSQL...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en

---
You received this message because you are subscribed to the Google Groups "Oracle PL/SQL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oracle-plsql...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

A Sundar

unread,
Nov 8, 2014, 7:26:16 AM11/8/14
to oracle...@googlegroups.com
Hi,

Thanks for your input on this.

This seems like issue with below statement.

if/* test */true then   --- no space between if and /

If i replace this with  if /* test */true then it is working fine with wrapped code. But unwrapped code working in both the case.

What is your view about this case.

Regards,
Sundar



ddf

unread,
Jan 7, 2015, 12:28:07 PM1/7/15
to oracle...@googlegroups.com
It appears that the wrap utility uses a slightly different parsing mechanism than SQL*Plus so the spaces are required if wrap is to work correctly.  It isn't a bug and it isn't a problem.


David Fitzjarrell 
Reply all
Reply to author
Forward
0 new messages