validate_conversion does not compile in package but as standalone procedure - plsql

I'm getting an compilation error, when I try to use validate_conversion in plsql.
Error: PLS-00801: Interner Fehler [*** ASSERT at file pdz2.c, line 5361; The_Exp is null.; TEST__DBNAME__B__2920081[10, 3]]
Line: 10
Text: END;
Funny thing is, this error only occurs if compiled in a package. An MWE is:
CREATE OR REPLACE PACKAGE test IS
PROCEDURE my_VALIDATE_CONVERSION(asNbr VARCHAR2);
END test;
/
CREATE OR REPLACE PACKAGE BODY test IS
PROCEDURE my_VALIDATE_CONVERSION(asNbr VARCHAR2) IS
BEGIN
CASE VALIDATE_CONVERSION(asNbr AS NUMBER, '999999D99', ' NLS_NUMERIC_CHARACTERS = '',.''')
WHEN 1 THEN
DBMS_OUTPUT.PUT_LINE('He');
ELSE
DBMS_OUTPUT.PUT_LINE('Cu');
END CASE;
END;
BEGIN
NULL;
END test;
/
If compiled as standalone procedure my_VALIDATE_CONVERSION it works just fine.
CREATE OR REPLACE PROCEDURE my_VALIDATE_CONVERSION(asNbr VARCHAR2) IS
BEGIN
CASE VALIDATE_CONVERSION(asNbr AS NUMBER, '999999D99', ' NLS_NUMERIC_CHARACTERS = '',.''')
WHEN 1 THEN
DBMS_OUTPUT.PUT_LINE('He');
ELSE
DBMS_OUTPUT.PUT_LINE('Cu');
END CASE;
END;
What's going on here?
Im using:
PL/SQL Developer Version 13.0.6.1911 (64 bit)
Oracle Database 18c Standard Edition 2 Release 18.0.0.0.0

Seems like a bug in the database. I would try upgrading to Oracle 19c or apply the latest patch set to your database. I was able to compile your package in my database (version 19.6.0.0.0) without any errors.

This internal failure for sure will happen with the procedure compilation. The fact that it did not suggests that the compilation of the package was done with PLSQL_DEBUG turned on, and the compilation of the procedure was done without.

When you use this function in package in
Select Validate_Conversion(String AS Number) Into variable From Dual, is compiled successful.
Select Validate_Conversion(p_Oran AS Number) Into IsNumeric From dual; --COMPILED
IsNumeric := Validate_Conversion(p_Oran AS Number); --FAILURE
If Validate_conversion(p_Oran AS Number) = 0 Then --FAILURE
enter image description here

Related

What is causing the syntax error in my sql stored procedure?

I'm pretty new at stored procedures and I get the following syntax error in my code:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DELIMITER //CREATE PROCEDURE sp_create_probe(IN matrix_id INT, IN oligo_id IN...' at line 2
Here's the code for my procedure:
DELIMITER //
CREATE PROCEDURE sp_create_probe(IN matrix_id INT, IN oligo_id INT)
BEGIN
SET FOREIGN_KEY_CHECKS=0;
INSERT INTO Probes (oligo, microarray) VALUES (oligo_id, matrix_id);
SET FOREIGN_KEY_CHECKS=1;
END //
DELIMITER ;
Hope someone can help me out
EDIT:
Well I ended up fixing it. Classic noob mistake.
I had this line before the code you see above:
DROP PROCEDURE IF EXISTS sp_create_probe
Didn't copy that line into the post for some reason but it's missing the ";" at the end. That fixed it.

Any way to call odi package or interface through the oracle database

I need to execute the odi package/mapping through database parametric procedure along with that i need to capture the package/Mapping status(Failed/Passed) in procedure .
ODI Version : 12c
i have tried the mentioned code and it's showing the attached error message:
You can do it in two steps:
Create a plsql procedure that will run a shell script/line command
The line command will call an ODI scenario of a map.
You can achieve the first point by reading this.
PL/SQL procedure that executes a command line:
create or replace procedure host( cmd in varchar2 )
as
status number;
begin
dbms_pipe.pack_message( cmd );
status := dbms_pipe.send_message( 'HOST_PIPE' );
if ( status <> 0 ) then raise_application_error( -20001, 'Pipe error' );
end if;
end;
/
Second point it's written in the ODI documentation, at chapter 7.3.2 Executing Scenario from command line.

how to guess random values from user in pl sql

