Using updatable cursors

When you write an application using updatable cursors, consider the following:

This code fragment shows the sequence of CT-Library calls used to delete and update a row on an updatable cursor:

/*
 ** This sample code fragment illustrates the CT-Library calls 
 ** used to update and delete a row on an updatable cursor.
 **
 ** Error handling and other details are omitted for the sake of brevity.
 ** NOTE: Ellipses in the following represent code that you must supply.
 */
 	/*
 	** See the previous example for the cursor declare, open and
 	** fetch. The differences are:
 	** 1. The statement to declare is
 	**	SELECT * FROM AUTHORS WHERE STATE = ? FOR UPDATE OF PHONE
 	** 2. The declare must specify CS_FOR_UPDATE instead of 
 		CS_READ_ONLY.
 	** 3. The setting of the fetch count is eliminated.
 	*/
 	/*
 	** Assume that you have fetched rows (one at a time) until you see
 	** a row you want to delete. This code deletes the most recently
 	** fetched row.
 	*/
 	retcode = ct_cursor( cmd, CS_CURSOR_DELETE, "AUTHORS",
 		CS_NULLTERM, NULL,		CS_UNUSED, CS_UNUSED );
 	/*
 	** Send the batch and check results.
 	*/
 	retcode = ct_send( cmd );
 	retcode = handleresults( cmd );
 	/*
 	** Fetch more rows until we see a row that we want to update.
 	*/
 	...
 	/*
 	** Update the most recently-fetched row.  For this example, we 
 	** will update the PHONE column in the AUTHORS table, and we
 	** will use a parameter in the update statement for the value of
 	** PHONE. Fill in the CS_DATAFMT structure for the parameter and 
 	** the parmval, atlen, and nullind values.
 	*/
 	dfmt.status = CS_INPUTVALUE;
 	dfmt.datatype = CS_CHAR_TYPE;
 	strcpy( parmval, "303-443-2706" );
 	datlen = strlen( "303-443-2706" );
 	nullind = 0;
 	/*
 	** Send the cursor update.
 	*/
 	retcode = ct_cursor( cmd, CS_CURSOR_UPDATE, "AUTHORS",
 		CS_NULLTERM,"UPDATE AUTHORS SET PHONE = ?", CS_NULLTERM,
 		CS_UNUSED );
 	/*
 	** Send the parameter description and value.
 	*/
 	retcode = ct_param( cmd, &dfmt, parmval, datlen, nullind );
 	/*
 	** Send the batch and check results.
 	*/
 	retcode = ct_send( cmd );
 	retcode = handleresults( cmd );