Обсуждение: stored procedure call is not working with "select procedure()" option

Поиск
Список
Период
Сортировка

stored procedure call is not working with "select procedure()" option

От
Abhra Kar
Дата:
Hi , 
         I have a stored procedure name "procedure()". Which I am calling by -- 

Session sess = (Session)entityManager.getDelegate(); //entityManager is javax.persistent.EntityManager[ Properly Initialise]
              sess.createSQLQuery("select procedure()");

procedure is containing some truncate queries like --  EXECUTE('truncate table abc');

It's not throwing any exception but not executing the procedure.Using oracle query -- sess.createSQLQuery("{ call procedure() }").executeUpdate();   procedure execution is working fine.

What's need to be change here.

Thanks and Regards,
Abhra

Re: stored procedure call is not working with "select procedure()"option

От
Adrian Klaver
Дата:
On 02/19/2018 11:13 PM, Abhra Kar wrote:
> Hi ,
>           I have a stored procedure name "procedure()". Which I am 
> calling by --
> 
> Session sess = (Session)entityManager.getDelegate(); //entityManager is 
> javax.persistent.EntityManager[ Properly Initialise]
>                sess.createSQLQuery("select procedure()");
> 
> procedure is containing some truncate queries like -- EXECUTE('truncate 
> table abc');
> 
> It's not throwing any exception but not executing the procedure.Using 
> oracle query -- sess.createSQLQuery("{ call procedure() 
> }").executeUpdate();   procedure execution is working fine.
> 
> What's need to be change here.

More information would help:

1) Postgres version.

2) JDBC driver and version?

3) Any relevant information from the Postgres logs.

The forthcoming Postgres version 11 will have stored procedures, but at 
the moment Postgres has only stored functions.

> 
> Thanks and Regards,
> Abhra


-- 
Adrian Klaver
adrian.klaver@aklaver.com


Re: stored procedure call is not working with "select procedure()"option

От
Adrian Klaver
Дата:
On 02/20/2018 07:35 AM, Abhra Kar wrote:

Please also reply to list so more people can see and answer.
Ccing list
> 
> 
> On Tue, Feb 20, 2018 at 8:46 PM, Adrian Klaver 
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:
> 
>     On 02/19/2018 11:13 PM, Abhra Kar wrote:
> 
>         Hi ,
>                    I have a stored procedure name "procedure()". Which I
>         am calling by --
> 
>         Session sess = (Session)entityManager.getDelegate();
>         //entityManager is javax.persistent.EntityManager[ Properly
>         Initialise]
>                         sess.createSQLQuery("select procedure()");
> 
>         procedure is containing some truncate queries like --
>         EXECUTE('truncate table abc');
> 
>         It's not throwing any exception but not executing the
>         procedure.Using oracle query -- sess.createSQLQuery("{ call
>         procedure() }").executeUpdate();   procedure execution is
>         working fine.
> 
>         What's need to be change here.
> 
> 
>     More information would help:
> 
>     1) Postgres version.
> 
>     2) JDBC driver and version?
> 
>     3) Any relevant information from the Postgres logs.
> 
>     The forthcoming Postgres version 11 will have stored procedures, but
>     at the moment Postgres has only stored functions.
> 

> 
> Postgres Version -- 9.5
> 
> JDBC Driver - org.postgresql.Driver
> 
> JDVC driver version and relavant postgres logs didn't get.
> 
> Regards,
> Abhra


-- 
Adrian Klaver
adrian.klaver@aklaver.com


Re: stored procedure call is not working with "select procedure()" option

От
Abhra Kar
Дата:


On Tue, Feb 20, 2018 at 9:21 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 02/20/2018 07:35 AM, Abhra Kar wrote:

Please also reply to list so more people can see and answer.
Ccing list


