xo::db::postgresql instproc nextval (public)
<instance of xo::db::postgresql> nextval sequence
Defined in /var/www/openacs/packages/xotcl-core/tcl/05-db-procs.tcl
Return the next value of a PostgreSQL sequence, resolving its name through the per-thread sequence cache.
- Parameters:
- sequence (required)
- Sequence name.
- Testcases:
- xotcl_core_tutorial_4, test_cr_items
Source code: if {![info exists ::db::sequences]} { ns_log notice "-- creating per thread sequence table (triggered by :xo::db::postgresql nextval $sequence)" foreach s [::xo::dc list relnames "select relname from pg_class where relkind = 'S'"] { set ::db::sequences($s) 1 } } if {[info exists ::db::sequences(t_$sequence)]} { #ns_log notice "-- found t_$sequence" set sequenceName t_$sequence set nextval [::xo::dc get_value nextval "select nextval(:sequenceName)"] } elseif {[info exists ::db::sequences($sequence)]} { #ns_log notice "-- found $sequence" set sequenceName $sequence set nextval [::xo::dc get_value nextval "select nextval(:sequenceName)"] } elseif { [::xo::dc 0or1row nextval_sequence { select nextval(:sequence) as nextval where (select relkind from pg_class where relname = :sequence) = 'S' }]} { # # We do not have an according sequence-table. Use the system catalog to check # for the sequence # # ... the query sets nextval if it succeeds # } else { # # finally, there might be a view with a nextval # ns_log debug "db_nextval: sequence($sequence) is not a real sequence. Perhaps it uses the view hack." set nextval [::xo::dc get_value nextval "select nextval from :sequence"] } return $nextvalXQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)