xo::db::require proc references

 xo::db::require[i] references

Defined in

Partial Call Graph (max 5 caller/called nodes):
%3 test_xotcl-core xotcl-core (test ) xo::db::require proc references xo::db::require proc references test_xotcl-core->xo::db::require proc references test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test ) test_xotcl_core_tutorial_2->xo::db::require proc references

Testcases:
xotcl_core_tutorial_2, xotcl-core
Source code:
# Check for already existing foreign keys.
set ref [string trim $ref]
# try to match the full reftable(refcol) syntax...
if {![regexp {^(\w*)\s*\(\s*(\w*)\s*\)\s*(.*)$} $ref match reftable refcol rest]} {
  # if fails only table was given, assume refcol is reftable's
  # primary key
  set reftable [lindex $ref 0]
  set refcol [::acs::dc call util get_primary_keys -table $reftable]
  # only one primary key is supported for the table
  if {[llength $refcol] != 1} {
    return
  }
}

set exists_p [::acs::dc call util foreign_key_exists  -table $table  -column $col  -reftable $reftable  -refcolumn $refcol]
if {$exists_p} {
  ns_log debug "foreign key already exists for table $table column $col"  "to ${reftable}(${refcol})"
  return
}
::xo::dc dml alter-table-$table  "alter table $table add foreign key ($col) references $ref"
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: