I'm facing an error when inserting a JSON object into a VARIANT
data type column, from within a stored procedure in Snowflake.
Below is the reference code:
create or replace procedure test1234()
returns varchar not null
language javascript
as
$$
var birthDateVar = 'BIRTH_DATE';
var genderVar = 'GENDER';
var countryVar = 'COUNTRY';
var loanVar = 'LOAN_AMOUNT';
var emailVar = 'EMAIL';
var tableName = 'SF_STRUCT_STAGE_RAW';
var UPDATE_DATE = "2019-01-01";
var email = "[email protected]";
var row_num = "1";
var person_id = "1";
var EMAILERROR = {
"row_num": row_num,
"person_id": person_id,
"tableName": tableName,
"fieldName": emailVar,
"fieldValue": email,
"errorDesc": 'value is invalid email'
};
var cmd = "insert into error_details_log values(:1,:2);";
var stmt = snowflake.createStatement(
{
sqlText: cmd,
binds: [EMAILERROR, UPDATE_DATE]
}
);
stmt.execute();
return emailError;
$$;