Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to create a function that take the user input and search for the code in my table and return var

User_YJ1D6Apr 10 2022 — edited Apr 10 2022

Hi, i was trying to create a function that ask the user for an employe code then take that code and search in my EMPLOYE table andreturn all informations about the employe.
I did this but, it gives me an error , could someone help me to figure this out please .

CREATE OR REPLACE FUNCTION fNombreProjets(code_Emp IN NUMBER) 
RETURN number IS 
  ALLO number(100) := 0; 
BEGIN

  SELECT e.IDEMPLOYE ,
      e.NOMEMPLOYE ,
      e.ADRESSE ,
      e.TELEPHONE ,
      e.ADRESSECOURRIEL 
  FROM Employe e
  WHERE idEmploye= code_Emp;

  DBMS_OUTPUT.PUT_LINE('Code employe : ' || e.code_Emp ||chr(13)||chr(10) ||
              'Nom employe : ' || e.nomEmploye ||chr(13)||chr(10)||
              'Adresse employe : ' || e.adresse ||chr(13)||chr(10)||
              'Telephone employe : ' || e.telephone ||chr(13)||chr(10)||
              'Adresse Courriel employe : ' || e.adresseCourriel ||chr(13)||chr(10));
  RETURN ALLO;
END;   

ACCEPT val NUMBER PROMPT 'Entrer le code Employé: '
DECLARE
  code_Emp  NUMBER := '&val';
    myname varchar2(200);

BEGIN
  code_Emp := fNombreProjets(code_Emp);
END;

THANK YOU ALL !

Comments
Post Details
Added on Apr 10 2022
5 comments
2,328 views