SclDelete
Overview
This command creates a new delete operation for a database table. This allows you to delete one or more rows in a database table. The rows to be deleted can be restricted to a subset of all rows in the table by using a constraint to the delete operation.
Synopsis
$DatabaseHandle SclDelete DeleteHandle $TableName
Description
Create a new delete operation for the specified table and assign the delete handle to a variable for later use.
Arguments
- DatabaseHandle
- DeleteHandle
- TableName
The variable must contain a valid database handle.
Passed by reference. The variable to which the delete handle will be assigned.
Passed by value. The name of the database table from which the rows of data will be inserted.
Returns
Returns $SCL_TRUE on successful execution. Throws a TCL error if there is no database connected or if the specified table does not exist in the database.
Examples
#
# Get the handle to an existing database and a new row in the collar table
#
if {[sclDatabases SclCountItems] < 1} {
error "No databases are connected"
}
sclDatabases SclGetItem DatabaseHandle 0
#
# create an insert operation for the collar table
#
$DatabaseHandle SclDelete DeleteHandle "collar"
$DeleteHandle SclConstraint "hole_id >= Z"
$DeleteHandle SclProcess
SclDestroy DeleteHandle
# get handle to the collar table
$DatabaseHandle SclIterateFirst DatabaseIterator
while {[$DatabaseIterator SclIterateNext TableHandle]} {
if {"[$TableHandle SclGetId]" == "collar"} {
break
}
}
# register all columns in the collar table
$DatabaseHandle SclQuery QueryHandle "collar"
$TableHandle SclIterateFirst TableIterator
while {[$TableIterator SclIterateNext ColumnName]} {
$QueryHandle SclQueryColumn $ColumnName
lappend ColumnNames $ColumnName
}
puts "Column names = $ColumnNames"
$QueryHandle SclProcess
$QueryHandle SclGetIterator QueryIterator
while {[$QueryIterator SclIterateNext RowHandle] == $SCL_TRUE} {
# iterate over all values in the row and append them for display purposes
$RowHandle SclIterateFirst RowIterator
while {[$RowIterator SclIterateNext ColumnValue]} {
lappend values $ColumnValue
}
# now display the values for this row
puts "Row values = $values"
unset values
}
SclDestroy QueryHandle
|