package_generate_body (private)
package_generate_body object_type
Defined in packages/acs-subsite/tcl/package-procs.tcl
Generates plsql to create the package body
- Parameters:
- object_type (required)
- The name of the object type for which we are creating the package
- Author:
- Michael Bryzek <mbryzek@arsdigita.com>
- Created:
- 10/2000
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: # Pull out information about this object type acs_object_type::get -object_type $object_type -array acs_type set table_name $acs_type(table_name) set id_column $acs_type(id_column) set package_name [string tolower $acs_type(package_name)] set supertype $acs_type(supertype) # Pull out information about the supertype acs_object_type::get -object_type $supertype -array acs_type set supertype_table_name $acs_type(table_name) set supertype_id_column $acs_type(id_column) set supertype_package_name [string tolower $acs_type(package_name)] set attribute_list [package_create_attribute_list -supertype $supertype -object_name "NEW" -table $table_name -column $id_column $object_type] # Prune down the list of attributes in supertype_attr_list to # those specific to the function call in the supertype's package set supertype_params [db_list select_supertype_function_params {}] set supertype_attr_list [package_create_attribute_list -supertype $supertype -object_name "NEW" -limit_to $supertype_params -table $supertype_table_name -column $supertype_id_column -column_value $id_column $supertype] return [db_map body]Generic XQL file: packages/acs-subsite/tcl/package-procs.xql
PostgreSQL XQL file: <fullquery name="package_generate_body.select_supertype_function_params"> <querytext> select args.arg_name from acs_function_args args where args.function = upper(:supertype_package_name) || '__NEW' </querytext> </fullquery> <fullquery name="package_generate_body.body"> <querytext> begin perform drop_package('${package_name}'); perform define_function_args('${package_name}__new','[plpgsql_utility::define_function_args $attribute_list]'); CREATE FUNCTION ${package_name}__new([plpgsql_utility::generate_function_signature $attribute_list]) RETURNS [db_column_type -complain $table_name $id_column] AS $$ DECLARE [plpgsql_utility::generate_attribute_parameters $attribute_list]; v_$id_column ${table_name}.${id_column}%TYPE; BEGIN v_$id_column := ${supertype_package_name}__new ( [plpgsql_utility::generate_attribute_parameter_call_from_attributes \ -prepend "p_" \ "${supertype_package_name}__new" \ $supertype_attr_list] ); insert into ${table_name} ($id_column[plsql_utility::generate_attribute_dml -ignore [list $id_column] $table_name $attribute_list]) values (v_$id_column[plsql_utility::generate_attribute_dml -prepend "p_" -ignore [list $id_column] $table_name $attribute_list]); return v_$id_column; END; $$ LANGUAGE plpgsql; CREATE FUNCTION ${package_name}__delete ( p_${id_column} [db_column_type -complain $table_name $id_column] ) RETURNS integer AS $$ DECLARE BEGIN perform ${supertype_package_name}__delete( p_${id_column} ); return 1; END; $$ LANGUAGE plpgsql; return null; end; </querytext> </fullquery>packages/acs-subsite/tcl/package-procs-postgresql.xql
Oracle XQL file: <fullquery name="package_generate_body.select_supertype_function_params"> <querytext> select args.argument_name from user_arguments args where args.package_name =upper(:supertype_package_name) and args.object_name='NEW' </querytext> </fullquery> <fullquery name="package_generate_body.body"> <querytext> create or replace package body ${package_name} as [package_insert_default_comment] function new ( [plsql_utility::generate_attribute_parameters $attribute_list] ) return ${table_name}.${id_column}%TYPE is v_$id_column ${table_name}.${id_column}%TYPE; begin v_$id_column := ${supertype_package_name}.new ( [plsql_utility::generate_attribute_parameter_call_from_attributes \ -prepend "new." \ -indent 21 \ $supertype_attr_list] ); insert into ${table_name} ($id_column[plsql_utility::generate_attribute_dml -ignore [list $id_column] $table_name $attribute_list]) values (v_$id_column[plsql_utility::generate_attribute_dml -prepend "new." -ignore [list $id_column] $table_name $attribute_list]); return v_$id_column; end new; procedure del ( $id_column in ${table_name}.${id_column}%TYPE ) is begin ${supertype_package_name}.del( $package_name.del.$id_column ); end del; end ${package_name}; </querytext> </fullquery>packages/acs-subsite/tcl/package-procs-oracle.xql