View Full Version : Clear One or more Fields in a Table


Paul Pellegrin
03-02-2005, 05:16 AM
How can I clear the contents of a field in all records in a table? I have Alpha Five V5 Home. I tried "blank_put" and other schemes but without any success.

Tom Cone Jr
03-02-2005, 05:42 AM
Since what you want to do affects all records in the table I'd look at designing an update operation to assign a "new" field value to the same field in each record.

-- tom

Stan Mathews
03-02-2005, 05:45 AM
Design an update operation with the genie, general tab, "blank out the value" - screenshot attached.

a_tbl = table.open("tablename")
query.order = ""
query.filter = ".T."
query.options = "I"
update.fields = 1
update.field1 = "fieldname_tobeblanked"
update.expr1 = "\"\"" '-if the field is character
update.expr1 = "0" '-if the field is numeric
update.expr1 = "{}" '-if the field is date type

03-02-2005, 05:48 AM
Hi Paul,
If you want to clear all the fields/records in the table then use EMPTY table. You will find this when right click on a table in the control panel. The xbasic command/code is Zap().
If you just want to clear some fields/records in a table, then define an update operation for the table. If a field is a character, set the value as "" for numeric fields the value should be set 0 . copy the xbasic code and save it as a script so you can run it anytime via script_play("scriptname"). Hope this helps.