On Tue, Feb 20, 2018 at 8:46 PM, Adrian Klaver <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:

    On 02/19/2018 11:13 PM, Abhra Kar wrote:

        Hi ,
                   I have a stored procedure name "procedure()". Which I
        am calling by --

        Session sess = (Session)entityManager.getDelegate();
        //entityManager is javax.persistent.EntityManager[ Properly
        Initialise]
                        sess.createSQLQuery("select procedure()");

        procedure is containing some truncate queries like --
        EXECUTE('truncate table abc');

        It's not throwing any exception but not executing the
        procedure.Using oracle query -- sess.createSQLQuery("{ call
        procedure() }").executeUpdate();   procedure execution is
        working fine.

        What's need to be change here.


    More information would help:

    1) Postgres version.

    2) JDBC driver and version?

    3) Any relevant information from the Postgres logs.

    The forthcoming Postgres version 11 will have stored procedures, but
    at the moment Postgres has only stored functions.



Postgres Version -- 9.5

JDBC Driver - org.postgresql.Driver

JDVC driver version and relavant postgres logs didn't get.

Regards,
Abhra


--
Adrian Klaver
adrian.klaver@aklaver.com


Please provide me the list email.I don't know about it.

Thanks

Re: stored procedure call is not working with "select procedure()"option

От
Adrian Klaver
Дата:
On 02/20/2018 08:17 AM, Abhra Kar wrote:
> 
> 
> On Tue, Feb 20, 2018 at 9:21 PM, Adrian Klaver 
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:

> 
> 
> Please provide me the list email.I don't know about it.

The list email is the one you used already:

pgsql-general@postgresql.org

I suspect the problem is that when you replied to my first post you did 
Reply not Reply All. This picked up my email, but not the list email.

> 
> Thanks


-- 
Adrian Klaver
adrian.klaver@aklaver.com


Re: stored procedure call is not working with "select procedure()" option

От
Abhra Kar
Дата:


On Tue, Feb 20, 2018 at 9:52 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 02/20/2018 08:17 AM, Abhra Kar wrote:


On Tue, Feb 20, 2018 at 9:21 PM, Adrian Klaver <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:



Please provide me the list email.I don't know about it.

The list email is the one you used already:

pgsql-general@postgresql.org

I suspect the problem is that when you replied to my first post you did Reply not Reply All. This picked up my email, but not the list email.


Thanks


--
Adrian Klaver
adrian.klaver@aklaver.com


Postgres Version -- 9.5

JDBC Driver - org.postgresql.Driver

JDVC driver version and relavant postgres logs didn't get.

Regards,
Abhra

Re: stored procedure call is not working with "select procedure()"option

От
Alban Hertroys
Дата:
> On 20 Feb 2018, at 8:13, Abhra Kar <abhra.kar@gmail.com> wrote:
>
> Hi ,
>          I have a stored procedure name "procedure()". Which I am calling by --
>
> Session sess = (Session)entityManager.getDelegate(); //entityManager is javax.persistent.EntityManager[ Properly
Initialise]
>               sess.createSQLQuery("select procedure()");

…

> It's not throwing any exception but not executing the procedure.Using oracle query -- sess.createSQLQuery("{ call
procedure()}").executeUpdate();   procedure execution is working fine. 

Seems to me you are forgetting to execute the query, like in your Oracle example. IIRC, calling execute() is how to
executea statement that returns a ResultSet in Java. 

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.



Re: stored procedure call is not working with "select procedure()" option

От
Abhra Kar
Дата:


On Tue, Feb 20, 2018 at 10:45 PM, Alban Hertroys <haramrae@gmail.com> wrote:

> On 20 Feb 2018, at 8:13, Abhra Kar <abhra.kar@gmail.com> wrote:
>
> Hi ,
>          I have a stored procedure name "procedure()". Which I am calling by --
>
> Session sess = (Session)entityManager.getDelegate(); //entityManager is javax.persistent.EntityManager[ Properly Initialise]
>               sess.createSQLQuery("select procedure()");



> It's not throwing any exception but not executing the procedure.Using oracle query -- sess.createSQLQuery("{ call procedure() }").executeUpdate();   procedure execution is working fine.

Seems to me you are forgetting to execute the query, like in your Oracle example. IIRC, calling execute() is how to execute a statement that returns a ResultSet in Java.

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.


So What should be the query --- 
sess.createSQLQuery("select procedure()").execute();

Something like this? 

Thanks 
Abhra