user3213758
user3213758

Reputation: 103

pl sql error PLS-00103

I have a table(customer) and is has attributes of c_Id, fname, lname, age

the table is populated with the following values

 1|Ann|Smiths|23
 2|Chris|Gates|21
 3|Janes|Jobs|24

I am very new to pl/sql and I wrote a simple select statement

DECLEAR
     name varchar2(50);
BEGIN
     SELECT fname into name
     FROM customer
     WHERE fname= 'Ann';
END;

When I execute the script my from my textfile(doselect) on sqlplus using the following command

 EXECUTE doselect

however it gives me the following error

ERROR at line 1:
ORA-06550: line 1, column 8:  
PLS-00103: Encountered the symbol ":" when expecting one of the following: 
:= . ( @ % ; 

Please help.

Upvotes: 0

Views: 14461

Answers (3)

user12564327
user12564327

Reputation: 1

Create a type holding_TY as an object

(
    d_id int not null,
    foreign key(d_id)references device(d_id),
    d_number number
)

Create type holding_nt as a table of holding_TY

CREATE TABLE bill (
    bi_id int primary key,
    c_id number not null,
    foreign key(c_id) references customer(c_id),
    bi_date date_TY,
    holding holding_nt,
    total_pri float
)

Nested table holding store as holding_nt_table

Upvotes: 0

Antonino Barila
Antonino Barila

Reputation: 163

DECLARE
   name   VARCHAR2 (50);
BEGIN
   SELECT   FNAME
     INTO   name
     FROM   customer
    WHERE   FNAME = 'Ann';
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('ERROR ' || SQLERRM);
END;
/

Your error is in DECLEAR -> DECLARE, and you must close your script with /.

You should always insert a block for exception handling.

Upvotes: 0

Frank Schmitt
Frank Schmitt

Reputation: 30765

Apart from the typo (DECLEAR instead of DECLARE), your script looks fine. To get output from SQL/Plus, I'd also add a DBMS_OUTPUT statement:

DECLARE
     name varchar2(50);
BEGIN
     SELECT fname into name
     FROM customer
     WHERE fname= 'Ann';
     -- print it
     dbms_output.put_line(name);
END;

However, to execute a file from SQL/Plus, don't use the EXECUTE command - rather use @ :

SQL> set serveroutput on
SQL> @doselect
 10  /
 Ann

SQL/Plus is not very friendly to new users - you might want to use another client to get started (e.g. Oracle SQL/Developer - it's free and comes with a nice GUI).

Upvotes: 1

Related Questions