View Full Version : PL\SQL package creation
Hi,
I have following code:
(seems very simple but tricky)
1-- create or replace package testNameConcate
2-- is
3-- function disp(Name varchar)
4-- return varchar;
5-- end testNameConcate;
6-- /
7-- create or replace package body testNameConcate
8-- is
9-- function disp(Name varchar)
10-- return varchar
11-- is
12-- nm varchar(25);
13-- begin
14-- nm='Hello ' || Name;
15-- return nm;
16-- end testNameConcate;
/
As u see "/" is need at line 6 other wise it gives me an error
PLS-00103: Encountered the symbol "CREATE" at line 7
but sill this code is giving me a same error, and now it has problem with
"/" and error is
PLS-00103: Encountered the symbol "/" at line 6
What am i missing here?
D Rolfe
09-22-2004, 06:21 AM
The package and package body are two seperate things. You are trying to
define both of them at the same time. The error message indicates that
the parser is surprised to find more 'stuff' at the end of your package
definition. You need a blank line after line #6.
Hi, I have following code: (seems very simple but tricky) 1-- create or replace package testNameConcate 2-- is 3-- function disp(Name varchar) 4-- return varchar; 5-- end testNameConcate; 6-- /
7-- create or replace package body testNameConcate 8-- is 9-- function disp(Name varchar) 10-- return varchar 11-- is 12-- nm varchar(25); 13-- begin 14-- nm='Hello ' || Name; 15-- return nm; 16-- end testNameConcate; /
As u see "/" is need at line 6 other wise it gives me an error PLS-00103: Encountered the symbol "CREATE" at line 7 but sill this code is giving me a same error, and now it has problem with "/" and error is PLS-00103: Encountered the symbol "/" at line 6 What am i missing here?
David Rolfe
Mark C. Stock
09-22-2004, 06:30 AM
"DCP" <vaagh@hotmail.com> wrote in message
news:f5c10fa85d76815cf0463b1e210193d3@localhost.talkaboutdatabases.com...
| Hi,
|
| I have following code:
| (seems very simple but tricky)
|
|
| 1-- create or replace package testNameConcate
| 2-- is
| 3-- function disp(Name varchar)
| 4-- return varchar;
| 5-- end testNameConcate;
| 6-- /
| 7-- create or replace package body testNameConcate
| 8-- is
| 9-- function disp(Name varchar)
| 10-- return varchar
| 11-- is
| 12-- nm varchar(25);
| 13-- begin
| 14-- nm='Hello ' || Name;
| 15-- return nm;
| 16-- end testNameConcate;
| /
|
| As u see "/" is need at line 6 other wise it gives me an error
|
| PLS-00103: Encountered the symbol "CREATE" at line 7
|
| but sill this code is giving me a same error, and now it has problem with
| "/" and error is
|
| PLS-00103: Encountered the symbol "/" at line 6
|
| What am i missing here?
|
|
code is fine -- it's probably the way you're running it. i would assume that
you've got all this code in the SQL buffer and then attempt to execute it as
if it is a single SQL statement -- it's actually two SQL statements, so you
need to save it to a named script file (not the default afiedt.buf that gets
created when you do a plain EDIT in SQL*Plus) and then use '@filename' or
'start filename' to execute the script
also: user varchar2 instead of varchar -- oracle's been saying the following
since v7 or v6:
"VARCHAR Datatype
"The VARCHAR datatype is currently synonymous with the VARCHAR2 datatype.
Oracle recommends that you use VARCHAR2 rather than VARCHAR. In future
releases, VARCHAR might be defined as a separate datatype used for
variable-length
character strings compared with different comparison semantics."
++ mcs
THANKS GUYS
But none of the solution is working!
I tried to insert a blank line after "/", even created a .SQL file and try
to run it after changing VARCHAR TO VARCHAR2...
None of these is working with me....
Thanks you for helping me but i guess its two seperate sql commend so need
to execute sepeate as 'Mark' said
george lewycky
09-22-2004, 12:32 PM
You need to create the PACKAGE before the PACKAGE BODY
George
"Mark C. Stock" <mcstockX@Xenquery .com> wrote in message news:<Xf6dnTIpMZkQEczcRVn-rQ@comcast.com>... "DCP" <vaagh@hotmail.com> wrote in message news:f5c10fa85d76815cf0463b1e210193d3@localhost.talkaboutdatabases.com... | Hi, | | I have following code: | (seems very simple but tricky) | | | 1-- create or replace package testNameConcate | 2-- is | 3-- function disp(Name varchar) | 4-- return varchar; | 5-- end testNameConcate; | 6-- / | 7-- create or replace package body testNameConcate | 8-- is | 9-- function disp(Name varchar) | 10-- return varchar | 11-- is | 12-- nm varchar(25); | 13-- begin | 14-- nm='Hello ' || Name; | 15-- return nm; | 16-- end testNameConcate; | / | | As u see "/" is need at line 6 other wise it gives me an error | | PLS-00103: Encountered the symbol "CREATE" at line 7 | | but sill this code is giving me a same error, and now it has problem with | "/" and error is | | PLS-00103: Encountered the symbol "/" at line 6 | | What am i missing here? | | code is fine -- it's probably the way you're running it. i would assume that you've got all this code in the SQL buffer and then attempt to execute it as if it is a single SQL statement -- it's actually two SQL statements, so you need to save it to a named script file (not the default afiedt.buf that gets created when you do a plain EDIT in SQL*Plus) and then use '@filename' or 'start filename' to execute the script also: user varchar2 instead of varchar -- oracle's been saying the following since v7 or v6: "VARCHAR Datatype "The VARCHAR datatype is currently synonymous with the VARCHAR2 datatype. Oracle recommends that you use VARCHAR2 rather than VARCHAR. In future releases, VARCHAR might be defined as a separate datatype used for variable-length character strings compared with different comparison semantics." ++ mcs
Daniel Morgan
09-22-2004, 03:31 PM
DCP wrote:
THANKS GUYS But none of the solution is working! I tried to insert a blank line after "/", even created a .SQL file and try to run it after changing VARCHAR TO VARCHAR2... None of these is working with me.... Thanks you for helping me but i guess its two seperate sql commend so need to execute sepeate as 'Mark' said
Go to {ORACLE_HOME}/rdbms/admin
Look at how Oracle builds packages.
For example look at dbmssupp.sql
Note the last line:
@@prvtsupp.plb
dbmssupp.sql builds the package header.
prvtsupp.plb builds the package body.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)
Zvika Glickman
09-23-2004, 12:43 AM
gelewyc@nyct.com (george lewycky) wrote in message news:<68aecc05.0409221232.407c8e54@posting.google.com>... You need to create the PACKAGE before the PACKAGE BODY George "Mark C. Stock" <mcstockX@Xenquery .com> wrote in message news:<Xf6dnTIpMZkQEczcRVn-rQ@comcast.com>... "DCP" <vaagh@hotmail.com> wrote in message news:f5c10fa85d76815cf0463b1e210193d3@localhost.talkaboutdatabases.com... | Hi, | | I have following code: | (seems very simple but tricky) | | | 1-- create or replace package testNameConcate | 2-- is | 3-- function disp(Name varchar) | 4-- return varchar; | 5-- end testNameConcate; | 6-- / | 7-- create or replace package body testNameConcate | 8-- is | 9-- function disp(Name varchar) | 10-- return varchar | 11-- is | 12-- nm varchar(25); | 13-- begin | 14-- nm='Hello ' || Name; | 15-- return nm; | 16-- end testNameConcate; | / | | As u see "/" is need at line 6 other wise it gives me an error | | PLS-00103: Encountered the symbol "CREATE" at line 7 | | but sill this code is giving me a same error, and now it has problem with | "/" and error is | | PLS-00103: Encountered the symbol "/" at line 6 | | What am i missing here? | | code is fine -- it's probably the way you're running it. i would assume that you've got all this code in the SQL buffer and then attempt to execute it as if it is a single SQL statement -- it's actually two SQL statements, so you need to save it to a named script file (not the default afiedt.buf that gets created when you do a plain EDIT in SQL*Plus) and then use '@filename' or 'start filename' to execute the script also: user varchar2 instead of varchar -- oracle's been saying the following since v7 or v6: "VARCHAR Datatype "The VARCHAR datatype is currently synonymous with the VARCHAR2 datatype. Oracle recommends that you use VARCHAR2 rather than VARCHAR. In future releases, VARCHAR might be defined as a separate datatype used for variable-length character strings compared with different comparison semantics." ++ mcs
1. The / must be at first column.
2. There are other errors in the package body. Attached a fixed code:
create or replace package testNameConcate
is
function disp(Name varchar)
return varchar;
end testNameConcate;
/
create or replace package body testNameConcate
is
function disp(Name varchar)
return varchar
is
nm varchar(25);
begin
nm:='Hello ' || Name;
return nm;
end;
end testNameConcate;
/
Mark C. Stock
09-23-2004, 03:23 AM
"Zvika Glickman" <zglickman@il.bphx.com> wrote in message
news:b6b91e64.0409230043.1acbe6f0@posting.google.com...
| gelewyc@nyct.com (george lewycky) wrote in message
news:<68aecc05.0409221232.407c8e54@posting.google.com>...
| > You need to create the PACKAGE before the PACKAGE BODY
| >
| > George
| >
| >
| >
| >
| >
| >
| >
| > "Mark C. Stock" <mcstockX@Xenquery .com> wrote in message
news:<Xf6dnTIpMZkQEczcRVn-rQ@comcast.com>...
| > > "DCP" <vaagh@hotmail.com> wrote in message
| > >
news:f5c10fa85d76815cf0463b1e210193d3@localhost.talkaboutdatabases.com...
| > > | Hi,
| > > |
| > > | I have following code:
| > > | (seems very simple but tricky)
| > > |
| > > |
| > > | 1-- create or replace package testNameConcate
| > > | 2-- is
| > > | 3-- function disp(Name varchar)
| > > | 4-- return varchar;
| > > | 5-- end testNameConcate;
| > > | 6-- /
| > > | 7-- create or replace package body testNameConcate
| > > | 8-- is
| > > | 9-- function disp(Name varchar)
| > > | 10-- return varchar
| > > | 11-- is
| > > | 12-- nm varchar(25);
| > > | 13-- begin
| > > | 14-- nm='Hello ' || Name;
| > > | 15-- return nm;
| > > | 16-- end testNameConcate;
| > > | /
| > > |
| > > | As u see "/" is need at line 6 other wise it gives me an error
| > > |
| > > | PLS-00103: Encountered the symbol "CREATE" at line 7
| > > |
| > > | but sill this code is giving me a same error, and now it has problem
with
| > > | "/" and error is
| > > |
| > > | PLS-00103: Encountered the symbol "/" at line 6
| > > |
| > > | What am i missing here?
| > > |
| > > |
| > >
| > > code is fine -- it's probably the way you're running it. i would
assume that
| > > you've got all this code in the SQL buffer and then attempt to execute
it as
| > > if it is a single SQL statement -- it's actually two SQL statements,
so you
| > > need to save it to a named script file (not the default afiedt.buf
that gets
| > > created when you do a plain EDIT in SQL*Plus) and then use '@filename'
or
| > > 'start filename' to execute the script
| > >
| > > also: user varchar2 instead of varchar -- oracle's been saying the
following
| > > since v7 or v6:
| > >
| > > "VARCHAR Datatype
| > > "The VARCHAR datatype is currently synonymous with the VARCHAR2
datatype.
| > > Oracle recommends that you use VARCHAR2 rather than VARCHAR. In future
| > > releases, VARCHAR might be defined as a separate datatype used for
| > > variable-length
| > > character strings compared with different comparison semantics."
| > >
| > > ++ mcs
|
| 1. The / must be at first column.
| 2. There are other errors in the package body. Attached a fixed code:
|
| create or replace package testNameConcate
| is
| function disp(Name varchar)
| return varchar;
| end testNameConcate;
| /
| create or replace package body testNameConcate
| is
| function disp(Name varchar)
| return varchar
| is
| nm varchar(25);
| begin
| nm:='Hello ' || Name;
| return nm;
| end;
| end testNameConcate;
| /
good catch -- i stopped at compiling the package spec and didn't even look
at the body -- sorry my response was incomplete
++ mcs
MyLounge.com Site Map
Forum:
Cars,
Cell Phone,
Database,
Games,
Home Improvement,
IT,
Music,
School,
Sports,
Web Design,
Web Server,
Weight Loss
The MyLounge.com forum is intended for informational use only and should not
be relied upon and is not a substitute for any advice. The information contained
on MyLounge.com are opinions and suggestions of members and is not a representation
of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for
the accuracy, completeness or usefulness of any postings or the qualifications
of any person responding. Please consult a expert or seek the services of an
attorney in your area for more accuracy on your specific situation. Please note
that our forums also serve as mirrors to Usenet newsgroups. Many posts you see
on our forums are made by newsgroup users who may not be members of MyLounge.com
Term of Service
vBulletin v3.0.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.