I changed the second parameter to character. I changed the 3rd parameter to output. The stored procedure keeps getting a null error on the insert from the JSON_TABLE values, even though I'm passing in data. I'm not sure if it is how I'm passing it in, or if it is my JSON_TABLE code. I've made a lot of changes trying different things and rearranging the order of the fields on the insert, and I keep getting that same error on the insert, where the first field listed gets a null error. It has 3 parameters:
IN INTRANS CHAR (01),
IN INVDTA CHAR (5000),
OUT OUTID INTEGER
When I call it in Run SQL Scripts, I pass this:
call xptest/AV620SP
('A','
{"CountQty": 11.0,
"CountReason": "BD",
"Discrepancy": 4.0,
"Location": "DF028-044-02-0",
"SKU": 623826.0,
"OrderNumber": 123456789.0,
"DateCountCreated": "2022-08-01",
"TimeCountCreated": "08:15:22",
"CountEmployee": "34523",
"ErrorDescription": "Duplicate",
"ErrorDate": 20220801,
"ErrorTime": 81522,
"Notes": "This is a test"}
',?)
Attached is the pertinent code for the stored procedure. When I call it as it is coded right now from Run SQL Scripts as above, it returns
SQL State: 23502
Vendor Code: -407
Message: [SQL0407] Null values not allowed in column or variable INSLTLOC.
Do you see anything obvious that I'm doing wrong here?
------------------------------
Amy Vozza
------------------------------
Original Message:
Sent: Sat August 20, 2022 09:52 PM
From: Amy Vozza
Subject: SQL Stored Procedure Accepting JSON Data
Thanks for your help. I'll try that.
------------------------------
Amy Vozza
Original Message:
Sent: Sat August 20, 2022 08:30 PM
From: Satid Singkorapoom
Subject: SQL Stored Procedure Accepting JSON Data
Dear Amy
You should try providing a character string value for the 2nd parameter to see if it works or not. If so, this is what is called implicit casting (automatic data type conversion) for SQL data types. I found that DB2 can "promote" CHAR to CLOB data type : https://www.ibm.com/docs/en/i/7.2?topic=elements-promotion-data-types. But if the call fails, then please try explicit casting by using CLOB( <character string> ) function with the 2nd parameter to see if this works or not.
------------------------------
Right action is better than knowledge; but in order to do what is right, we must know what is right.
-- Charlemagne
Satid Singkorapoom
Original Message:
Sent: Fri August 19, 2022 04:47 PM
From: Amy Vozza
Subject: SQL Stored Procedure Accepting JSON Data
I'm creating an SQL stored procedure that accepts 3 parameters: input character, input CLOB for JSON record, and input/output integer. What is the correct way to call that in Run SQL Scripts?
------------------------------
Amy Vozza
------------------------------
#SQL