Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecD2J-000095-1G for pgsql-general@arkaria.postgresql.org; Thu, 18 Jan 2018 16:27:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecD2I-0006FN-Kq for pgsql-general@arkaria.postgresql.org; Thu, 18 Jan 2018 16:27:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ecD2I-00068T-CB for pgsql-general@lists.postgresql.org; Thu, 18 Jan 2018 16:27:30 +0000 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ecD2E-0000Fr-DN for pgsql-general@postgresql.org; Thu, 18 Jan 2018 16:27:29 +0000 Received: by mail-pf0-x22c.google.com with SMTP id b25so8706834pfd.9 for ; Thu, 18 Jan 2018 08:27:25 -0800 (PST) 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=MrTZKdAmPvwZz7cg5oIQQBqrHWK6Wy/qokPolmvnt50=; b=fGaALq+KMpAhUcqqO0uEe+lgNOAef3iH82HLB3AoTG9ejGDcFUlZ5ryzViBLAjYTxq RPaCassA6/ey14jf+ZQ/xFKJFikzcLiHDdatTnowBylnv+aF1WtKPXMSt5pyIOEVA/Kz VA3qpLpaqH3UuV3j4ippCm/f1NgQRiam/MxG6MgWd/bXnjMpU8mY6hMSzgvb4Sg1ZPe1 TiRNo9fAJr0Yi058T1mrDvtkvMxw+lneCy1We7TM8pfkSFBaqdIgdaEbQ/dig84Ozxmj nBvkv3b71lAzSJHdUNKHspdf8vvAgXiRw5ODqsRjGxRQ80lnMJg6bli2MG/eks0p0USI qgRg== 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=MrTZKdAmPvwZz7cg5oIQQBqrHWK6Wy/qokPolmvnt50=; b=SmV1s5bb/RaiPQx2DjJ7EVoER9m29LukvpgSXhihWNg4RoCXhiKCtTRXvPACjS88wq 9NAgQvRSjR/8UpjHfG1kvXL0Qn2cIuuJbWMJafL7UMyThzI5VKzC8rNmp/sEzXRvAqEL 8AYJSjmwDJ4QRYtBwZqh0Meu5Kq73sggz5sDBT4I94UNP4s7LePAU7/XXPHQsZGkiKYV Uefi6E5KbgMN1eUW6yPIUzKhihMbDZ299m/s2JO1nqtceN7qDz2hbOfmfd71F1SfpK8B w4U4HFd5iosG1/qVYZpTGSEHZUbA9q3Bvi6obgQp4C6jo4ASWkQfoe5BmDgGrzWoR8m7 kvIA== X-Gm-Message-State: AKwxytckm3UZYb0KFsg4HjHPH43O+rGKv88j12rnvbtgRGaMiftN/Bgq WDAAXXqYSGMitBMo1dZhoBM= X-Google-Smtp-Source: ACJfBot9LHv5wjxbrMmoQfzbsk/F3C6mFQn8rCByuWSZinVKPBNAhxlQH6khVB/f4YKdJmBWkPAScw== X-Received: by 10.99.125.74 with SMTP id m10mr22902498pgn.354.1516292843590; Thu, 18 Jan 2018 08:27:23 -0800 (PST) Received: from kitselas.hci.utah.edu ([155.100.47.7]) by smtp.gmail.com with ESMTPSA id w12sm7397031pfd.86.2018.01.18.08.27.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 08:27:22 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: Call sql function in psql From: Rob Sargent In-Reply-To: Date: Thu, 18 Jan 2018 09:27:21 -0700 Cc: "pgsql-general@postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <88C8D539-67F2-472C-AA5F-5F6F274DBA84@gmail.com> References: To: Abhra Kar X-Mailer: Apple Mail (2.3273) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Jan 18, 2018, at 9:22 AM, Abhra Kar wrote: >=20 > Hi All, >=20 > Please send me some info how to post directly in mailing = list,somwhow I am not able to find out the way so I am mailing here. >=20 >=20 Here is fine >=20 > Present problem--=20 >=20 >=20 >=20 > I tried to change below code in psql =E2=80=94 >=20 > =20 > Session sess =3D (Session) entityManager.getDelegate(); >=20 > sess.createSQLQuery("{ call reset_all() }").executeUpdate(); >=20 > =20 > Here 'sess' is org.hibernate.Session and reset_all() is a function = which contains=E2=80=94 >=20 > =20 > DECLARE >=20 > username varchar(30); >=20 > BEGIN >=20 > select user into username; >=20 > if username like 'XXXXX%' then >=20 > update YYYYY set aaaa =3D 0; >=20 > update ZZZZ set bbbb=3D 0; >=20 > EXECUTE('truncate table abc'); >=20 > EXECUTE('truncate table def'); >=20 > :::::::::::::::::::::::::::::::::::::::::::::::: >=20 > else >=20 > RAISE NOTICE 'User not allowed to run this procedure'; >=20 > end if; >=20 > end; >=20 > =20 > I tried to modify like >=20 > =20 > sess.createSQLQuery("select reset_all()").executeUpdate(); >=20 > =20 > getting error -- org.postgresql.util.PSQLException: A result was = returned when none was expected. >=20 > =20 > What should be the syntax of calling reset_all(). >=20 >=20 >=20 > Thanks and Regards, >=20 > Abhra >=20 >=20 >=20 At the very least change =E2=80=98call=E2=80=99 to =E2=80=98select=E2=80=99= . Are those braces (=E2=80=9C{}=E2=80=9D) truly necessary? (Been a = while since I=E2=80=99ve user hibernate).=20