Reputation: 33
Please how can i create a COBOL program with embedded SQL that accepts user input and uses SQL to INSERT into a table. I know how to insert using SQL, but i dont know how to transfer the COBOL ACCEPT input to the SQL table
EXEC SQL DECLARE A05544 TABLE
( CUST_ID CHAR(6) NOT NULL,
PROD CHAR(6) NOT NULL,
PRIC CHAR(6) NOT NULL
) END-EXEC.
01 DCLA05544.
10 CUST_ID PIC X(6).
10 PROD PIC X(6).
10 PRIC PIC X(6).
Above is the embedded SQL table declaration for the table I want to insert into
WELCOME.
DISPLAY 'INPUT CUSTOMER ID'
This is how the program starts
Ive tried to insert this way
EXEC SQL
INSERT INTO A05544
(CUST_ID)
VALUES(CID_ADD)
END-EXEC
but I get the error DSNHANAL LINE 225 COL 14 STATEMENT REFERENCES COLUMN 'A05544''CID_ADD', WHICH IS NOT DECLARED IN THE SPECIFIED TABLE(S)
Upvotes: 0
Views: 201
Reputation: 7297
There is no reference to CID_ADD anywhere in the COBOL part, is it? It looks like this is the variable you've ACCEPT
ed beforehand, in this case use :
to tell the precompiler about your intentions:
EXEC SQL
INSERT INTO A05544
(CUST_ID)
VALUES(:CID_ADD)
END-EXEC
Upvotes: 2