[SQL] Using bind variable within BEGIN END - Mailing list pgsql-sql

From anand086
Subject [SQL] Using bind variable within BEGIN END
Date
Msg-id 1496363048908-5964384.post@n3.nabble.com
Whole thread Raw
Responses Re: [SQL] Using bind variable within BEGIN END  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: [SQL] Using bind variable within BEGIN END  (Rob Sargent <robjsargent@gmail.com>)
Re: [SQL] Using bind variable within BEGIN END  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-sql
Hi,

I am quite new to postgresql and working with application team to migrate to
postgresql from oracle.

When we are trying to use bind variable within BEGIN/END code block, it
fails with

Caused by: java.sql.SQLException: The column index is out of range: 1,
number of columns: 0. Query: DO $do$ DECLARE rowcount int; BEGIN LOOP INSERT
INTO temp_resolution ( SELECT s.from_entity_id,r.source_entity_id FROM
temp_resolution as s JOIN temp_resolution as t ON (s.transfer_to_id =
t.from_entity_id) LEFT OUTER JOIN relates as r ON ( s.transfer_to_id =
r.target_entity_id AND r.relation_type_id = ? ) LEFT OUTER JOIN attributes
as a ON ( r.source_entity_id = a.entity_id AND a.attribute_type_id = ? )
WHERE a.attribute_value::numeric <= 10 OR a.attribute_value::numeric = 99 )
ON CONFLICT(from_entity_id) DO UPDATE SET transfer_to_id =
excluded.source_entity_id;GET DIAGNOSTICS rowcount = ROW_COUNT; EXIT WHEN
rowcount = 0; END LOOP ; END $do$; Parameters: [3, 367]


Received the same error while calling a function within BEGIN END code.

What is the correct way to use bind variables in postgresql? 






--
View this message in context: http://www.postgresql-archive.org/Using-bind-variable-within-BEGIN-END-tp5964384.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.



pgsql-sql by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: YNT: Re: [SQL] Can the result sets produced in SQL procedures beleft open for the use of the calling program?
Next
From: "David G. Johnston"
Date:
Subject: Re: [SQL] Using bind variable within BEGIN END