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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

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

sbt
15-Moonstone
15-Moonstone

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
15-Moonstone
15-Moonstone
(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
15-Moonstone
15-Moonstone
(To:supandey)

Its PostgreSQL.

sbt
15-Moonstone
15-Moonstone
(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?

Announcements


Top Tags