Results 1 to 2 of 2

Thread: store function

  1. #1
    Join Date
    May 2014
    Posts
    4

    Unanswered: store function

    Question:

    A stored function to calculate delivery charges given city and weight





    this my answer, can you share if this answer wrong

    CREATE OR REPLACE FUNCTION CALCULATE_CHARGES
    (
    CITY IN VARCHAR2
    , CHARGES IN NUMBER
    , TOTAL IN NUMBER
    ) RETURN NUMBER AS
    BEGIN
    RETURN total:=city*charges;
    END CALCULATE_CHARGES;

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Sorry Yusri, we do not have your table definitions nor we can see what you see.

    But by just looking at your code we can detect the following:

    1) you should not multiply a number (charges) by a VARCHAR3 variable (city) as in "city * charges", what if city is an alpha code?

    2) Perhaps the purpose of the function would seem to be:

    a) query a "city" table to obtain some percent (or amount) corresponding to that city.
    b) multiply that percent (or amount) to the charges and return the result

    Post your table definitions.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •