To insert a new row into a database table, you use the following technique:
| Note: | To find the column names for a table, send the table the AbtTable>>columnNames message. |
The following sample code inserts a new row into a table in the SAMPLE database as follows:
To use this block of code, evaluate it with the Inspect command.
"Insert a row in a table"
| connection newRow table |
connection := AbtDbmSystem activeDatabaseConnectionWithAlias: 'SAMPLE'.
table := (connection openTableNamed: 'STAFF').
newRow := table emptyRow.
newRow at: #NAME put: 'Delancey';
at: #ID put: 999;
at: #DEPT put: 10;
at: #JOB put: 'Clerk';
at: #SALARY put: 15000;
at: #YEARS put: 2;
at: #COMM put: 185.
table addRow: newRow.
^table asStrings.