Question

I getting the error when creating query for PL/SQL CREATE OR REPLACE FUNCTION Customer_Details RETURN VARCHAR2;...

I getting the error when creating query for PL/SQL

CREATE OR REPLACE FUNCTION Customer_Details 
RETURN VARCHAR2;
IS 
Cust_Name VARCHAR2 (20); 
BEGIN 
SELECT FirstName 
INTO Cust_Name
FROM Customer
WHERE CustomerID = '300001';
RETURN Cust_Name;
END;
/ 

I'm getting the error:

3/1 PLS-00103: Encountered the symbol "IS"

Errors: check compiler log

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have corrected the code, there was just one error at line 3,

you had used RETURN VARCHAR2; , the semicolon here ends the return statement.

but actually we do it like, first we declare the return type of out function and then the actual variable, which in case is Cust_name.

So RETURN VARCHAR2 IS Cust_Name VARCHAR2 (20); is just`a single statement.

CREATE OR REPLACE FUNCTION Customer_Details
RETURN VARCHAR2 IS Cust_Name VARCHAR2 (20);
BEGIN
SELECT FirstName
INTO Cust_Name
FROM Customer
WHERE CustomerID = '300001';
RETURN Cust_Name;
END;

/

This code works fine.

Add a comment
Know the answer?
Add Answer to:
I getting the error when creating query for PL/SQL CREATE OR REPLACE FUNCTION Customer_Details RETURN VARCHAR2;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create...

    PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create the schema, and package. 2. Create users x1 and x2 who are the participants in the auction. They will need acces to the package. 3. Bid on the same item and record your observations. Verify all scenarios. Upload the files with the missing code and a detailed sample run. AUCTION OWNER.TXT SQL> conn / as sysdba Connected. SQL> drop user xyz cascade; User dropped....

  • /* I am executing following SQL statement for the below code but I am getting error....

    /* I am executing following SQL statement for the below code but I am getting error. Pls, upload screenshot after running it. SQL Statement: SELECT OfferNo, CourseNo FROM Offering WHERE OfferTerm = 'Sum' AND OfferYear = 2012 AND FacSSN IS NULL; */ CREATE TABLE STUDENT( StdSSN INT NOT NULL PRIMARY KEY, StdFName VARCHAR2(50), StdLName VARCHAR2(50), StdCity VARCHAR2(50), StdState VARCHAR2(2), StdZip VARCHAR2(10), StdMajor VARCHAR2(15), StdYear VARCHAR2(20) ); CREATE TABLE FACULTY( FacSSN INTEGER NOT NULL PRIMARY KEY, FacFName VARCHAR(50), FacLName VARCHAR(50), FacCity...

  • I need help for SQL homework. the question: the code for part 1,2: drop table Customer;...

    I need help for SQL homework. the question: the code for part 1,2: drop table Customer; drop table Company; drop table Cruise; drop table TravelAgent; drop table Reservation; drop sequence customerID_seq; drop sequence cruiseID_seq; drop sequence travelAgentID_seq; drop sequence reservationID_seq; create table Customer( customerID number, firstName varchar2(15), lastName varchar2(15), address varchar2(30), phone number(10) not null, age number(3), Constraint Customer_PK Primary Key (customerID), constraint Customer_unique unique (firstName,lastName,phone), constraint Customer_check check(phone is not null) ); create sequence customerID_seq start with 1 increment...

  • SQL PROGRAMMING Exercises Create a function named MyCube that will take a NUMBER as in input...

    SQL PROGRAMMING Exercises Create a function named MyCube that will take a NUMBER as in input and RETURN the cubed value of the input as a NUMBER. To calculate the CUBE, multiply the input number by itself three times (eg. num * num * num). Once you have the function created, test it using the following SQL statement: SELECT MyCube(3) FROM dual; *The dual table is a built in table that you can use to test your functions. Create a...

  • Write an SQL query against the Chinook Database v1.4. Each query must run successfully using DB...

    Write an SQL query against the Chinook Database v1.4. Each query must run successfully using DB Browser for SQLite. Create the exact query below. Must use sub query. I saw that a similar solution for this question used IF and CONCAT functions which do not work and return errors. If it is possible to use the CASE function in place of IF that would be greatly appreciated. Also I really hate to ask but if it could be organized neatly...

  • Part I. Create a library check-out database using Microsoft SQL Server that stores data about books,...

    Part I. Create a library check-out database using Microsoft SQL Server that stores data about books, patrons, and the check-out process. Books (BookID, BookName, Author, YearPublished) Patrons (PatronsID, PatronsName, PatronsAddress, PatronsBirthday) CheckInOut (TransactionID, PatronID, BookID, CheckOutDate, NumDay, ReturnDate, Late, Fees, Paid) - the NumDay field contains the number of days patrons can keep the book, if the return date is over the number of day, then the Late field will have a Y value and a fee of $1.00 per...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT