package_attribute_default (private)

 package_attribute_default [ -min_n_values min_n_values ] \
    [ -attr_default attr_default ] object_type table column

Defined in packages/acs-subsite/tcl/package-procs.tcl

Returns a sql value to be used as the default in a pl/sql function or procedure parameter list. This is a special case, hardcoded function that specifies defaults for standard acs_object attributes.

Switches:
-min_n_values
(defaults to "0") (optional)
Used to determine if an argument is required (e.g. required = min_n_values != 0)
-attr_default
(optional)
The default values for this attribute as specified in the attributes table.
Parameters:
object_type - The object type that owns the attribute we are using. Used only to set a default for acs_object.object_type stored (either table_name from the attribute or for the object_type)
table - The table in which the value of this attribute is stored (either table_name from the attribute or for the object_type)
column - The column in which the value of this attribute is stored (either column_name or attribute_name from the attributes table)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/28/2000

Partial Call Graph (max 5 caller/called nodes):
%3 package_create_attribute_list package_create_attribute_list (private) package_attribute_default package_attribute_default package_create_attribute_list->package_attribute_default db_map db_map (public) package_attribute_default->db_map ns_dbquotevalue ns_dbquotevalue package_attribute_default->ns_dbquotevalue

Testcases:
No testcase defined.
Source code:

    # We handle defaults grossly here, but I don't currently have
    # a better idea how to do this
    if { $attr_default ne "" } {
        return [::ns_dbquotevalue $attr_default]
    }

    # Special cases for acs_object and acs_rels
    # attributes. Default case sets default to null unless the
    # attribute is required (min_n_values > 0)

    if {$table eq "ACS_OBJECTS"} {
        switch -- $column {
            "OBJECT_TYPE"   { return [::ns_dbquotevalue $object_type] }
            "CREATION_DATE" { return [db_map creation_date] }
            "CREATION_IP"   { return "NULL" }
            "CREATION_USER" { return "NULL" }
            "LAST_MODIFIED" { return [db_map last_modified] }
            "MODIFYING_IP"  { return "NULL" }
        }
    } elseif {$table eq "ACS_RELS"} {
        switch -- $column {
            "REL_TYPE"      { return [::ns_dbquotevalue $object_type] }
        }
    }

    # return to null unless this attribute is required
    # (min_n_values > 0)
    return [expr {$min_n_values > 0 ? "" : "NULL"}]
Generic XQL file:
<fullquery name="package_attribute_default.creation_date">
    <querytext>current_timestamp</querytext>
</fullquery>

<fullquery name="package_attribute_default.last_modified">
    <querytext>current_timestamp</querytext>
</fullquery>
packages/acs-subsite/tcl/package-procs.xql

PostgreSQL XQL file:
packages/acs-subsite/tcl/package-procs-postgresql.xql

Oracle XQL file:
packages/acs-subsite/tcl/package-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: