Обсуждение: Error in PlPython procedure
Hi All, I am using PlPython procedure to insert data in a table: plan = plpy.execute("insert into test(id,name) values(1 , 'test_py')") I am getting error: ERROR: invalid input syntax for integer: "<PLyResult object at 0x374a5a70>" In fact preparing a plan and passing a list of values for columns is also giving same error. What is correct valid input syntax for integer in PlPython? Mars_osrp -- View this message in context: http://www.nabble.com/Error-in-PlPython-procedure-tp15601869p15601869.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
mars_osrp wrote: > Hi All, > > I am using PlPython procedure to insert data in a table: > > plan = plpy.execute("insert into test(id,name) values(1 , 'test_py')") > > I am getting error: > ERROR: invalid input syntax for integer: "<PLyResult object at 0x374a5a70>" > > In fact preparing a plan and passing a list of values for columns is also > giving same error. > > What is correct valid input syntax for integer in PlPython? > Shouldn't that be "plpy.prepare(...)" instead of the execute() method? I think what you want is: plan = plpy.prepare("INSERT INTO test (id, name) VALUES ($1, $2)", ["integer", "text"]) res = plpy.execute(plan, [1, "test_py"]) Or something like that. pl/Python error messages are definitely pretty cryptic, though. b
On Feb 20, 2008, at 5:53 PM, mars_osrp wrote: > > Hi All, > > I am using PlPython procedure to insert data in a table: > > plan = plpy.execute("insert into test(id,name) values(1 , 'test_py')") > > I am getting error: > ERROR: invalid input syntax for integer: "<PLyResult object at > 0x374a5a70>" > > In fact preparing a plan and passing a list of values for columns > is also > giving same error. > > What is correct valid input syntax for integer in PlPython? Can you show us the function you're using and how you're using it? I don't see anything wrong with that on its own. You're error refers to using a PyResult object somewhere and integer is expected -- plpy.execute() returns PyResult objects -- not integers -- so that looks good. My guess is you're expecting to be able to use the return value of plpy.execute() directly, i.e I think your query is running fine, it's how you're accessing the result that is the problem. Erik Jones DBA | Emma® erik@myemma.com 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com