Recently I had to write an oracle function, and the error ora-06575 popped up awfully a lot.
Usually it was because of missing colon from assignment, such as: z = 5 (vs. z := 5)
Or a missed ';' at the end of a statement.
Anyway, I was able to create the function, but it failed during execution with that error, and gave no hint as to where the problem was (except that it was in the function).
I wrote same function in MSSQL and Sybase, and both of those actually tried to point me to the place of any errors. So I figure I'm doing something wrong in Oracle - it can't just tell me 'there's an error'.
In oracle I have a statement like this:
CREATE OR REPLACE
FUNCTION...
I'm compiling the function from SQL developer by selecting the function, and pressing F9.
When I select a statement which executes the function, and press F9, I get the ora-06575 error.
If I press F5 to compile the function, it tells me:
ORA-24344: success with compilation error
Compiled.
So I found this website: http://www.dba-oracle.com/t_ora_24344_success_with_compilation_error.htm
But I can't seem to run 'show errors'. When I run it, I get no output that I can see.
Can that only work from sqlplus? I'm using SQL developer, I'd prefer to stick to SQL developer.
Is there something I'm missing? I want it to tell me where the error is.
SHOW ERRORS is a sql*plus command
You can also query the USER_ERRORS view
SELECT line, position, text
FROM user_errors
WHERE name = '<<your_object_name>>'
SHOW ERRORS works in SQL*Developer too (at least in the versions I've used recently, certainly 3.1). You mentioned in a comment that you're connected as SYS, so I really hope you're creating your function explicitly in another schema - I'd avoid this anyway just in case you forget one day, and modifying any of the pre-built schemas (SYS, SYSTEM etc.) is a bad idea. If so you need to prefix the errored object with the schema too:
create or replace function my_schema.x return number is
begin
return sysdate;
end;
/
show errors my_schema.x
When run as a script (F5) this says:
FUNCTION X compiled
Warning: execution completed with warning
3/8 PLS-00382: expression is of wrong type
3/1 PL/SQL: Statement ignored
The first two lines of the output come from the function compilation, the last two from show errors. You can also run the two statements separately with F9 to see the same results.
But I'm not sure how you're getting the ORA-24344, so maybe you're on an earlier version; and it's possible that won't work. A.B.Cade's solution will work whatever your client though.
Related
This is an example and i know this post too:
How to get input from user at runtime
When i run this code in sql developer with pl/sql:
DECLARE
a NUMBER;
BEGIN
a:=&a;
DBMS_OUTPUT.PUT_LINE(a);
end;
I get a prompt for my user input value and i see my input value on the script output.
Ok this works.
But i see the whole code and my input value.
A solution for exactly this example, no sqlplus, prompt or accept and not this post:
Provide a message prompt for user input in SQL Developer 3.1.07
Is it possible to deactivate the whole code output and only see my input value, is there a sql developer setting?
I'm using:
Oracle SQL Developer
Version 21.4.1.349
Build 349.1822
On a Windows 10 PRO
Oracle Database
21c Express(21.0.0.0.0)
Manage your output panel in SQL Developer:
Turns on|off verification
The VERIFY setting controls whether or not SQL*Plus displays before and after images of each line that contains a substitution variable.
SET VER[IFY] {OFF | ON}
Turns on|off feedback completely
The FEEDBACK setting controls whether SQL*Plus displays the number of records returned.You can set a threshold, below which you don't get any feedback regardless of whether the setting is on.
SET FEED[BACK] {OFF | ON | row_threshold}
Some Links:
set feedback off
SET FEEDBACK
SET VERIFY
Substitution variables, like your &a, are exclusively an SQL*Plus concept. The only reason SQL Developer knows what to do with it is that SQL Developer supports most of the SQL*Plus scripting language. So your "no sqlplus" requirement (in your question) is nonsensical. Any solution must be a SQL*Plus solution in one way or another.
What you are asking for is very simple. SQL*Plus supports a feature called verify, which does exactly what you don't want it to do: showing you the before and after versions of your code. By default it is on - all you need to do is to turn it off before you run your code.
Another thing is the displaying of just your value in the output. By default the serveroutput feature is off; to see the output from dbms_output.put_line() you must turn it on. It is not clear if you have done that.
So, before you run your code, you must run these two SQL*Plus commands; the first one is the one you were asking about, the second one is to see the output from put_line(). Note that both are SQL*Plus commands; they are not terminated with semicolon (although SQL Developer will not throw an error if they are).
set verify off
set serveroutput on
As an aside, SQL*Plus tolerates some syntax errors, so your code will run as written (unless it's surrounded by other code); but technically, you are missing a forward slash on a line by itself at the end of your code, to indicate the end of a PL/SQL block.
In the editor window:
set verify off
set serveroutput on
DECLARE
a NUMBER;
BEGIN
a:=&a;
DBMS_OUTPUT.PUT_LINE(a);
end;
/
Pop-up window asks for value for a; I enter the value 5 and hit the OK button
Script output (lower pane):
5
PL/SQL procedure successfully completed.
If your next question is "how do I make it so that PL/SQL procedure successfully completed does not appear in the output window" - the answer is similar:
set feedback off
(also a SQL*Plus command, understood by SQL Developer, and not terminated with a semicolon).
You might not believe it but I searched the questions on stackoverflow to find an answer for the following question:
I can compile this function
create or replace function cart_distance(x1 in number,x2 in number,y1 in number,y2 in number)
return number is
begin
return sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
end;
But if I want to test it the compiler gives the following error "Encountered the symbol SELECT"
SELECT cart_distance(2,3,4,5) FROM DUAL;
The function and the query are written in the SQL worksheet and I press the "Run statement" option. (I'm very unexperienced with the program)
Try Selecting the query text and pressing the "Run" button. From the error which you have posted, I understand that it is executing the function compilation in the same Run as executing the query. Or better - try in a separate worksheet. Make sure your connection is correct.
I get an Oracle error ORA-6502 Character string buffer too small in my code at the statement below
EXECUTE IMMEDIATE 'BEGIN :project_id :=
Activity_API.Get_Project_Id(:activity_seq); END;'
USING OUT project_id_, activity_seq_
project_id_ - this is a local variable in the function
activity_seq_ -- this is an IN parameter to the function.
I don't understand the cause of the error. Besides, the error is not consistently showing up.
Please help me know what am I missing out.
Thanks.
Generally this error means that you have a VARCHAR(N) variable somewhere in your code and you tried to assign VARCHAR(N+x) value to it. It may happens anywhere, say:
size of activity_seq_ is too big for function local variable
size of project_id_ is too small for function result
there is some oversized value used into the function itself
etc.
Sometimes it may happens because of multibyte character set used, say, if value is VARCHAR(N chars) while assignment target is VARCHAR(n bytes). Anyway, you should just debug it. Use PL/SQL Developer or any other tool which can trace stored procedures row by row, run your statement into the test window and see what happens, where and why.
I am trying to debug a package with in the SQL Developer. The method that i am trying to debug takes 2 parameters
PROCEDURE procedure_name (dblink IN CHAR, bDebug IN BOOLEAN DEFAULT FALSE)
When i click on "Debug" icon, it asks for inputs that i need to give to this procedure. I give
dblink:='linkname';
bDebug:=TRUE;
but when it starts debugging, I see the value of dblink as
'linkname
'
i.e. linkname, lots of spaces and then the ending quote. so when in code i try to do this
`strSrc VARCHAR(120) := 'tablename'||dblink;`
it gives me error that buffer is to small, which makes sense. but why SQL Developer is doing so? how to fix it?
I am guessing your padding is coming from how SQL Developer is defining its variable to bind with (it is probably defining it as a CHAR(4000)). For now, you should be able to get around this in your test code by putting trim() around the dblink variable:
strSrc VARCHAR(120) := 'tablename'||trim(dblink);
Note that this would normally not be needed if the procedure was passed a literal (or a correctly sized CHAR variable, a VARCHAR, etc), like the production code is probably doing.
For debugging purposes, create a wrapper procedure that accepts a VARCHAR2 parameter, then passes it to your procedure; then you debug it in SQL Developer by calling your wrapper.
I have an Oracle script that looks like the following:
variable L_kSite number;
variable L_kPage number;
exec SomeStoredProcedureThatReturnsASite( :L_kSite );
exec SomeStoredProcedureThatAddsAPageToTheSite( :L_kSite, :L_kPage );
update SiteToPageLinkingTable
set HomePage = 1
where kSite = :L_kSite and kPage = :L_kPage;
Supposedly the last statement is a valid use of a bind variable but when I try to run the script I get this on the last line:
SQL Error: Missing IN or OUT parameter at index:: 1
I'm not sure how to proceed here as I'm not especially proficient in Oracle.
I had a similar error on my side when I was using JDBC in Java code.
According to this website (the second awnser) it suggest that you are trying to execute the query with a missing parameter.
For instance :
exec SomeStoredProcedureThatReturnsASite( :L_kSite );
You are trying to execute the query without the last parameter.
Maybe in SQLPlus it doesn't have the same requirements, so it might have been a luck that it worked there.
Based on the comments left above I ran this under sqlplus instead of SQL Developer and the UPDATE statement ran perfectly, leaving me to believe this is an issue in SQL Developer particularly as there was no ORA error number being returned. Thank you for leading me in the right direction.
I think its related with jdbc.
I have a similar problem (missing param) when I have a where condition like this:
a = :namedparameter and b = :namedparameter
It's ok, When I have like this:
a = :namedparameter and b = :namedparameter2 (the two param has the same value)
So it's a problem with named parameters.
I think there is a bug around named parameter handling, it looks like if only the first parameter get the right value, the second is not set by driver classes. Maybe its not a bug, only I don't know something, but anyway I guess that's the reason for the difference between the SQL dev and the sqlplus running for you, because as far as I know SQL developer uses jdbc driver.
I got the same error and found the cause to be a wrong or missing foreign key. (Using JDBC)
I had this error because of some typo in an alias of a column that contained a questionmark (e.g. contract.reference as contract?ref)
I had issue in SQL Developer because I was using binds incorrectly. Was using this, copied from log:
variable = ?
should be
variable = :variable
Now SQL Developer prompts me for values.
I got the same error sporadically appearing on some user setup, while others were content with the same report. I had my parameters written in altered case and with nordic letters, for example: Henkilö. I changed them to HENKILO, using only upper case and no nordics, and it did the trick.
The driver is some unknown or varying JDBC version to Oracle.
My error desc was originated from some 3rd party bin:
Excel Plugin Error: Failed executing statement (Missing IN or OUT parameter at index:: 4)
SQL Statement failed. Please verify and correct it!