Progress
Embedded SQL-92
Guide and Reference


UPDATE Rows in a Table

An UPDATE statement modifies data in one or more rows of a table.

EXAMPLE

The following UPDATE statement updates the phone number of a row in the customer table:

/*
** Connect to the default database.
*/
EXEC SQL CONNECT TO DEFAULT ;
 
cust_no_v = 1004 ;
 
EXEC SQL
     UPDATE customer
     SET  phone = ‘(203)555-2703’ 
     WHERE cust_no = :cust_no_v ; 
 
if (sqlca.sqlcode < 0)
{
     printf ("Update statement failed (%ld : %s)\n",
               sqlca.sqlcode, sqlca.sqlerrm);
     EXEC SQL ROLLBACK WORK ;
     EXEC SQL DISCONNECT DEFAULT ;
     exit (1); 
}
/*
** Successful; COMMIT the UPDATE operation.
*/
EXEC SQL COMMIT WORK ;
 
printf ("Update Successful\n\n");
 
/* Disconnect from the database */
EXEC SQL DISCONNECT DEFAULT ; 

EXAMPLE

The following UPDATE statement gives a 10 percent increase in salary to all employees of department 12. Note that multiple rows are updated with this UPDATE statement:

EXEC SQL
    UPDATE employee
    SET sal = sal * 1.1
    WHERE deptno = 12 ; 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095