Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGawb-0004GS-LD for pgsql-sql@arkaria.postgresql.org; Fri, 02 Jun 2017 01:00:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dGawa-0007dw-PY for pgsql-sql@arkaria.postgresql.org; Fri, 02 Jun 2017 01:00:00 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dGawX-0007ax-K3 for pgsql-sql@postgresql.org; Fri, 02 Jun 2017 00:59:57 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dGawU-0002NU-AR for pgsql-sql@postgresql.org; Fri, 02 Jun 2017 00:59:56 +0000 Received: by mail-pf0-x244.google.com with SMTP id u26so9939519pfd.2 for ; Thu, 01 Jun 2017 17:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=XFxHzqkJDfRGykItK0q4OlaHocNt6K+3qqY2GwAgl/g=; b=R2nYx39/hvWHGdMJMItCxOhm5MgKi4N7mnPVjWPxxW/wHRLjpxW7I5pw8rB7KLBAQU F0L5O24gv+tJWNcFyOzlPOmj1z7zQ0ILClAM0fXGmngvwbGJCb59HSs1HjBSQFdLgX3H yj7ubOTOyeIrxLxRhJMHZnDoAkrV2dqZ8FWi/kcB0XrB2NSlxd0Fe8ot8JBun2e1a6O4 XGxoxMRkEMH4owVOLo0dNv8qRim8wlszdqVvLvgUnqMo3HOhpPGOIzFIdVQY/B6AyTYn uHjJXtXbTGO0BAZDAGPvqj/MHCfTv8mjSLicX3jxL68EZsDB8laOP3S3zB08H/t07EGU cV1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=XFxHzqkJDfRGykItK0q4OlaHocNt6K+3qqY2GwAgl/g=; b=fuyOiod+r0UhRytgFswF7VRApv+RD+vf9MnjUWLOiWmpHSLS/Fz0BqfBeyU6PWOvO9 CM5UHaITtFJOVqTuoII+rzuSWbfWGdzxrfMHVTxKcbrWmloVnueSwNO40LCwrgpp+28C XPmguMTS+VY4xDciRmTnpcuOArLF64dHz7RtCx/+0cK1c0MZbWzEDa2SbeFV40KqvWpB rY867/gL9HKxife901WjczsmCmHF90MocesCsePilJ+PfJGyriZ60GYVhJuJNypbbwHD +I+2JiNQvsqr4H90ix8n7Oiv8e9+/HbZ+C5WIrLyBtGmAUhZILaO0GZjCqlr/dXTJYsx bAuw== X-Gm-Message-State: AODbwcB2VJdbtLhs10zCJPsmsIH8PHmPGka3aObVXi/V+xgUpoQkkXDi yclTkq4IetHI6hr3sQ4= X-Received: by 10.98.58.195 with SMTP id v64mr3891366pfj.237.1496365192738; Thu, 01 Jun 2017 17:59:52 -0700 (PDT) Received: from ?IPv6:2601:681:4600:7028:194e:c331:84c4:d7a2? ([2601:681:4600:7028:194e:c331:84c4:d7a2]) by smtp.gmail.com with ESMTPSA id f72sm36900039pff.78.2017.06.01.17.59.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 17:59:51 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: Using bind variable within BEGIN END From: Rob Sargent X-Mailer: iPhone Mail (14F89) In-Reply-To: <1496363048908-5964384.post@n3.nabble.com> Date: Thu, 1 Jun 2017 18:59:50 -0600 Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <1496363048908-5964384.post@n3.nabble.com> To: anand086 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org I think you'll need to show your code not the error. Postgres version is a = good idea. What application stack are you using or is this raw jdbc? > On Jun 1, 2017, at 6:24 PM, anand086 wrote: >=20 > Hi, >=20 > I am quite new to postgresql and working with application team to migrate= to > postgresql from oracle. >=20 > When we are trying to use bind variable within BEGIN/END code block, it > fails with >=20 > 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 INS= ERT > 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 =3D > t.from_entity_id) LEFT OUTER JOIN relates as r ON ( s.transfer_to_id =3D > r.target_entity_id AND r.relation_type_id =3D ? ) LEFT OUTER JOIN attribu= tes > as a ON ( r.source_entity_id =3D a.entity_id AND a.attribute_type_id =3D = ? ) > WHERE a.attribute_value::numeric <=3D 10 OR a.attribute_value::numeric = =3D 99 ) > ON CONFLICT(from_entity_id) DO UPDATE SET transfer_to_id =3D > excluded.source_entity_id;GET DIAGNOSTICS rowcount =3D ROW_COUNT; EXIT WH= EN > rowcount =3D 0; END LOOP ; END $do$; Parameters: [3, 367] >=20 >=20 > Received the same error while calling a function within BEGIN END code. >=20 > What is the correct way to use bind variables in postgresql?=20 >=20 >=20 >=20 >=20 >=20 >=20 > -- > View this message in context: http://www.postgresql-archive.org/Using-bin= d-variable-within-BEGIN-END-tp5964384.html > Sent from the PostgreSQL - sql mailing list archive at Nabble.com. >=20 >=20 > --=20 > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql --=20 Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql