Previous Topic: Updating SQL Columns of Type DATENext Topic: Drop Table Example


Getting the Exact Syntax for Updating a SQL Table

In order to update an existing SQL table, it is necessary to know the exact order of the columns, the data types, and the existence of null indicators. Fortunately, there is an easy technique to get the exact CA Culprit syntax needed to update an SQL table. Here's how:

Code a small CA Culprit program using TYPE=ADD on the OUTPUT parameter. Deliberately make a mistake on the data type or size of an EDIT parameter. This produces E level errors during the compile phase of CA Culprit.

Report Syntax

 col. 2
 ▼
 IN 80
 REC  ID  1 4 2
 01OUT  SQLTABLE=STOCKS      TYPE=ADD
*       DICTIONARY=TSTDICT   SCHEMA=INV
 0151*001  ID   FW     $ Deliberate Error!
 017       DROP

At the end of the compile phase, error messages are produced on the Input Parameter Listing. Message C700071 provides you with sample EDIT parameters to describe the output SQL table exactly. Use this as a template for coding your CA Culprit program.

Table Diagnostics

********* EDIT      LINE CC COLUMN   VALUE OR FIELD-NAME AND EDIT OPTIONS *********  01   5     1       *001   ID       FW E C300064 FORMAT CODE IS INVALID E C300023 FIELD SIZE IS INVALID I C700071 USE THE SAMPLE EDIT PARAMETERS BELOW TO CORRECT YOUR PROGRAM           0151*010 COMPANY_NAME                      SZ=0020           0151*020 COMPANY_ID                        SZ=0005           0151*021 COMPANY_ID_NULL_IND         FB    SZ=0004           0151*030 TRADING_DATE                      SZ=0010           0151*031 TRADING_DATE_NULL_IND       FB    SZ=0004           0151*040 VOLUME                      FB    SZ=0004           0151*041 VOLUME_NULL_IND             FB    SZ=0004           0151*050 CLOSE_PRICE                 FP    SZ=0005   DP=0003           0151*061 CLOSE_PRICE_NULL_IND        FB    SZ=0004