plsql-utility-procs.tcl

Procs to help generate pl/sql dynamically

Location:
packages/acs-subsite/tcl/plsql-utility-procs.tcl
Created:
Thu Dec 7 10:31:56 2000
Author:
mbryzek@arsdigita.com
CVS Identification:
$Id: plsql-utility-procs.tcl,v 1.9.2.4 2021/03/06 20:01:30 gustafn Exp $

Procedures in this file

Detailed information

plsql_utility::format_pieces (private)

 plsql_utility::format_pieces [ -indent indent ] \
    [ -num_spaces num_spaces ] [ -delim delim ] \
    [ -line_term line_term ] pieces

Proc to format a list of elements. This is used to generate nice error/debugging messages when we are executing things like pl/sql. Pieces is a list of lists where each element is a key value pair.

Example:

plsql_utility::format_pieces -indent 3 -delim " => "  [list [list object_type group] [list group_id -2] [list group_name "Reg users"]]
returns:
object_type    => group,
   group_id       => -2,
   group_name     => Reg users

Switches:
-indent (optional, defaults to "6")
-num_spaces (optional, defaults to "3")
-delim (optional)
-line_term (optional, defaults to ",")
Parameters:
pieces (required)
a list of lists where each element is a key/value pair
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
11/2000

Partial Call Graph (max 5 caller/called nodes):
%3 plpgsql_utility::generate_attribute_parameters plpgsql_utility::generate_attribute_parameters (public) plsql_utility::format_pieces plsql_utility::format_pieces plpgsql_utility::generate_attribute_parameters->plsql_utility::format_pieces plsql_utility::generate_attribute_parameter_call plsql_utility::generate_attribute_parameter_call (public) plsql_utility::generate_attribute_parameter_call->plsql_utility::format_pieces plsql_utility::generate_attribute_parameters plsql_utility::generate_attribute_parameters (public) plsql_utility::generate_attribute_parameters->plsql_utility::format_pieces

Testcases:
No testcase defined.

plsql_utility::generate_attribute_dml (public)

 plsql_utility::generate_attribute_dml \
    [ -start_with_comma start_with_comma ] [ -prepend prepend ] \
    [ -ignore ignore ] table_name attr_list

Generates the string for a sql insert... e.g. ",col1, col2"

