ORA-06550 and PLS-00103 - oracle

HI,
I am using UNIX OS and working on oracle. I am getting the error message below
E ORA-06550: line 1, column 8:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin function package pragma procedure subtype type use
<an identifier> <a double-quoted delimited-identifier> form
current cursor
The symbol "" was ignored.
ORA-06550: line 2, column 27:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin function package pragma procedure subtype type use
<an identifier> <a double-quoted delimited-identifier>
On googling, I found
"The problem appears to be with Windows CRLF characters on line breaks. Oracle does not treat this as white space, instead it sees it as an empty string. In order to get round this problem, convert the CRLF characters to LF characters and Oracle should be happy."
Anyone have any idea about why it is happening in UNIX/ksh shell?

As #JOTN said, the dos2unix command is your friend here. Should be invoked something like
dos2unix the_file_you_want_converted > another_file_to_hold_the_unix_version
Share and enjoy.

Related

Call a PL/SQL package from shell script - Error "identifier must be declared"

am calling a plsql package from shell script as
sqlplus -s <<!
$userpass
set pagesize 0 feedback off verify off heading off echo off
exec POEXT.PO_ACK_UPDATE("$worfile",$ftpvendornum,"$org_code",$req_id,"$ftpgrp","$vendor_name");
exit;
!
The value of the parameters as follows
worfile=R12POAUS220171025#230307.ZIP
ftpvendornum=15163
org_code=US2
req_id=53004007
ftpgrp=DCU
vendor_name=Empty
when i run - I get an error message like below
ERROR at line 1:
ORA-06550: line 1, column 35:
PLS-00201: identifier 'R12POAUS220171025#230307.ZIP' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
I executed the same block in sqldeveloper using anonymous block its getting executed.
can someone help me to figure out what could be the possible issue?
How is it when you write the statement with single ' around the parameters?
exec POEXT.PO_ACK_UPDATE('$worfile',$ftpvendornum,'$org_code',$req_id,'$ftpgrp','$vendor_name');

Using Variable- Oracle

