package_create (private)
package_create [ -debug_p debug_p ] object_type
Defined in packages/acs-subsite/tcl/package-procs.tcl
Creates a packages with a new function and delete procedure for the specified object type. This function uses metadata exclusively to create the package. Resets the package_object_view cache Throws an error if the specified object type does not exist or is not dynamic
- Switches:
- -debug_p (optional, defaults to
"f"
)- If "t" then we return a text block containing the sql to create the package. Setting debug_p to t will not create the package.
- Parameters:
- object_type (required)
- The object type for which to create a package
- Author:
- Michael Bryzek <mbryzek@arsdigita.com>
- Created:
- 12/27/2000
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if {[catch { acs_object_type::get -object_type $object_type -array acs_type } errmsg]} { error "The specified object, $object_type does not exist." } if { ![string is true -strict $acs_type(dynamic_p)] } { error "The specified object, $object_type is not dynamic. Therefore, a package cannot be created for it" } # build up a list of the pl/sql to execute as it will make it # easier to return a string for debugging purposes. set package_name $acs_type(package_name) lappend plsql [list "package" "create_package" [package_generate_spec $object_type]] [list "package body" "create_package_body" [package_generate_body $object_type]] if { $debug_p == "t" } { foreach pair $plsql { # append text "[plsql_utility::parse_sql [lindex $pair 1]]\n\n" append text [lindex $pair 2] } return $text } foreach pair $plsql { lassign $pair type stmt_name code db_exec_plsql $stmt_name $code # Let's check to make sure the package is valid # # This seems to be a speciality in Oracle: The status of a # program unit (PL/SQL package, procedure, or function) is set # to INVALID if a database object on which it depends is # changed. That program unit must then be recompiled (which # Oracle Database will often do automatically the next time # you try to use that program unit). # if { ![db_string package_valid_p {}] } { error "$object_type \"$package_name\" is not valid after compiling:\n\n$code\n\n" } } # Now reset the object type view in case we've cached some attribute queries package_object_view_reset $object_type # Return the object type - what else to return? return $object_typeGeneric XQL file: packages/acs-subsite/tcl/package-procs.xql
PostgreSQL XQL file: <fullquery name="package_create.package_valid_p"> <querytext> -- select case when exists (select 1 -- from user_objects -- where status = 'INVALID' -- and object_name = upper(:package_name) -- and object_type = upper(:type)) -- then 0 else 1 end select 1 from dual; </querytext> </fullquery>packages/acs-subsite/tcl/package-procs-postgresql.xql
Oracle XQL file: <fullquery name="package_create.package_valid_p"> <querytext> select case when exists (select 1 from user_objects where status = 'INVALID' and object_name = upper(:package_name) and object_type = upper(:type)) then 0 else 1 end from dual </querytext> </fullquery>packages/acs-subsite/tcl/package-procs-oracle.xql