To add information to an existing table, create a new row for the table using the emptyRow method, then use the at:put: method to add information to the row.
The following example uses these methods to add Joe Smith's name and address to the PEOPLE table.
In each at:put: message, the argument passed with at: is the column name and the argument passed with put: is the column value.
Substitute table and column names and column data types in the sqlDef temporary variable definition. Evaluate the code using the Execute command.
To display the data you have just added to the table, evaluate the second block of code using the Display command.
The second block of code returns the result table and converts it to an ordered collection, which displays as follows. You can execute these two blocks of code as many times as you want, substituting new data each time, to add more than one row to the table.
OrderedCollection('['Joe Smith'] ['123 Shady Lane'] ['Raleigh'] ['NC'] [27613] ['919 555-1234']' )
"Add a row to a table" | table connection newRow | connection := AbtDbmSystem activeDatabaseConnectionWithAlias: 'SampleConSpec'. table := (connection) openTableNamed: 'PEOPLE'. newRow := table emptyRow. newRow at: #NAME put: 'Joe Smith '; at: #STREET put: '123 Shady Lane '; at: #CITY put: 'Raleigh '; at: #STATE put: 'NC'; at: #ZIPCODE put: 27613; at: #PHONE put: '919 555-1234 '. table addRow: newRow. table asStrings. "Select a row from a table" | connection querySpec resultCollection| resultCollection := OrderedCollection new. connection := AbtDbmSystem activeDatabaseConnectionWithAlias: 'SampleConSpec'. querySpec := (AbtQuerySpec new) statement: 'SELECT * FROM PEOPLE'. (connection resultTableFromQuerySpec: querySpec) do: [:eachRow | resultCollection add: (eachRow asString)]. ^resultCollection.