Re: how to compile a package from a form.
Date: 31 Mar 2003 05:35:23 -0800
Message-ID: <c0e3f26e.0303310535.76d4574b_at_posting.google.com>
playmaker_at_iname.com (Playmaker) wrote in message news:<459dd057.0303280446.2d56cb1a_at_posting.google.com>...
> I have a package caled dw_test.sql, located in a unix server under the path
> /usr/test/. Is there a way to create a button in a form that will JUST compile
> this specific package? I don't want to run any of the procedures this package
> contains.I would like just to compile it.
> Neither the EXEC SQL nor the DBMS_SQL.EXECUTE commands have been proven very
> helpfull. Any suggestions are welcomed.
> Thank you in advance.
If you just wanted to compile the package you could do this:
DBMS_UTILITY.EXEC_DDL_STATEMENT('ALTER PACKAGE dw_test COMPILE');
However, it sounds more like to want to CREATE OR REPLACE the package based on a script in a file? In that case you would need to read the file and build the DDL statement, then use DBMS_UTILITY.EXEC_DDL_STATEMENT to run that. If the file is on the client you can use TEXT_IO to read it; if it is on the server you can use UTL_FILE. In either case the logic would be similar:
DECLARE
v_file TEXT_IO.FILE_TYPE; v_line VARCHAR2(2000); v_ddl VARCHAR2(32767);
BEGIN
- Open the file for read
v_file := TEXT_IO.FOPEN( '/usr/test/dw_test.sql', 'R' );
LOOP
- Get next line until EOF
BEGIN
TEXT_IO.GET_LINE( v_file, v_line );
EXCEPTION
WHEN NO_DATA_FOUND THEN
- EOF EXIT; END;
- Build DDL statement v_ddl := v_ddl||' '||v_line; END LOOP; TEXT_IO.FCLOSE(v_file);
- Get next line until EOF
BEGIN
TEXT_IO.GET_LINE( v_file, v_line );
EXCEPTION
WHEN NO_DATA_FOUND THEN
- Run the DDL statement DBMS_UTILITY.EXEC_DDL_STATEMENT(v_ddl); END;