Skip to main content


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 06:45 Go to next message
Omid Pourhadi is currently offline Omid PourhadiFriend
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 13:26 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
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 05:33 Go to previous messageGo to next message
Omid Pourhadi is currently offline Omid PourhadiFriend
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 15:25 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
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 Apr 27 04:37:55 GMT 2024

Powered by FUDForum. Page generated in 0.02910 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top