views:

38

answers:

1

Hey folks, I've got this procedure:

CREATE OR REPLACE PROCEDURE CONV1(
    pDate   IN  VARCHAR2,
    pYear  OUT number,
    pMonth OUT number,
    pDay   OUT number
)
AS
    lDate   DATE;
BEGIN
    lDate := to_date(pDate, 'DD.MM.YYYY HH24:MI:SS');
    pYear := to_number(to_char(lDate, 'YYYY'));
    pMonth := to_number(to_char(lDate, 'MM'));
    pDay := to_number(to_char(lDate, 'DD'));

END CONV1;
/

How do I call this procedure if I just want ONE of the outs in there? (Like Select FMAN_STAT_CONV1('16.07.2010', pDay) from dual; (which ain't work btw))

Greetz!

+6  A: 

Create function which will use procedure conv1, but will return only one value.

Or even better for your particular case

SELECT to_char(to_date(your_date, 'DD.MM.YYYY HH24:MI:SS'), 'DD') from dual.

Or common case is:

CREATE OR REPLACE FUNCTION CONV2(
  pDate   IN  VARCHAR2
) 
RETURN NUMBER
IS
  pDay   number;
  pMonth number;
  pYear  number;

BEGIN
   conv1(pDate, pYear, pMonth, pDay);
   return pDay;
END;
Michael Pakhantsov
made a function, thx
Husky110