xo::db::DB-postgresql instproc generate_psql

 <instance of xo::db::DB-postgresql[i]> generate_psql

Defined in

Testcases:
xotcl_core_tutorial_2, xotcl-core
Source code:
set function_args [:get_function_args $package_name $object_name]
set function_args [:fix_function_args $function_args $package_name $object_name]
set sql_info [:sql_arg_info $function_args $package_name $object_name]
#ns_log notice "-- select ${package_name}__${object_name} ($psql_args)"
set sql_suffix [:psql_statement_suffix ${package_name} ${object_name}]
set sql [subst {
  select ${package_name}__${object_name}([dict get $sql_info psql_args]) $sql_suffix
}]
set sql_cmd {ns_set value [ns_pg_bind 0or1row $db $sql] 0}
dict set sql_info body [subst {
  #function_args: $function_args
  foreach var \[list [dict get $sql_info arg_order]\]  {
    set varname \[string tolower \$var\]
    if {\[info exists \$varname\]} {
      set \$var \[set \$varname\]
      set _\$var :\$var
    } else {
      set _\$var null
    }
  }
  set sql "$sql"
  db_with_handle -dbn \$dbn db {
    #ns_log notice "--sql=\$sql"
    return \[ $sql_cmd \]
  }
}]
return $sql_info
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: