You are here: Surpac Concepts > Macros > SCL > Database Commands > SclUpdateRow
GEOVIA Surpac

SclUpdateRow

Overview

You use the SclUpdateRow command with SclQueryUpdate to save changes to a single database row.

Synopsis

$QueryHandle SclUpdateRow

Description

Write any changes made with SclSetValueByName or SclSetValueByIndex to the current row in the database.

Arguments

  • QueryHandle
  • The variable must contain a valid query handle created by SclQueryUpdate.

Returns

Returns $SCL_TRUE on successful execution. Returns a TCL error if there is no database connected or if the query handle was not created by SclQueryUpdate.

Example

if {[sclDatabases SclCountItems] < 1} {
	error "No databases are connected"
}
#
# Get the handle to an existing database and query the collar table
# for all rows with hole_id between WD004 and WD033 above max_depth of 130
# then offset their x and y coordinates
#
sclDatabases SclGetItem DatabaseHandle 0
$DatabaseHandle SclQueryUpdate QueryHandle "collar"
$QueryHandle SclConstraint "hole_id >= WD004 AND hole_id <= WD033 AND max_depth < 130"
$QueryHandle SclQueryOrder "hole_id" "ascending"
$QueryHandle SclQueryColumn "x" "y"
$QueryHandle SclProcess
$QueryHandle SclGetIterator queryupIter
while {[$queryupIter SclIterateNext rowHandle]==1} {
  set x [$rowHandle SclGetValueByName "x"]
  set newX [expr $x + 130]
  $QueryHandle SclSetValueByName x "$newX"
  set y [$rowHandle SclGetValueByName "y"]
  set newY [expr $y - 11.02]
  $QueryHandle SclSetValueByName y "$newY"
  $QueryHandle SclUpdateRow   ;# push the changes for this row to the database

# display a message so we can see the change in the Message area
puts "moving $x, $y to $newX, $newY"
}
SclDestroy QueryHandle