error during insertion in mysql if empty string fields in struct
-
anuragkumar5 years ago #16509
Hi @chris,
I am using below insert query in my connector:
INSERT INTO person (name, age,graduatedOn,birth_date_time,isAlive)
VALUES (:name:, :age:Integer:, :graduatedOn:Date:,:birth_date_time:Date:, :isAlive:);Here, I am passing value from a struct having all string fields.
There is no problem, when I have set all the fields in the struct and none is empty. Insert query runs fine then.
Problem is in below conditions:
1) when age is empty, then I get below error:
{
“message”: “Invalid payload for connector type SQL: Parameter age had invalid format: JSON Literal for type Integer malformed”,
“success”: false
}2) When age is filled, then I get error for the date field ‘graduatedOn’, error is below:
{
“message”: “Data truncation: Incorrect date value: ” for column ‘graduatedOn’ at row 1″,
“success”: false
}Please find below the table description attached
How can I deal with this situation, as I can have empty fields in my struct if user has not entered any value for it. I think the problem is mainly for Int, Date, Datetime, boolean fields in db.
I even tried using a domain type for nullable string (that I created) for these Date, int, DateTime and Boolean db fields.
Regards
Anurag
Attachments:
You must be logged in to view attached files.Christian KleinschrothHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (310)Has successfully completed the online course Advanced (320)Has successfully completed the Intermediate CertificationHas successfully completed the Advanced Certification5 years ago #16512::Hello,
make sure you are using inhered domain data types with the nullable flag and Strings as validation for date field parameters
For more details refer to:
https://community.simplifier.io/forum/topic/date-int-and-boolean-null-setting-in-db/#post-16511
You must be logged in to reply to this topic.