cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Getting error "org.json.JSONObject cannot be cast to java.lang.String" while inserting into postgreSQL using json_populate_record function

sbt
13-Aquamarine
13-Aquamarine

Getting error "org.json.JSONObject cannot be cast to java.lang.String" while inserting into postgreSQL using json_populate_record function

Hello ,

I am getting error "org.json.JSONObject cannot be cast to java.lang.String" when i run the service.

input given = {"formulaexp":"(2*3)","outputtag":"test","displayunit":"testunit","attributearray":"{abc,efg,hij}"}

but the same input works when i execute in query analyser

Thanks

Sunay

6 REPLIES 6
supandey
19-Tanzanite
(To:sbt)

Sunay, have you tried replacing the [[...]] with <<...>>> ?

sbt
13-Aquamarine
13-Aquamarine
(To:supandey)

sushant,

Yes but get the below error

Error executing service

Unable to Invoke Service TestInsertExpression on AlgorithmConfigratorDB : ERROR: syntax error at or near "{" Position: 185

Script

insert into Formula_Template(FormulaExp,OutputTag,DisplayUnit,AttributeArray)

select FormulaExp,OutputTag,DisplayUnit,AttributeArray from json_populate_record(null::Formula_Template, <<inputJSON>>)

Thanks

Sunay

supandey
19-Tanzanite
(To:sbt)

Against which database are you running this query? Just want to recheck the syntax of SQL you have there, from the screenshot above it looks like PostgerSQL, but could you please confirm.

sbt
13-Aquamarine
13-Aquamarine
(To:supandey)

Its PostgreSQL.

sbt
13-Aquamarine
13-Aquamarine
(To:supandey)

Sushanth,

any suggestion on what i am missing in the syntax..?

Thanks

Sunay

supandey
19-Tanzanite
(To:sbt)

one more question have you tested with INPUT parameter of type String instead of JSON?

Top Tags