slight correction
 
SQL>:x := emp_sel('SCOTT'); 
 
has to be changed to :-
 
SQL> exec :x := emp_sel('SCOTT');
 
sorry ... cut&paste problem from sqlplus output !!!

-----Original Message-----
Sent: Friday, June 06, 2003 9:51 AM
To: '[EMAIL PROTECTED]'


Functions CAN be called from SQL*Plus like this ...
 
create the function
-------------------
 
create or replace function emp_sel(e IN VARCHAR2) RETURN VARCHAR2 IS
cName VARCHAR2(32);
BEGIN
    SELECT INITCAP(ename) INTO cName FROM EMP WHERE ename = e;
    RETURN (cName);
END;
/
 
in SQL*Plus do the following
-----------------------------
 
SQL>variable x varchar2(32);
SQL> exec :x := emp_sel('SCOTT');
 
PL/SQL procedure successfully completed.
 
SQL>print X;
 
X
--------------------------------
Scott
 
HTH ...
 
 

-----Original Message-----
Sent: Friday, June 06, 2003 9:55 AM
To: Multiple recipients of list ORACLE-L


 declare 
   a varchar2(20);
   b:=varchar2(20):='gali';
 begin
   a:=EMP_SEL(b);
   dbms_output.put_line(a);
   end;
You cannot call the functions like this, only procedures can be.
Venkat

--------- Original Message ---------

DATE: Fri, 06 Jun 2003 03:35:11 
To: Multiple recipients of list ORACLE-L <[EMAIL PROTECTED]>    
Cc:     

hi all,
this is purushottam hegde from Bangalore(IND)
i am relatively new to oracle and so to this group.
iam having a problem with function...
it goes like this.
 
 
 
SQL> CREATE OR REPLACE FUNCTION EMP_SEL(ename IN Varchar2) return varchar2
is
  2  resex varchar2(3);
  3  Begin 
  4  SELECT sex into resex from emp where name=ename;
  5  return(resex);
  6  END;
  7  /
Function created.
 
SQL> EXECUTE EMP_SEL('gali');
BEGIN EMP_SEL('gali'); END;
      *
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'EMP_SEL' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
 
 
 
pl help me in this regard
 
thanking all of u
 
purushottam hegde
 
 



  _____  

Do you Yahoo!?
Free online  <http://us.rd.yahoo.com/mail_us/tag/*http://calendar.yahoo.com>
calendar with sync to Outlook(TM).



____________________________________________________________
Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
Login To Lycos  <http://login.mail.lycos.com/r/referral?aid=27005> Mail

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Chelur, Jayadas {PBSG}
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to