ODBC/Methods/Update

From J Wiki
Jump to: navigation, search
ODBC: Data Sources | Handles | Data Driver | Error Messages | API: Connect Read Update Create Bulk Insert

To update a record, you process an SQL update statement. Here we update the salary field for ABBOTT K.

First read the record to see the current value (the salary is 50817):

   sel=. 'select * from tdata where name=''ABBOTT K'''
   ddfet sel ddsel ch
+--------------+-+----+--------+--------+-----+
|Abbott K      |M|D103|19631000|19830900|50817|
+--------------+-+----+--------+--------+-----+

Next we process an update statement:

   us=. 'update tdata set salary=45000 where name=''ABBOTT K'''
   us ddsql ch
0

Finally, we read the record again, to ensure the update was successful:

   sel=. 'select * from tdata where name=''ABBOTT K'''
   ddfet sel ddsel ch
+--------------+-+----+--------+--------+-----+
|Abbott K      |M|D103|19631000|19830900|45000|
+--------------+-+----+--------+--------+-----+