Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » postgresql calling a function on delete
icon4.gif  postgresql calling a function on delete [message #1114098] Sun, 22 September 2013 02:45 Go to next message
Omid Pourhadi is currently offline Omid Pourhadi
Messages: 13
Registered: May 2013
Junior Member
Hi,

I created a function in postgresql and I want to run it when an entity is being deleted. I have to use customizer.

@Override
    public void customize(ClassDescriptor descriptor) throws Exception
    {
        descriptor.getQueryManager().setDeleteSQLString("select delete_recursive(#ID)");
    }


but when I execute this I get follow exception :

A result was returned when none was expected


my function is

CREATE OR REPLACE FUNCTION delete_recursive(docid bigint)
  RETURNS void AS


as you can see function output is VOID I think it's because the way of calling functions in postgresql which starts with select

how can i overcome this issue ?

is this a bug ?
Re: postgresql calling a function on delete [message #1114964 is a reply to message #1114098] Mon, 23 September 2013 09:26 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1017
Registered: July 2009
Senior Member
You are specifying an SQL string which EclipseLink then tries to execute, which isn't the correct way of executing a stored procedure on Postgres. You should create a StoredProcedureCall, which EclipseLink will then form into SQL for the Postgres database if the app is configured to use the PostgreSQLPlatform:
http://wiki.eclipse.org/EclipseLink/Examples/JPA/CRUDStoredProcedures has an example.

Best Regards,
Chris
Re: postgresql calling a function on delete [message #1119158 is a reply to message #1114964] Sat, 28 September 2013 01:33 Go to previous messageGo to next message
Omid Pourhadi is currently offline Omid Pourhadi
Messages: 13
Registered: May 2013
Junior Member
Thank you Chris,

But How can I pass dynamic argument value to StoredProcedureCall query ?

the given example uses static parameter value.

call.addArgument("P_F_NAME", ?);
Re: postgresql calling a function on delete [message #1121396 is a reply to message #1119158] Mon, 30 September 2013 11:25 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1017
Registered: July 2009
Senior Member
The example did not show static values - it was defining which fields the parameter value would correspond to. The values get pulled from the objects used in the CRUD operations. So
call.addArgument("P_EMP_ID", "EMP_ID") causes the "P_EMP_ID" call parameter to get passed the value from the "EMP_ID" mapping within the entity.

Best Regards,
Chris
Previous Topic:How to use Moxy
Next Topic:EclipseLink Bug in DatabaseQuery.checkPrepare
Goto Forum:
  


Current Time: Sat Aug 23 09:36:42 EDT 2014

Powered by FUDForum. Page generated in 0.02602 seconds