In the above code, I am giving schemaname as input and using that input it should connect to the database. But In this case the value i entered is not taken by the schemaname. This is how the out put and the error is:
declare schemaname varchar2(20);
exec :schemaname := XYZ;
BEGIN
end;
Error report -
ORA-06550: line 2, column 6:
PLS-00103: Encountered the symbol "" when expecting one of the following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table long double ref
char time timestamp interval date binary national character
nchar
ORA-06550: line 4, column 1:
PLS-00103: Encountered the symbol "CONNECT" when expecting one of the following:
Could any one suggest how to make it work using spool
the code between declare and end is PL/SQL. Commands like CONNECT or SPOOL are SQL*Plus commands. You cannot use SQL*Plus commands in a PL/SQL block.
In your case you don't need PL/SQL at all:
Create a script with following content
connect &1
spool C:\ABC
#c:\ABC
spool off;
and run it
#your_script_name
BTW: there is no reason to run script c:\ABC while you are spooling into it. What exactly do you want to achieve?
exec[ute] is SQL*Plus and SQL Developer (and maybe other clients) shorthand for an anonymous block. It is a client command, it is not part of PL/SQL. You are trying to use it inside a PL/SQL declare section, where it is not valid or recognised.
If you want a client bind variable you need the var[iable] command:
var schemaname varchar2(20);
exec :schemaname := '&1';
BEGIN
...
Notice the single quotes around &1, as it's being assigned to a string variable.
But you can't connect inside a PL/SQL block either, and you can't use a bind variable for the connection.
connect :schemaname
will prompt for a password (even if you defined it's value as user/passwd) and try to connect as a user lieterally called :schemaname.
You can use a substituion variable, but you don't really need to define a new one; as you seem to be passing the credentials in, you can do:
connect &1
(without surrounding quotes)

oracle plsql error while compiling package spec

create or replace
PACKAGE test_pkg
IS
PROCEDURE abc_requests (p_xys IN NUMBER);
end test_pkg;
Hello my procedure name is abc_requests with just one parameter.
Below is my error message, please help.
Error message:
Error(4,11): PLS-00103: Encountered the symbol " "
when expecting one of the following:
<an identifier>
<a double-quoted delimited-identifier>
current delete exists prior
You have used non-breaking spaces in your statement, instead of plain spaces. If you copy and paste the code from the page as it is displayed above it will work. If you edit the question and copy the original code it will not.
You can use the dump() function (or a decent text editor) to see what the code actually contains:
select dump('PROCEDURE abc_requests (p_xys IN NUMBER);',16) from dual;
DUMP('PROCEDURE ABC_REQUESTS(P_XYS IN NUMBER);',16)
--------------------------------------------------------------------------------------------------------------------------------------------------
Typ=96 Len=44: 50,52,4f,43,45,44,55,52,45,c2,a0,61,62,63,5f,72,65,71,75,65,73,74,73,20,28,70,5f,78,79,73,c2,a0,49,4e,c2,a0,4e,55,4d,42,45,52,29,3b
^^^^^ ^^^^^ ^^^^^
I've highlighted the two problem characters, which are the multibye non-break space (in UTF-8).
Retype your code, or copy and paste from the question, or just change the non-breaking spaces to normal ones.

PLS-00103: Encountered the symbol " " when expecting one of the following

For some reason this wont work. I have got it down to the most basic operation to try and troubleshoot.
BEGIN
FOR rec IN (
select REGISTRATION_UID from DIM_REGISTRATION_SET
) 
   LOOP
dbms_output.put_line('Testing 123');
  END LOOP; 
end;
/
My error is as below:
Error starting at line 1 in command:
BEGIN
FOR rec IN (
select REGISTRATION_UID from DIM_REGISTRATION_SET
) 
   LOOP
dbms_output.put_line('Testing 123');
  END LOOP; 
end;
Error report:
ORA-06550: line 4, column 6:
PLS-00103: Encountered the symbol " " when expecting one of the following:
loop
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
You seem to have an unexpected character in your code. If you copy and paste the rendered output from this question then it runs fine. If you copy the question source code (from the edit dialogue) then it gets that error.
Dumping the code (again copied from the source, not the rendering) shows:
select dump('(
select REGISTRATION_UID from DIM_REGISTRATION_SET
) ', 16)
from dual; 
DUMP('(SELECTREGISTRATION_UIDFROMDIM_REGISTRATION_SET) ',16)
--------------------------------------------------------------------------------
Typ=96 Len=73: 28,a,20,20,20,20,20,20,20,20,20,20,73,65,6c,65,63,74,20,52,45,47,
49,53,54,52,41,54,49,4f,4e,5f,55,49,44,20,66,72,6f,6d,20,44,49,4d,5f,52,45,47,49
,53,54,52,41,54,49,4f,4e,5f,53,45,54,a,20,20,20,20,20,20,20,20,29,c2,a0
So the space after the closing parenthesis isn't actually a space, it's Unicode character c2a0, which is a non-breaking space.
The error message shows that too, if you dump that:
select dump ('Encountered the symbol " "', 16) from dual;
DUMP('ENCOUNTEREDTHESYMBOL" "',16)
--------------------------------------------------------------------------------
Typ=96 Len=27: 45,6e,63,6f,75,6e,74,65,72,65,64,20,74,68,65,20,73,79,6d,62,6f,6c
,20,22,c2,a0,22
I would guess you copied that code from somewhere (Word?) and it picked up that character, and it hasn't been translated to a normal space. Just replace it with a space, or remove it as it's redundant whitespace anyway.
Actually, there are several others; two at the start of the LOOP line (followed by two normal spaces), and two immediately before END LOOP; (preceded by two normal spaces), and one after that statement; so those all need to be replaced too. (I'd be tempted to retype the whole thing, but that might not be practical for your full code).

Trivial PL/SQL block generating frustrating PLS-00103 error

I may be going a bit insane, but I keep getting a PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following... error. I have pared my program down to the following:
BEGIN
NULL;
END;
/
Which I am running within AquaData Studio.
This produces:
[Error] Script lines 1-2 ... ORA-06550: line 2, column 8:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following...; Script line 2, statement line 2, column 8
I write a decent amount of PL/SQL and normally the above trivial block runs just fine. What the heck is wrong with what I'm doing?
It turns out the solution was as suggested by #a_horse_with_no_name in his comment. In ADS, you need to open File → Options Ctrl + , (that's a comma!) and set the following options on the General tab:
';' Statement separator (make sure it is not ticked)
'/' at End of Line Terminates Statement (make sure it is ticked)
See screenshot below. Do this, and it all works:

Resources