Oracle ошибка ora 06550

Well I am trying to run this script in PL/SQL. But I am constantly getting errors, I tried replacing single quotes with double quotes but no use.

ACCEPT p_name PROMPT "Enter Customer Name: "
VARIABLE g_output VARCHAR2(200)
DECLARE
   v_street VARCHAR2(30);
   v_city VARCHAR2(20);
   v_prov VARCHAR2(20);
   v_postal VARCHAR2(10);
BEGIN
   SELECT cstreet, ccity, cprov, cpostal
     INTO v_address,v_city,v_state,v_zip
     FROM customer
    WHERE cname = "&p_name";
   :g_output := "&p_name" || " " ||v_street || " " || v_city;
   :g_output := :g_output " " || v_prov || " " || v_postal;
END;
/
PRINT g_output

Error:

Enter Customer Name: Ankur Kaushal
old  10:     WHERE cname = "&p_name";
new  10:     WHERE cname = "Ankur Kaushal";
old  11:    :g_output := "&p_name" || " " ||v_street || " " || v_city;
new  11:    :g_output := "Ankur Kaushal" || " " ||v_street || " " || v_city;
   :g_output := :g_output " " || v_prov || " " || v_postal;
                          *
ERROR at line 12:
ORA-06550: line 12, column 27:
PLS-00103: Encountered the symbol " " when expecting one of the following:
. ( * @ % & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like
between || indicator multiset member SUBMULTISET_
The symbol "." was substituted for " " to continue.


Input truncated to 14 characters

G_OUTPUT
--------------------------------------------------------------------------------

Any mistake I am making here?

asked Jul 10, 2012 at 12:19

unknownsatan's user avatar

3

Shouldn’t the penultimate line be

  :g_output := :g_output || ' ' || v_prov || ' ' || v_postal; 

?

answered Jul 10, 2012 at 12:28

podiluska's user avatar

podiluskapodiluska

51k7 gold badges98 silver badges104 bronze badges

2

Oracle SQL and PL/SQL uses single quotes ' to delimit strings. Double quotes " are used to signal identifiers (table names, column names…).

Replace all your double quotes by single quotes.

Also note that SQL*Plus is a poor tool to be used as a user interface. There is no way to make your actual code work with names that include quotes («O’Reilly») except making the user manually enter two single quotes («O»Reilly»).

answered Jul 10, 2012 at 12:38

Vincent Malgrat's user avatar

Vincent MalgratVincent Malgrat

66.8k9 gold badges119 silver badges171 bronze badges

 SELECT cstreet, ccity, cprov, cpostal
 INTO v_address, v_city, v_prov, v_zip

There is no declaration of v_state.

Lucas Zamboulis's user avatar

answered Mar 19, 2014 at 9:29

Jegadees's user avatar

Are you getting the ORA-06550 error when running an SQL statement? Learn the cause of this error and the solution in this article.

Demonstration of the Error

To demonstrate this error, I can run this code that creates a stored procedure:

CREATE OR REPLACE PROCEDURE testProcedure AS
  textValue VARCHAR2(3);
BEGIN
  textValue := someOtherValue;
END;

If I compile this procedure, I get this message:

Procedure TESTPROCEDURE compiled
Errors: check compiler log

Now, I can run this procedure:

EXEC testProcedure;
Error starting at line : 8 in command -
EXEC testProcedure
Error report -
ORA-06550: line 1, column 7:
PLS-00905: object INTRO_USER.TESTPROCEDURE is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

As you can see, I get the error code ORA-06550: line X column X.

What caused this error?

ORA-06550 Cause

ORA-06550 is caused by a PL/SQL compilation error – an error in your PL/SQL code.

The cause of the error is actually dependent on the error it is linked to.

It’s a bit of a decoy. It says “Hey, I’ve found an error, but your actual error is over there!”

As you might notice, when you get an ORA-06550 error, it is accompanied by a second error message just below it.

You should be able to see this if you’re running SQL Developer or Toad (or many other IDEs).

Go to View > Log, and a Log window should appear.

ORA-06550 line N column N Solution

If not, you can run the SHOW ERRORS command.

SHOW ERRORS;
Errors for PROCEDURE INTRO_USER.TESTPROCEDURE:
LINE/COL ERROR
-------- -------------------------------------------------------
4/3      PL/SQL: Statement ignored
4/16     PLS-00201: identifier 'SOMEOTHERVALUE' must be declared

This will show the error message that causes this error to appear, which could be one of many errors.

To resolve the ORA-06550 error, first fix the error that comes with it.

The error that comes with it is also more descriptive of the actual issue.

For example, in our example above, I also got a PLS-00201 error.

This was because I had mentioned a variable called someOtherValue but this was not declared anywhere.

To fix this, I would need to declare the variable, correct a typo if I spelt it wrong, or use another value.

Once you have fixed the error, recompile the code.

For example:

CREATE OR REPLACE PROCEDURE testProcedure AS
  textValue VARCHAR2(3);
BEGIN
  textValue := 'ABC';
END;
Procedure TESTPROCEDURE compiled
EXEC testProcedure;
PL/SQL procedure successfully completed.

Hopefully this article has helped you resolve the ORA-06550 error message.

DECLARE
    L_DATE_1 DATE :='2018-09-01';
    L_DATE_2 DATE :='2018-11-12';
    begin
    SELECT C."APPCM_PHOTO_CASE_MATERIAL_ID" ID,
           C.APPFE_EVENT_ID ev_id 
    FROM table_1 C
WHERE C.t_appcm_violation_date between L_DATE_1 and L_DATE_2

ошибка Error report —
ORA-06550: Строка 5, столбец 1:
PLS-00428: в этом предложении SELECT ожидается фраза INTO

Что хочет от меня, если я уже идентифицировал переменную?


    with period as (
        select
            to_date('2018-09-01','yyyy-mm-dd') L_DATE_1,
            to_date('2018-11-12','yyyy-mm-dd') L_DATE_2
        from
            dual
    )
 SELECT C.APPCM_PHOTO_CASE_MATERIAL_ID ID,
        C.APPFE_EVENT_ID ev_id 
 FROM period,table_1 C
 WHERE C.t_appcm_violation_date between L_DATE_1 and L_DATE_2

Вот, так я получил желаемое без ошибок. Как сделать аналогию через объявление локальной переменой ?

MaxU - stand with Ukraine's user avatar

задан 12 ноя 2018 в 17:55

максим ильин's user avatar

7

PLS-00428: в этом предложении SELECT ожидается фраза INTO

Сообщение об ошибке однозначно указывает, что надо объявить локальную переменную для результата и добавить её в запрос: SELECT ... INTO local_result FROM ....

Но в вопросе запрос явно вернёт не одну строку, поэтому тут нужен курсор и цикл.
Лучше неявный курсор, который неявно объявит переменную для результата в теле цикла.
Как-то так:

DECLARE
    L_DATE_1 DATE :='2018-09-01';
    L_DATE_2 DATE :='2018-11-12';
BEGIN
    for rec in (
        SELECT 
           C."APPCM_PHOTO_CASE_MATERIAL_ID" ID, C.APPFE_EVENT_ID ev_id
        FROM table_1 C
        WHERE C.t_appcm_violation_date between L_DATE_1 and L_DATE_2
        ) loop
        dbms_output.put_line ('fetched row:'||rec.id||','||rec.ev_id);
    end loop; 
END;

ответ дан 15 ноя 2018 в 9:48

0xdb's user avatar

0xdb0xdb

51.5k198 золотых знаков59 серебряных знаков237 бронзовых знаков

если вам просто нужно вывести на экран результат параметризированного запроса, то для задания переменных в SQLPLUS можно воспользоваться коммандой SQLPLUS: DEFINE:

DEFINE L_DATE_1 = to_date('2018-09-01','yyyy-mm-dd')
DEFINE L_DATE_2 = to_date('2018-11-12','yyyy-mm-dd')

SELECT C.APPCM_PHOTO_CASE_MATERIAL_ID ID,
        C.APPFE_EVENT_ID ev_id 
FROM period,table_1 C
WHERE C.t_appcm_violation_date between &L_DATE_1. and &L_DATE_2.

В чём разница между DECLARE и DEFINE:

  • DECLARE — предикат в PL/SQL, применяемый в анонимных SQL блоках.
  • DEFINE — нечто схожее с коммандами препроцессора в C/C++. DEFINE будет работать только в программе-клиенте (SQLPLUS, SQL Developer, SQLcl, etc). Программа-клиент заменит все вхождения таких «переменных» на их значения перед тем как послать запрос на сервер. Т.е. Oracle DB получит запрос с уже подставленными значениями.

ответ дан 16 ноя 2018 в 10:24

MaxU - stand with Ukraine's user avatar

2

Home » [Resolved] ORA-06550 PL SQL Error in Oracle

Ora-06550 error pl sql

ORA-06550 PL SQL Error in Oracle: While working on Oracle technologies, especially PL SQL or any tool or programming language interacting with the Oracle database, you might encounter ORA 06550 error.

What is this and how do we resolve it, We will look at it in this post.

Table of Contents

A Successful call to an existing database procedure

Examine the code in the screen shot

image ORA-06550 PL SQL Error in Oracle 1

set serveroutput on
 CREATE OR REPLACE PROCEDURE Ora06500test
    AS
      x number;
    BEGIN
      x := 10;
      dbms_output.put_line ('value of x '|| x);
    END;
 /
 

 Begin
 Ora06500test;
 end;
/
 

The above procedure is a simple procedure compiled successfully and when executed using an anonymous block it returns the value of x.

Doing a failed call due to ORA-06550 Error

Now let’s purposely invalidate this procedure by doing a syntax error

CREATE OR REPLACE PROCEDURE Ora06500test
    AS
      x number;
    BEGIN
      x := 10;
      dbms_output.putline ('value of x '|| x);
    END;
 /

Notice I removed the ( _ ) from put_line and made it as putline.

image 2 ORA-06550 PL SQL Error in Oracle 2

I compiled and saved the procedure ignoring the errors. and invalidating the object

ORA-06550 Error shows the line number and column number

Now If I execute the anonymous block it returns

image 3 ORA-06550 PL SQL Error in Oracle 3

Notice the ORA-06550. The error throws up along with the line number and column number.

Forms of ORA-06550 Error

Sometimes we get

  • PLS-00302: component ‘XYZ’ must be declared ORA-06550 : Means XYZ object is not present in the database or is a keyword that oracle is not able to differentiate.
  • PLS-00201 : Probable the variable was not declared.
  • PLS-00905: object EMPtable is invalid ORA-06550: line x, column x: , PL/SQL Statement ignored : check if the EMPtable is present and valid.
  • java.sql.SQLException: ORA-06550: after calling procedure from java code : The procedure may be invalidated.

Summary of ORA-06550 Error

So ORA-06550 is thrown when a procedure is invalidated due to some dependencies or changes. We need to fix it by seeing what is the error in the line number and compile the object again

ORA 06550 just points to the location in your PL SQL code but that line of code can have different kinds of errors, like Syntax issue, Pointing to an invalidated object, using a keyword, etc. So basically we need to figure out what the error reason is and then we have to apply the fix to make our code run.

FAQs on ORA-06550

When does ORA 06550 occur?

It occurs when a database object is invalidated or compiled with errors. i.e a PL/SQL compilation error was ignored.

How do you define ORA-06550 Error

ORA-06550 error is the location in the PL SQL code where the error is present.

Is fixing ORA-06550 easy?

Yes , Once you identify the reason at the Error location thrown you can fix easily.

More on EBS Apps Tech

Problem

When running a stored procedure in Cognos the user may encounter an UDA-SQL-0107 error message when running agianst Oracle.

Symptom

RQP-DEF-0177 An error occurred while performing operation
‘sqlOpenResult’ status=’-28′. UDA-SQL-0114 The cursor supplied to the
operation «sqlOpenResult» is inactive. UDA-SQL-0107 A general exception
has occurred during the operation «execute». ORA-06550: line 1, column
17: PLS-00302: component ‘xxx’ must be declared ORA-06550:
line 1, column 7: PL/SQL: Statement ignored

Cause

This is a defect or limitation with in Oracle. Schema names cannot have the same name as tables, views, functions or procedures.

Resolving The Problem

Rename the schema or stored procedure.

[{«Product»:{«code»:»SSEP7J»,»label»:»Cognos Business Intelligence»},»Business Unit»:{«code»:»BU059″,»label»:»IBM Software w\/o TPS»},»Component»:»—«,»Platform»:[{«code»:»PF002″,»label»:»AIX»},{«code»:»PF010″,»label»:»HP-UX»},{«code»:»PF016″,»label»:»Linux»},{«code»:»PF027″,»label»:»Solaris»},{«code»:»PF033″,»label»:»Windows»}],»Version»:»8.4.1;8.4;8.3;10.1″,»Edition»:»»,»Line of Business»:{«code»:»LOB10″,»label»:»Data and AI»}}]

Понравилась статья? Поделить с друзьями:
  • Oracle ошибка ora 01031
  • Ora 00604 ошибка на рекурсивном sql уровне
  • Ora 00257 ошибка архивации
  • Ora 00001 unique constraint ошибка
  • Or pmia 14 ошибка что это