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

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

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
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:

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

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:

t_ddl clob;
t_ddl_tab dbms_sql.varchar2s;
t_cur integer;
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
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 );

By the way, you can find this great plugin here



  1. prasannakurugod January 24, 2017
  2. Vijay September 23, 2014