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
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.
Thankyou. you made my day. I was struggling with this error in sqldeveloper reports too