Marius Flevie
Marius Flevie

Reputation: 107

What is wrong with this stored function?

Create Or Replace Function  ASS1_TEST_MSG (pName varchar2) Return varchar2 As
vMsg := '';
Begin
    If pName = 'Peter' Then
        vMsg := 'Hello Peter. I am a student in Database Systems.';
    End If;
    Return vMsg;
End;

Upvotes: 0

Views: 59

Answers (1)

ajmalmhd04
ajmalmhd04

Reputation: 2602

You need to declare the datatype of vMsg,

Try this:

CREATE OR REPLACE
FUNCTION ASS1_TEST_MSG(
          pName VARCHAR2)
     RETURN VARCHAR2
AS
     vMsg varchar2(100):= '';
BEGIN
     IF pName   = 'Peter' THEN
          vMsg := 'Hello Peter. I am a student in Database Systems.';
     END IF;
     RETURN vMsg;
END;

Upvotes: 3

Related Questions