Text and image sample program

The example9.c sample program generates a random image, inserts it into a table, and then selects the image and compares it to the original by following these steps:

  1. Inserts all data into the row except the text or image value.

  2. Updates the row, setting the text or image value to NULL. This step is necessary, because a text or image value that is null will have a valid text pointer only if the null value was explicitly entered with the update statement.

  3. Selects the row. You must specifically select the column that is to contain the text or image value. This step is necessary in order to provide the application’s DBPROCESS with correct text pointer and text timestamp information. The application should throw away the data returned by this select command.

  4. Calls dbtxtptr to retrieve the text pointer from DBPROCESS. dbtxtptr’s column parameter is an integer that refers to the select operation performed in step 3. For example, if “text_column” is the name of the text column, the select statement reads:

    select date_column, integer_column, text_column
    
    from bigtable
    

    dbtxtptr requires column to be passed as 3.

  5. Calls dbtxtimestamp to retrieve the text timestamp from the DBPROCESS. dbtxtimestamp’s column parameter refers to the select operation performed in step 3.

  6. Writes the text or image value to Adaptive Server. An application can either:

    • Write the value with a single call to dbwritetext, or

    • Write the value in chunks, using dbwritetext and dbmoretext.

NoteIf you intend the application to perform another update to this text or image value, you may want to save the new text timestamp that is returned by Adaptive Server at the conclusion of a successful dbwritetext operation. The new text timestamp can be accessed using dbtxtsnewval and stored for later retrieval using dbtxtsput.

Also, access to a Adaptive Server that contains the pubs2 database is required.