Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 617761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:28:15+00:00 2026-05-13T18:28:15+00:00

I am porting an Oracle function into Postgres PGPLSQL.. I have been using this

  • 0

I am porting an Oracle function into Postgres PGPLSQL.. I have been using this guide: http://www.postgresql.org/docs/8.1/static/plpgsql.html

CREATE OR REPLACE PROCEDURE DATA_UPDATE
  (mission  NUMBER,
   task     NUMBER)
AS
BEGIN
IF mission IS NOT NULL THEN
  UPDATE MISSION_OBJECTIVE MO
     SET (MO.MO_TKR_TOTAL_OFF_SCHEDULED,
          MO.MO_TKR_TOTAL_RECEIVERS) =
           (SELECT NVL(SUM(RR.TRQ_FUEL_OFFLOAD),0),
                   NVL(SUM(RR.TRQ_NUMBER_RECEIVERS),0)
              FROM REFUELING_REQUEST RR, MISSION_REQUEST_PAIRING MRP
             WHERE MO.MSN_INT_ID = MRP.MSN_INT_ID
               AND MO.MO_INT_ID = MRP.MO_INT_ID
               AND MRP.REQ_INT_ID = RR.REQ_INT_ID)
   WHERE MO.MSN_INT_ID = mission
     AND MO.MO_INT_ID = task ;
END IF ;
COMMIT ;
END ;

I’ve got it this far:

CREATE OR REPLACE FUNCTION DATA_UPDATE
  (NUMERIC,
   NUMERIC)
   RETURNS integer as '
   DECLARE
   mission ALIAS for $1;
   task ALIAS for $2;
BEGIN
IF mission IS NOT NULL THEN
  UPDATE MISSION_OBJECTIVE MO
     SET (MO.MO_TKR_TOTAL_OFF_SCHEDULED,
          MO.MO_TKR_TOTAL_RECEIVERS) =
           (SELECT COALESCE(SUM(RR.TRQ_FUEL_OFFLOAD),0),
                   COALESCE(SUM(RR.TRQ_NUMBER_RECEIVERS),0)
              FROM REFUELING_REQUEST RR, MISSION_REQUEST_PAIRING MRP
             WHERE MO.MSN_INT_ID = MRP.MSN_INT_ID
               AND MO.MO_INT_ID = MRP.MO_INT_ID
               AND MRP.REQ_INT_ID = RR.REQ_INT_ID)
   WHERE MO.MSN_INT_ID = mission
     AND MO.MO_INT_ID = task ;
END IF;
COMMIT;
END;
' LANGUAGE plpgsql;

This is the error I get:

ERROR:  syntax error at or near "SELECT"
LINE 1: ...OTAL_OFF_SCHEDULED, MO.MO_TKR_TOTAL_RECEIVERS) = (SELECT COA...

I do not know why this isn’t working… any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:28:16+00:00Added an answer on May 13, 2026 at 6:28 pm

    I don’t think Postgres supports that update construct (the simple test I tried fails with the same error). You might have to do something like this:

    CREATE OR REPLACE FUNCTION DATA_UPDATE
      (mission NUMERIC,
       task NUMERIC)
       RETURNS void as '
    DECLARE
       offScheduled int4;
       totalReceivers int4; 
    BEGIN
    IF mission IS NOT NULL THEN
      select COALESCE(SUM(RR.TRQ_FUEL_OFFLOAD),0),
      COALESCE(SUM(RR.TRQ_NUMBER_RECEIVERS),0) into offScheduled, totalReceivers 
      FROM REFUELING_REQUEST RR, MISSION_REQUEST_PAIRING MRP
                 WHERE MO.MSN_INT_ID = MRP.MSN_INT_ID
                   AND MO.MO_INT_ID = MRP.MO_INT_ID
                   AND MRP.REQ_INT_ID = RR.REQ_INT_ID;
    
     UPDATE MISSION_OBJECTIVE MO
         SET MO.MO_TKR_TOTAL_OFF_SCHEDULED = offScheduled,
              MO.MO_TKR_TOTAL_RECEIVERS = totalReceivers 
         WHERE MO.MSN_INT_ID = mission
         AND MO.MO_INT_ID = task ;
    END IF;
    END;
    ' LANGUAGE plpgsql;
    

    … assuming I haven’t mangled the logic too badly 😉

    I took the liberty of changing the way the parameters are defined, and the return type (since it looks like you’re not actually returning anything from the function?)

    Edit: oops, I used the wrong construct for select into…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on porting some Oracle DB code to Postgres, and I
(This is similar to a question I asked earlier: Porting Oracle Procedure to PostgreSQL
I have been porting oracle selects, and I have been running across a lot
I have some old C 32 Bit DLLs that are using Oracle's Pro C
I have a legacy Struts 1.2.8 application that I'm maintaining and porting from Oracle
We have an application (well, 3) which uses Oracle 9i, however this is being
We are looking at various options in porting our persistence layer from Oracle to
I'm porting a Java library to C#. I'm using Visual Studio 2008, so I
im porting c code to windows 32 bit using visual studio express now i
We are porting existing windows code to Linux. We are using ACE as abstraction

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.