Solved

Oracle PL/SQL Function Syntax

Posted on 2014-09-30
3
625 Views
Last Modified: 2014-09-30
This is a simple function that I copied from a tutorial.

The following error is triggered when I try to compile:

"The name in the text editor differs from the specified object name"

Here is the function:

 
CREATE OR REPLACE FUNCTION DBM_Add_ColComment 
    
RETURN VARCHAR(20);
 IS 

    emp_name VARCHAR(20); 
 
    BEGIN 
 
        SELECT ename INTO emp_name
        FROM employee WHERE EmpNo = 6;
        
        RETURN emp_name;

 END;
 / 

Open in new window


This statement executes in the SQL window:

SELECT ename
        FROM employee WHERE EmpNo = 6;

What am I missing?

Thanks,
0
Comment
Question by:Dovberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 500 total points
ID: 40353307
Remove the semi-colon (;) from the first RETURN (after the CREATE)
. .  And the "( 20)" also, and replace IS with AS and:
CREATE OR REPLACE FUNCTION Dbm_Add_Colcomment
   RETURN VARCHAR2
AS
   Emp_Name       VARCHAR2 ( 20 );
BEGIN
   SELECT Ename
     INTO Emp_Name
     FROM Employee
    WHERE Empno = 6;

   RETURN Emp_Name;
END;
/

Open in new window

;)
PS: You may also want to use "VARCHAR2" data type.
0
 

Author Comment

by:Dovberman
ID: 40353431
Wonderful,

Thanks,
0
 

Author Closing Comment

by:Dovberman
ID: 40353435
Thank you,
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Oracle SQL - Query help 7 79
use lov values 2 72
Create file system directory from Oracle 10g 4 32
return value in based on value passed 6 37
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question