Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
A1991
Contributor
Contributor

Update JSON field type column from talend

Hi,

I have an update query same as given below. I have a field in DB with JSON datatype. I want to use this query to update the JSON type column in DB. Whole data which is between single quotes(mentioned in bold) should be inserted into DB. Target DB is postgre.

UPDATE table_name SET field_name = '{

    "@FILE": "csv",

    "Details": [

      "FName",

      "LName",

      "city",

      "contact",

      "DOB"

    ],

    "Indicator": false,

    "delimiter": ",",

    "ignore_header": true,

    "permission": false,

    "lines": 0

  }'  WHERE id =10

I am using tdbrow component to update the data in DB and using the above query as it is in the query box with double quotes , but my job is throwing exception. please check attached screenshot.

Any other method to achieve it?

Labels (3)
3 Replies
gjeremy1617088143
Creator III
Creator III

Hi @Anjali Yadav​ , it's because the query you use was hardwritten directly in the code as a String , so when it encounter the first doble quote it crash you have to escape all doble quote.

\\" or \" (i don't remember exactly for query) instead of " except for the one wich enclosed your query

after go to the line of code were your error have been throw and see if your query is read as a unique string

Send me Love and Kudos

A1991
Contributor
Contributor
Author

You are right gjeremy. Issue occured because of special characters in query. I need the query's data as it is in DB So I handled it in different and easy way. I created a context variable with string datatype and placed the whole query in​ value. Then I passed the context variable in db component. By this way I am able to update data for json field in DB.

gjeremy1617088143
Creator III
Creator III

I'm Happy you succeed !

If one of my answer set you to the right path please select it as best answer.