could someone help?
declare
ran int:=dbms_random.value(1,5);
num number;
begin
dbms_output.put_line('enter the num');
num:=&num;
if num<ran then
&dbms_output.put_line('Your num is less'||ran);
elsif num>ran then
&dbms_output.put_line('Your num is greater'||ran);
else
&dbms_output.put_line('Equal'||num||'='||ran);
end if;
while num=ran loop
&dbms_output.put_line('enter the num');
num:=&num;
end loop;
end;
there is some problems ?
what is wrong?
how to guess random numbers what's wrong
You would need to prompt for the number separately, and then use the value in a PL/SQL block once you have it.
Substitution variables are a SQL*Plus feature and not part of the core PL/SQL language (which is not interactive), so the following works in SQL*Plus. Client applications such as PL/SQL Developer emulate it to varying degrees, so it may also work in those (for example in PL/SQL Developer you would run it in a Command window, or in TOAD you'd use the 'Run as script' option). You may also be able to do something in Apex or using a third party scripting language such as Perl, Python, PowerShell etc.
accept mynumber number format 0 prompt "Enter a number between 1 and 5: "
declare
ran int := dbms_random.value(1, 5);
begin
if &mynumber < ran then
dbms_output.put_line('&mynumber is less than ' || ran);
elsif &mynumber > ran then
dbms_output.put_line('&mynumber is greater than ' || ran);
else
dbms_output.put_line('&mynumber = ' || ran);
end if;
end;
/
I'm not sure what the loop in your example is supposed to do. If you want it to prompt for input repeatedly in a loop you will need to write something in a separate scripting language or another development framework.

ERROR: The symbol "(" was substituted for "VARCHAR2" to continue

I am trying to compile this package body:
CREATE OR REPLACE PACKAGE BODY package_1 AS
PROCEDURE procedure_1 (P_HOST IN VARCHAR2, P_USER IN VARCHAR2, P_NAME IN VARCHAR2)
IS
BEGIN
SELECT HOSTNAME, USERS, PS_NAME
INTO P_HOST, P_USER, P_NAME
FROM PS_COLLECT
WHERE NOT EXISTS
(
SELECT HOSTNAME, USERS, PS_NAME
FROM PS_MASTER
WHERE PS_MASTER.HOSTNAME = PS_COLLECT.HOSTNAME
AND PS_MASTER.USERS = PS_COLLECT.USERS
AND PS_MASTER.PS_NAME = PS_COLLECT.PS_NAME
);
END procedure_1;
END package_1;
But I am getting this error
The symbol "(" was substituted for "VARCHAR2" to continue.
I am a newbie int PL/SQL..please help :)
I wouldn't expect this to cause the exact error you're seeing, but one definite problem with your code is that you are specifying IN mode for the parameters, but then trying to assign values to them inside the procedure. It looks like you should change the mode to OUT for all three parameters (in both the header and the body).
If that alone does not resolve your issue, I suggest posting the modified text of both the CREATE PACKAGE and CREATE PACKAGE BODY statements.

Accessing Bind Variable in PL/SQL

I am trying to run a program in the Oracle express edition editor. When I execute the program, I get an error
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Can anyone help me understand why I am getting an error and how to fix the code?
VARIABLE gvn_total_salary NUMBER;
DECLARE
vn_base_salary NUMBER := 3000;
vn_bonus NUMBER := 1000;
BEGIN
:gvn_total_salary := vn_base_salary + vn_bonus;
END;
The output I'm getting
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Run By SYSTEM
Parsing Schema SYSTEM
Script Started Thursday, April 26, 2012
3 seconds ago
Elapsed time 0.01 seconds
Statements Processed 1
Successful 0
With Errors 1
With the declaration of the bind variable, that code works fine for me in SQL*Plus
SQL> VARIABLE gvn_total_salary NUMBER;
SQL> DECLARE
2 vn_base_salary NUMBER := 3000;
3 vn_bonus NUMBER := 1000;
4 BEGIN
5 :gvn_total_salary := vn_base_salary + vn_bonus;
6 END;
7 /
PL/SQL procedure successfully completed.
SQL> print gvn_total_salary
GVN_TOTAL_SALARY
----------------
4000
Can you connect to the database using SQL*Plus and run the same thing?
What are you actually trying to accomplish? This script won't execute in sqlplus or Oracle Developer or any PL/SQL execution environment I can think of. In fact, I don't understand how you are passing the bind variable :gvn_total_salary and how you can get the error you are describing. You should get something like "bind variable gvn_total_salary" not declared.

Resources