db_exec_lob_oracle (private)
db_exec_lob_oracle [ -ulevel ulevel ] [ -subst subst ] type db \ statement_name pre_sql [ file ]
Defined in packages/acs-tcl/tcl/01-database-procs.tcl
A helper procedure to execute a SQL statement, potentially binding depending on the value of the $bind variable in the calling environment (if set).
- Switches:
- -ulevel (optional, defaults to
"2"
)- -subst (optional, defaults to
"all"
)- Parameters:
- type (required)
- db (required)
- statement_name (required)
- pre_sql (required)
- file (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set start_time [expr {[clock clicks -microseconds]/1000.0}] set sql [db_qd_replace_sql -ulevel [expr {$ulevel + 1}] -subst $subst $statement_name $pre_sql] set file_storage_p 0 upvar $ulevel storage_type storage_type if {[info exists storage_type] && $storage_type eq "file"} { set file_storage_p 1 set original_type $type set qtype 1row ns_log Debug "db_exec_lob: file storage in use" } else { set qtype $type ns_log Debug "db_exec_lob: blob storage in use" } set errno [catch { upvar bind bind # Below, note that 'ns_ora blob_get_file' takes 3 parameters, # while 'ns_ora write_blob' takes only 2. So if file is empty # string (which it always will/should be for $qtype # write_blob), we must not pass any 3rd parameter to the # ns_ora command: --atp@piskorski.com, 2003/04/09 15:10 EDT if { [info exists bind] && [llength $bind] != 0 } { if { [llength $bind] == 1 } { if { $file eq "" } { # gn: not sure, why the eval was ever needed (4 times) set selection [eval [list ns_ora $qtype $db -bind $bind $sql]] } else { set selection [eval [list ns_ora $qtype $db -bind $bind $sql $file]] } } else { set bind_vars [ns_set create] foreach { name value } $bind { ns_set put $bind_vars $name $value } if { $file eq "" } { set selection [eval [list ns_ora $qtype $db -bind $bind_vars $sql]] } else { set selection [eval [list ns_ora $qtype $db -bind $bind_vars $sql $file]] } } } else { if { $file eq "" } { set selection [uplevel $ulevel [list ns_ora $qtype $db $sql]] } else { set selection [uplevel $ulevel [list ns_ora $qtype $db $sql $file]] } } if {$file_storage_p} { set content_index [ns_set find $selection "content"] if {$content_index == -1} { set content_index 0 } set content [ns_set value $selection $content_index] switch -- $original_type { blob_get_file { if {[ad_file exists $content]} { file copy -- $content $file return $selection } else { error "file: $content doesn't exist" } } write_blob { if {[ad_file exists $content]} { set ofp [open $content r] fconfigure $ofp -encoding binary ns_writefp $ofp close $ofp return $selection } else { error "file: $content doesn't exist" } } } } else { return $selection } } error] ds_collect_db_call $db $type $statement_name $sql $start_time $errno $error if { $errno == 2 } { return $error } return -code $errno -errorinfo $::errorInfo -errorcode $::errorCode $errorXQL Not present: Generic, PostgreSQL, Oracle