Switches:
-start_with_comma (optional, defaults to "t")
-prepend (optional)
-ignore (optional)
Parameters:
table_name (required)
attr_list (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
11/2000

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

plsql_utility::generate_attribute_parameter_call (public)

 plsql_utility::generate_attribute_parameter_call [ -prepend prepend ] \
    [ -indent indent ] pairs

Generates the arg list for a call to a pl/sql function or procedure

Switches:
-prepend (optional)
-indent (optional, defaults to "9")
Parameters:
pairs (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
11/2000

Partial Call Graph (max 5 caller/called nodes):
%3 plsql_utility::generate_attribute_parameter_call_from_attributes plsql_utility::generate_attribute_parameter_call_from_attributes (public) plsql_utility::generate_attribute_parameter_call plsql_utility::generate_attribute_parameter_call plsql_utility::generate_attribute_parameter_call_from_attributes->plsql_utility::generate_attribute_parameter_call plsql_utility::format_pieces plsql_utility::format_pieces (private) plsql_utility::generate_attribute_parameter_call->plsql_utility::format_pieces

Testcases:
No testcase defined.

plsql_utility::generate_attribute_parameter_call_from_attributes (public)

 plsql_utility::generate_attribute_parameter_call_from_attributes \
    [ -prepend prepend ] [ -indent indent ] attr_list

Wrapper for generate_attribute_parameter_call that formats default attribute list to the right format.

Switches:
-prepend (optional)
-indent (optional, defaults to "9")
Parameters:
attr_list (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
11/2000

Partial Call Graph (max 5 caller/called nodes):
%3 plsql_utility::generate_attribute_parameter_call plsql_utility::generate_attribute_parameter_call (public) plsql_utility::generate_attribute_parameter_call_from_attributes plsql_utility::generate_attribute_parameter_call_from_attributes plsql_utility::generate_attribute_parameter_call_from_attributes->plsql_utility::generate_attribute_parameter_call

Testcases:
No testcase defined.

plsql_utility::generate_attribute_parameters (public)

 plsql_utility::generate_attribute_parameters [ -indent indent ] \
    attr_list

Generates the arg list to a pl/sql function or procedure

Switches:
-indent (optional, defaults to "9")
Parameters:
attr_list (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
11/2000

Partial Call Graph (max 5 caller/called nodes):
%3 plsql_utility::format_pieces plsql_utility::format_pieces (private) plsql_utility::generate_attribute_parameters plsql_utility::generate_attribute_parameters plsql_utility::generate_attribute_parameters->plsql_utility::format_pieces

Testcases:
No testcase defined.

plsql_utility::generate_constraint_name (public)

 plsql_utility::generate_constraint_name [ -max_length max_length ] \
    table column stem

Generates a constraint name adhering to the arsdigita standard for naming constraints. Note that this function does not yet ensure that the returned constraint name is not already in use, though the probability for a collision is pretty low. The ideal name is table_column_stem. We trim first table, then column to make it fit.

Switches:
-max_length (optional, defaults to "30")
Parameters:
table (required)
column (required)
stem (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
11/2000

Partial Call Graph (max 5 caller/called nodes):
%3 attribute::datatype_to_sql_type attribute::datatype_to_sql_type (private) plsql_utility::generate_constraint_name plsql_utility::generate_constraint_name attribute::datatype_to_sql_type->plsql_utility::generate_constraint_name group_type::new group_type::new (public) group_type::new->plsql_utility::generate_constraint_name rel_types::new rel_types::new (public) rel_types::new->plsql_utility::generate_constraint_name

Testcases:
No testcase defined.

plsql_utility::generate_oracle_name (public)

 plsql_utility::generate_oracle_name [ -max_length max_length ] \
    [ -include_object_id include_object_id ] stem

Returns an object name of max_length characters, in lowercase, beginning with stem but without any unsafe characters. Only allowed characters are numbers, letter, underscore, dash and space, though the returned word will start with a letter. Throws an error if no safe name could be generated. To almost guarantee uniqueness, you can use the next object_id from acs_object_id_seq as the tail of the name we return.

Switches:
-max_length (optional, defaults to "30")
-include_object_id (optional, defaults to "f")
Parameters:
stem (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
11/2000

Partial Call Graph (max 5 caller/called nodes):
%3 attribute::add attribute::add (public) plsql_utility::generate_oracle_name plsql_utility::generate_oracle_name attribute::add->plsql_utility::generate_oracle_name attribute::exists_p attribute::exists_p (public) attribute::exists_p->plsql_utility::generate_oracle_name group_type::new group_type::new (public) group_type::new->plsql_utility::generate_oracle_name packages/acs-subsite/www/admin/group-types/new.tcl packages/acs-subsite/ www/admin/group-types/new.tcl packages/acs-subsite/www/admin/group-types/new.tcl->plsql_utility::generate_oracle_name packages/acs-subsite/www/admin/rel-types/new-2.tcl packages/acs-subsite/ www/admin/rel-types/new-2.tcl packages/acs-subsite/www/admin/rel-types/new-2.tcl->plsql_utility::generate_oracle_name db_nextval db_nextval (public) plsql_utility::generate_oracle_name->db_nextval

Testcases:
No testcase defined.

plsql_utility::object_type_exists_p (public)

 plsql_utility::object_type_exists_p object_type

Returns 1 if the specified object_type exists. 0 otherwise.

Parameters:
object_type (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
11/2000

Partial Call Graph (max 5 caller/called nodes):
%3 group_type::new group_type::new (public) plsql_utility::object_type_exists_p plsql_utility::object_type_exists_p group_type::new->plsql_utility::object_type_exists_p packages/acs-subsite/www/admin/group-types/new.tcl packages/acs-subsite/ www/admin/group-types/new.tcl packages/acs-subsite/www/admin/group-types/new.tcl->plsql_utility::object_type_exists_p packages/acs-subsite/www/admin/rel-types/new-2.tcl packages/acs-subsite/ www/admin/rel-types/new-2.tcl packages/acs-subsite/www/admin/rel-types/new-2.tcl->plsql_utility::object_type_exists_p rel_types::new rel_types::new (public) rel_types::new->plsql_utility::object_type_exists_p db_string db_string (public) plsql_utility::object_type_exists_p->db_string

Testcases:
No testcase defined.

plsql_utility::parse_sql (public)

 plsql_utility::parse_sql sql_query

Replaces bind variables with their Double Apos'd values to aid in debugging. Throws error if any bind variable is undefined in the calling environment.

Limits: Only handles letter, numbers, and _ or - in bind variable names

Example:

   set group_id -2
   set sql {select acs_group.name(:group_id) from dual}
   ns_write [plsql_utility::parse_sql $sql]
would write the following to the browser:
   select acs_group.name('-2') from dual

Parameters:
sql_query (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
11/2000

Partial Call Graph (max 5 caller/called nodes):
%3 group_type::new group_type::new (public) plsql_utility::parse_sql plsql_utility::parse_sql group_type::new->plsql_utility::parse_sql ns_dbquotevalue ns_dbquotevalue plsql_utility::parse_sql->ns_dbquotevalue

Testcases:
No testcase defined.
[ show source ]