JDD/Methods/Update

From J Wiki
< JDD
Jump to navigation Jump to search
JDD: Driver Locale | Handles | Data Sources | 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__db sel ddsel__db ch
+--------+-+----+----------+----------+-----++
|Abbott K|M|D103|1963-10-01|1983-09-01|50817||
+--------+-+----+----------+----------+-----++

Next we process an update statement:

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

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

   sel=. 'select * from tdata where name=''ABBOTT K'''
   ddfet__db sel ddsel__db ch
+--------+-+----+----------+----------+-----++
|Abbott K|M|D103|1963-10-01|1983-09-01|45000||
+--------+-+----+----------+----------+-----++