Solving PLS-00753: malformed or corrupted wrapped unit within Apex SQL Workshop

Anton Scheffer 2

I was working on this great Apex plugin to load Excel sheets with more than 50 columns into the database. And because I had all those great, but secret ideas, to solve all the problems I used a wrapped package to store all the functionality of the plugin.
That worked perfect on my development machine, were I release all the code with SQL*Plus or Toad, but not on apex.oracle.com.
When I uploaded my scripts to the SQL Workshop, and ran it the wrapped script resulted in an error:

Error at line 0: PLS-00753: malformed or corrupted wrapped unit.

Googling this error didn’t help. Oracle advises to run the unwrapped code and wrap it afterwards inside the database, not much of a solution if you want to keep the source secret. But I found this site, which says: “This only happens if the last character of the wrapped code is at the end of a line.” The solution from that site didn’t worked for me, but I started to play with modifying the source of my invalid package.

Running this script after the wrapped script worked for me:

begin
execute immediate replace
( dbms_metadata.get_ddl( 'PACKAGE_BODY','DLW', sys_context( 'userenv', 'current_schema' ) )
, ' ' || chr(10)
, chr(10)
);
end;

Just remove a trailing space of every line. And if you happen to be on an Oracle 10 database and have a large wrapped package, this will work too:

declare
t_ddl clob;
t_ddl_tab dbms_sql.varchar2s;
t_cur integer;
begin
t_ddl := replace( dbms_metadata.get_ddl( 'PACKAGE_BODY','DLW', sys_context( 'userenv', 'current_schema' ) )
, ' ' || chr(10)
, chr(10)
);
for i in 0 .. trunc( length( t_ddl ) - 1 ) / 256
loop
t_ddl_tab( i ) := substr( t_ddl, 1 + i * 256, 256 );
end loop;
t_cur := dbms_sql.open_cursor;
dbms_sql.parse( t_cur, t_ddl_tab, 0, t_ddl_tab.last(), false, dbms_sql.native );
dbms_sql.close_cursor( t_cur );
end;

By the way, you can find this great plugin here

2 thoughts on “Solving PLS-00753: malformed or corrupted wrapped unit within Apex SQL Workshop

  1. declare
    t_ddl clob;
    t_ddl_tab dbms_sql.varchar2s;
    t_cur integer;
    begin
    t_ddl := replace( dbms_metadata.get_ddl( ‘PACKAGE_BODY’,’GWPKS_RDCREATE’, sys_context( ‘userenv’, ‘current_schema’ ) )
    , ‘ ‘ || chr(10)
    , chr(10)
    );
    for i in 0 .. trunc( length( t_ddl ) – 1 ) / 256
    loop
    t_ddl_tab( i ) := substr( t_ddl, 1 + i * 256, 256 );
    end loop;
    t_cur := dbms_sql.open_cursor;
    dbms_sql.parse( t_cur, t_ddl_tab, 0, t_ddl_tab.last(), false, dbms_sql.native );
    dbms_sql.close_cursor( t_cur );
    end;

    GWPKS_RDCREATE is my unit. Even after running the above block, I’m still facing the same error. Please help.

Comments are closed.

Next Post

Book Review of Building Modular Cloud Apps with OSGi by Bert Ertman and Paul Bakker (last edit: 25th October)

Facebook0TwitterLinkedin(this article was written as a live blog: it was work in progress for several days- while I was reading this book – this article was updated several times; at this point, it is complete. Title: Building Modular Cloud Apps with OSGi – Practical Modularity with Java in the Cloud […]