-1

Possible Duplicate:
CALLING A STORED PROCEDURE IN TOAD

I am given a function in Oracle as i have shown below.However i could not make it run.

FUNCTION GetAdres (pCif        NUMBER,
                    pAddressno NUMBER DEFAULT 0,
                   pAdrSerino NUMBER ,
                    pRAdres      OUT T_ADRES%ROWTYPE,
                   pErrCode      OUT NUMBER,
                   pErrMes      OUT VARCHAR2
                     )
Community
  • 1
  • 1
user1171708
  • 87
  • 2
  • 6
  • 13
  • What have you tried? What happened? What error, if any, did you get? Where are you trying to call it from, and what are you going to do with the results? – Alex Poole Feb 04 '13 at 07:52

1 Answers1

0

Think you should use a Procedure, not a Function

An Oracle function can return one -and only one- value, with another syntax.

CREATE FUNCTION GetAdres(parameter1  IN NUMBER, parameter2 IN NUMBER) 
   RETURN NUMBER

In fact, you can have OUT parameters in an Oracle Function (my bad), but you need a unique return type anyway.

But

You can perfectly use multiple OUT parameters in an Oracle procedure...

So

Solution1 (and I would go for this one)

Use a procedure instead of a function

Solution2

Create a custom type and use it as the return type.

create a custom type
CREATE TYPE my_type as object
    (Adres      VARCHAR2(100), 
     ErrCode    NUMBER,
     ErrMes     VARCHAR2(250));


CREATE FUNCTION GetAdres (pCif        NUMBER,
                    pAddressno NUMBER DEFAULT 0,
                   pAdrSerino NUMBER)
  RETURN my_type;
Raphaël Althaus
  • 59,727
  • 6
  • 96
  • 122