java - how I can copy the package source from database to my local machine using jdbc? -
i want copy packages's source in local machine using jdbc.
select dbms_metadata.get_ddl('package_body','collectstats','myschema') dual;
i have tried not getting it
you can create custom table ddl each objects (packages, procedures, functions) following:
drop table myobjects; create table myobjects (obj_name varchar2(128), sub_obj_name varchar2(128), obj_type varchar2(128), obj_ddl clob); set serveroutput on declare uobj_ddl clob; cnt number := 1; begin dt in (select object_name, subobject_name, object_type user_objects object_type in ('function','procedure','package')) loop --dbms_output.put_line(dt.object_name); uobj_ddl := dbms_metadata.get_ddl(upper(dt.object_type), upper(dt.object_name)); insert myobjects values (dt.object_name, dt.subobject_name, dt.object_type, uobj_ddl); if mod(cnt,100) = 0 commit; end if; cnt := cnt + 1; end loop; commit; end; /
then can select on java using jdbc:
select * myobjects;
sample java code:
try { pstat = con.preparestatement("select * myobjects"; resultset rset = pstat.executequery(); while(rset.next()){ objname = rset.getstring(1); subobjname = rset.getstring(2); objtype = rset.getstring(3); objddl = rset.getclob(4); } rset = null; } catch (sqlexception e) { e.printstacktrace(); } pstat = null;
Comments
Post a Comment