plsql_utility::generate_constraint_name (public)

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

Defined in packages/acs-subsite/tcl/plsql-utility-procs.tcl

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

Testcases:
No testcase defined.
Source code:
        set max_length_without_stem [expr {$max_length - [expr {[string length $stem] + 1}]}]

        set text "${table}_$column"
        if { [string length $text] > $max_length_without_stem } {
            set text ""
            # Pull out the initials of the table name
            foreach piece [split $table "_"] {
                append text [lindex [split $piece ""] 0]
            }
            append text "_$column"
        }
        return [string toupper "[string range $text 0 $max_length_without_stem-1]_$stem"]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: