pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: Abhra Kar <abhra.kar@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Call sql function in psql
Date: Thu, 18 Jan 2018 09:27:21 -0700
Message-ID: <88C8D539-67F2-472C-AA5F-5F6F274DBA84@gmail.com> (raw)
In-Reply-To: <CAFNULEcr1uQfUuAw4jzBojUz-Ur58YZKQiy0fJOJMqypS6kGTA@mail.gmail.com>
References: <CAFNULEcr1uQfUuAw4jzBojUz-Ur58YZKQiy0fJOJMqypS6kGTA@mail.gmail.com>


> On Jan 18, 2018, at 9:22 AM, Abhra Kar <abhra.kar@gmail.com> wrote:
> 
> Hi All,
> 
>               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.
> 
> 
Here is fine

> 
> Present problem-- 
> 
> 
> 
>               I tried to change below code in psql —
> 
>  
> Session sess = (Session) entityManager.getDelegate();
> 
>  sess.createSQLQuery("{ call reset_all() }").executeUpdate();
> 
>  
> Here 'sess' is  org.hibernate.Session and reset_all() is a function which contains—
> 
>  
> DECLARE
> 
> username varchar(30);
> 
> BEGIN
> 
> select user into username;
> 
> if username like 'XXXXX%' then
> 
> update YYYYY set aaaa = 0;
> 
> update ZZZZ set bbbb= 0;
> 
> EXECUTE('truncate table abc');
> 
> EXECUTE('truncate table def');
> 
> ::::::::::::::::::::::::::::::::::::::::::::::::
> 
> else
> 
> RAISE NOTICE 'User not allowed to run this procedure';
> 
> end if;
> 
> end;
> 
>  
> I tried to modify like
> 
>  
>         sess.createSQLQuery("select reset_all()").executeUpdate();
> 
>  
> getting error -- org.postgresql.util.PSQLException: A result was returned when none was expected.
> 
>  
> What should be the syntax of calling reset_all().
> 
> 
> 
> Thanks and Regards,
> 
> Abhra
> 
> 
> 
At the very least change ‘call’ to ‘select’.  Are those braces (“{}”) truly necessary? (Been a while since I’ve user hibernate). 





view thread (4+ messages)  latest in thread

Message-ID: <88C8D539-67F2-472C-AA5F-5F6F274DBA84@gmail.com>
Permalink:  ../88C8D539-67F2-472C-AA5F-5F6F274DBA84@gmail.com/
Also on:    postgresql.org/message-id/88C8D539-67F2-472C-AA5F-5F6F274DBA84@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: robjsargent@gmail.com, abhra.kar@gmail.com
  Subject: Re: Call sql function in psql
  In-Reply-To: <88C8D539-67F2-472C-AA5F-5F6F274DBA84@gmail.com>
  References: <CAFNULEcr1uQfUuAw4jzBojUz-Ur58YZKQiy0fJOJMqypS6kGTA@mail.gmail.com> <88C8D539-67F2-472C-AA5F-5F6F274DBA84@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox