ORA-31600 when using scan_percent with dbms_comparison.compare - oracle

I'm using Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production and I've created a comparison using this code :
BEGIN
DBMS_COMPARISON.CREATE_COMPARISON(
comparison_name => 'test2',
schema_name => 'someSchema',
object_name => 'someTable',
dblink_name => 'MYORACLEDB',
scan_mode => 'RANDOM',
scan_percent => 50);
END;
WHen i execute the comparison using
DECLARE
consistent BOOLEAN;
scan_info DBMS_COMPARISON.COMPARISON_TYPE;
BEGIN
consistent := DBMS_COMPARISON.COMPARE(
comparison_name => 'test2',
scan_info => scan_info,
perform_row_dif => FALSE);
END;
I get the following error message :
ORA-31600: invalid input value 1 for parameter data type in function a_plus_b_mul_c_minus_d
ORA-06512: at "SYS.DBMS_COMPARISON", line 547
ORA-06512: at line 7
31600. 00000 - "invalid input value %s for parameter %s in function %s"
*Cause: A NULL or invalid value was supplied for the parameter.
*Action: Correct the input value and try the call again.
When i run a comparison with the full scan mode i've got no error.
Anybody encountered such issue ?

Related

datapump import into OCI autonomous db shared infrastructure

on attempting to import a schema from OCI object storage using dbms_datapump
DECLARE
-- replace with your values
exported_schema VARCHAR2(64) := 'DEMO';
import_schema VARCHAR2(64) := 'DEMO'; -- in case you want to remap schema
data_pump_dir VARCHAR2(64) := 'DATA_PUMP_DIR';
dump_file_name VARCHAR2(256) := <object storage url>;
credential_name VARCHAR2(64) := 'OBJECT_STORE_CRED';
parallel NUMBER := 4;
job_handle NUMBER;
job_name VARCHAR2(64);
job_status VARCHAR2(128);
output_message VARCHAR2(1024);
l_sts KU$_STATUS;
v_logs ku$_LogEntry;
v_row PLS_INTEGER;
BEGIN
job_name := dbms_scheduler.generate_job_name('import_');
job_handle := dbms_datapump.open(operation => 'IMPORT', job_mode => 'SCHEMA', job_name => job_name);
dbms_datapump.add_file(handle => job_handle, filename => dump_file_name, directory => credential_name, filetype => dbms_datapump.ku$_file_type_uridump_file);
dbms_datapump.add_file(handle => job_handle, filename => import_schema || '_import.log', directory => data_pump_dir, filetype => 3);
--dbms_datapump.metadata_remap(job_handle, 'REMAP_SCHEMA', exported_schema, import_schema);
dbms_datapump.metadata_filter(handle => job_handle, name => 'SCHEMA_EXPR', value => 'IN(''' || exported_schema || ''')');
dbms_datapump.set_parallel(handle => job_handle, degree => parallel);
dbms_datapump.start_job(handle => job_handle, skip_current => 0, abort_step => 0);
dbms_datapump.wait_for_job(handle => job_handle, job_state => job_status);
output_message := 'Data Pump Import Execution: ''' || job_status || '''';
dbms_output.put_line(output_message);
EXCEPTION
WHEN OTHERS THEN
dbms_datapump.get_status(NULL, 8, 0, job_status, l_sts);
v_logs := l_sts.error;
v_row := v_logs.FIRST;
LOOP
EXIT WHEN v_row IS NULL;
dbms_output.put_line('logLineNumber=' || v_logs(v_row).logLineNumber);
dbms_output.put_line('errorNumber=' || v_logs(v_row).errorNumber);
dbms_output.put_line('LogText=' || v_logs(v_row).LogText);
v_row := v_logs.NEXT(v_row);
END LOOP;
RAISE;
END;
/
the following error occurrs
ORA-31623: um job não está associado a esta sessão por meio do handle especificado
ORA-06512: em "SYS.DBMS_DATAPUMP", line 4769
ORA-06512: em "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: em "SYS.DBMS_DATAPUMP", line 4515
ORA-06512: em "SYS.DBMS_DATAPUMP", line 6149
ORA-06512: em line 36
ORA-39001: valor de argumento inválido
ORA-06512: em "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: em "SYS.DBMS_DATAPUMP", line 4951
ORA-06512: em "SYS.DBMS_DATAPUMP", line 5202
ORA-06512: em line 20
Error at Line: 7 Column: 0
I used this program before to import schema using datapump file, but it is no longer working.
I also tried using oracle client 19.17 from my local machine with the following command
impdp admin/<password>#serviceName credential=OBJECT_STORE_CRED directory=data_pump_dir dumpfile=<object storage url> parallel=2 encryption_pwd_prompt=yes exclude=cluster,indextype,db_link
and got the following error
Import: Release 21.0.0.0.0 - Production on Sex Jan 6 16:49:53 2023
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle and/or its affiliates. All rights reserved.
Conectado a: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
UDI-06550: operaþÒo gerou erro ORACLE 6550
ORA-06550: linha 1, coluna 72:
PL/SQL: ORA-00942: a tabela ou view nÒo existe
ORA-06550: linha 1, coluna 42:
PL/SQL: SQL Statement ignored
Any suggestion about what is going wrong? Is there another method to import into autonomous database?
My read of this is that the error in the first case is saying that the parameter for this call (line 20 of your program) is not valid:
dbms_datapump.add_file(handle => job_handle, filename => dump_file_name, directory => credential_name, filetype => dbms_datapump.ku$_file_type_uridump_file);
When this happens, it could be the dumpfile name or the credential that is not valid for this operation. There can be other causes for the UDI error, as detailed in "How to resolve the Data Pump error ORA-31623 UDE-31623 (a job is not attached to this session via the specified handle) ? (Doc ID 1907256.1)" (https://support.oracle.com/epmos/faces/DocContentDisplay?id=1907256.1) but with the combination of the secondary error, and of the issue with the command-line version of the operation as well, I think it likely that the URI for the dumpfile and/or the credential being specified are not valid.
I'm not as sure about the second case, though, because you mention using the 19.7 client. The banned shows the 21.3 client being used, connecting to the 19c server. While the 21c client was made backward compatible, I would want to see the latest client in use to be sure it isn't a bug that has already been fixed. The latest instant client is version 21.8.

Data Pump import fails with "job does not exist"

Can anyone help with this problem? I'm trying to use datapump to load a dump file created but whenever I try, I get the following code:
DECLARE
hdnl NUMBER;
status VARCHAR2(20);
BEGIN
hdnl := dbms_datapump.open (operation => 'IMPORT', job_mode => 'TABLE', version => 'COMPATIBLE');
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'import.log', directory => 'DP_DIR', filetype => dbms_datapump.ku$_file_type_log_file);
DBMS_DATAPUMP.ADD_FILE(handle => hdnl, filename => 'latest.dmp', directory => 'DP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.START_JOB(handle => hdnl);
DBMS_DATAPUMP.WAIT_FOR_JOB(hdnl,status);
end;
/
I'm getting this error:
Error report -
ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 1852
ORA-06512: at "SYS.DBMS_DATAPUMP", line 6793
ORA-06512: at line 5
31626. 00000 - "job does not exist"
*Cause: An invalid reference to a job which is no longer executing,
is not executing on the instance where the operation was
attempted, or that does not have a valid Master Table.
Refer to any following error messages for clarification.
*Action: Start a new job, or attach to an existing job that has a
valid Master Table.
Any idea?
Regards

DBMS_AQADM.PURGE_QUEUE_TABLE with the error ORA-01001: invalid cursor and ORA-06512: at "SYS.DBMS_AQ_INV"

While attempting to manually execute the command below with user APPS (owner of WF_BPEL_QTAB queue) the error informed is occurring.
We did all the necessary research and the queue has no indexes (as some solutions suggest).
Command:
declare
l_purge_options dbms_aqadm.aq$_purge_options_t;
begin
l_purge_options.Block := False;
DBMS_AQADM.PURGE_QUEUE_TABLE(queue_table => 'APPS.WF_BPEL_QTAB'
,purge_condition => 'ENQ_TIME < trunc(sysdate) - 3
,purge_options => l_purge_options);
end;
Error:
ORA-00604: error occurred at recursive SQL level 1
ORA-01001: invalid cursor
ORA-06512: at "SYS.DBMS_AQ_INV", line 208
ORA-00918: column ambiguously defined
ORA-06512: at "SYS.DBMS_AQADM", line 1668
ORA-06512: at line 5
When using criteria from the queue table, you need to use the alias 'qtview'. Hence
declare
l_purge_options dbms_aqadm.aq$_purge_options_t;
begin
l_purge_options.Block := False;
DBMS_AQADM.PURGE_QUEUE_TABLE(queue_table => 'APPS.WF_BPEL_QTAB'
,purge_condition => 'qtview.ENQ_TIME < trunc(sysdate) - 3
,purge_options => l_purge_options);
end;

Issue creating data pump export job from sqldeveloper

I am trying to create data pump export using oracle sql developer wizard below are the grants provided to the user from which I am trying to setup data pump export
grant create session, create table, create procedure, exp_full_database, imp_full_database to TESTE;
grant read, write on directory DOCUMENTS to TESTE;
grant read, write on directory DATA_PUMP_DIR to TESTE;
but after completing wizard i get below error
...
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
dbms_output.put_line('REMOVE FINAL TRACE TEXT');
Raise;
END;
Error report -
ORA-31626: job does not exist
ORA-06512: at line 77
31626. 00000 - "job does not exist"
*Cause: An invalid reference to a job which is no longer executing,
is not executing on the instance where the operation was
attempted, or that does not have a valid Master Table.
Refer to any following error messages for clarification.
*Action: Start a new job, or attach to an existing job that has a
valid Master Table.
here is the plsql code generated by wizard at the end
set scan off
set serveroutput on
set escape off
whenever sqlerror exit
DECLARE
h1 number;
errorvarchar varchar2(100):= 'ERROR';
tryGetStatus number := 0;
begin
h1 := dbms_datapump.open (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'EXPORT_JOB_SQLDEV_944', version => 'COMPATIBLE');
tryGetStatus := 1;
dbms_datapump.set_parallel(handle => h1, degree => 1);
dbms_datapump.add_file(handle => h1, filename => 'EXPDAT-'||to_char(sysdate,'yyyy-mm-dd-hh24_mi_ss')||'.LOG', directory => 'DATA_PUMP_DIR', filetype => 3);
dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 1);
dbms_datapump.metadata_filter(handle => h1, name => 'SCHEMA_EXPR', value => 'IN(''MERCHANDISER'')');
dbms_datapump.add_file(handle => h1, filename => 'EXPDAT%U-'||to_char(sysdate,'yyyy-mm-dd-hh24_mi_ss')||'.DMP', directory => 'DATA_PUMP_DIR', filesize => '100M', filetype => 1);
dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1);
dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC');
dbms_datapump.set_parameter(handle => h1, name => 'ESTIMATE', value => 'BLOCKS');
dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0);
dbms_datapump.detach(handle => h1);
errorvarchar := 'NO_ERROR';
EXCEPTION
WHEN OTHERS THEN
BEGIN
IF ((errorvarchar = 'ERROR')AND(tryGetStatus=1)) THEN
DBMS_DATAPUMP.DETACH(h1);
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
RAISE;
END;
/
I have also tried below command in bash
expdp TESTE/TESTEr#localhost schemas=TESTE directory=documents dumpfile=test.dmp logfile=test.log
and got below error
Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
ORA-31626: job does not exist
ORA-31637: cannot create job SYS_EXPORT_SCHEMA_06 for user MERCHANDISER
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT_INT", line 798
ORA-06550: line 1, column 7:
PLS-00331: illegal reference to SYS.SYS
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
any idea what is causing issue

How can I use Oracle SQL developer to run stored procedures?

* EDIT6: * This is what ended up working for me (from accepted answer):
var ret1 number
var tran_cnt number
var msg_cnt number
var rc refcursor
exec :tran_cnt := 0
exec :msg_cnt := 123
exec get_account(Vret_val => :ret1, Vtran_count => :tran_cnt, Vmessage_count => :msg_cnt, Vaccount_id => 1, rc1 => :rc)
print :tran_cnt
print :msg_cnt
print :rc
The SQL Developer makes this super-hard / impossible?. I do not care if the utility is command-line-based; I just want to be able to run and view it quickly. It would be nice if it captured errors well as well. it would be nice to be able to log in gradually(interactively), as well as specifying everything at once (similar to how a typical ftp / sftp cmd-based client works).
My platform is Windows Server 2008 + Cygwin.
EDIT: Perhaps you would know how to script this using Python?
EDIT 2: In MSFT SQL server I can simply type this:
get_user 1;
then highlight it and hit F5, and I get:
login name
NULL Somename
printed to the output window. The Oracle SQL developer does not help with this at all. I am not sure how to pass in a 1, I am not sure how to see the actual rows/records that come back.
EDIT3: When I type just var rc refcursor; and select it and run it, I get this error (GUI):
An error was encountered performing the requested operation:
ORA-00900: invalid SQL statement
00900.00000 - "invalid SQL statement"
* Cause:
* Action:
Vendor code 900Error at Line: 2
EDIT4:
I am trying to run a procedure the definition of which starts like this:
create or replace procedure get_account
(
Vret_val out number,
Vtran_count in out number,
Vmessage_count in out number,
Vaccount_id IN NUMBER
, rc1 in out sys_refcursor
)as
begin
...
I get an error:
Error starting at line 2 in command:
exec :rc := get_account(1)
Error report:
ORA-06550: line 1, column 24:
PLS-00306: wrong number or types of arguments in call to 'GET_ACCOUNT'
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:
rc
------
I am so close ... please help.
* EDIT 5: *
Script that I am running (functionally the same), the error was always the same:
var ret1 number
var tran_cnt number
var msg_cnt number
var rc refcursor
exec :tran_cnt := 0
exec :msg_cnt := 123
exec get_account(Vret_val => :ret1, Vtran_count => :tran_cnt, Vmessage_count => :msg_cnt, Vaccount_id => 1, rc1 => rc)
Script Output (on F5) (Could be several messages from several runs.):
Error report:
ORA-06550: line 1, column 134:
PLS-00201: identifier 'RC' must be declared
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:
anonymous block completed
anonymous block completed
Error starting at line 7 in command:
exec get_account(Vret_val => :ret1, Vtran_count => :tran_cnt, Vmessage_count => :msg_cnt, Vaccount_id => 1, rc1 => rc)
Error report:
ORA-06550: line 1, column 134:
PLS-00201: identifier 'RC' must be declared
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:
anonymous block completed
anonymous block completed
Error starting at line 7 in command:
exec get_account(Vret_val => :ret1, Vtran_count => :tran_cnt, Vmessage_count => :msg_cnt, Vaccount_id => 1, rc1 => rc)
Error report:
ORA-06550: line 1, column 134:
PLS-00201: identifier 'RC' must be declared
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:
Why does it say line 1, column 134? No line stretched that far ...
Not only is there a way to do this, there is more than one way to do this (which I concede is not very Pythonic, but then SQL*Developer is written in Java ).
I have a procedure with this signature: get_maxsal_by_dept( dno number, maxsal out number).
I highlight it in the SQL*Developer Object Navigator, invoke the right-click menu and chose Run. (I could use ctrl+F11.) This spawns a pop-up window with a test harness. (Note: If the stored procedure lives in a package, you'll need to right-click the package, not the icon below the package containing the procedure's name; you will then select the sproc from the package's "Target" list when the test harness appears.) In this example, the test harness will display the following:
DECLARE
DNO NUMBER;
MAXSAL NUMBER;
BEGIN
DNO := NULL;
GET_MAXSAL_BY_DEPT(
DNO => DNO,
MAXSAL => MAXSAL
);
DBMS_OUTPUT.PUT_LINE('MAXSAL = ' || MAXSAL);
END;
I set the variable DNO to 50 and press okay. In the Running - Log pane (bottom right-hand corner unless you've closed/moved/hidden it) I can see the following output:
Connecting to the database apc.
MAXSAL = 4500
Process exited.
Disconnecting from the database apc.
To be fair the runner is less friendly for functions which return a Ref Cursor, like this one: get_emps_by_dept (dno number) return sys_refcursor.
DECLARE
DNO NUMBER;
v_Return sys_refcursor;
BEGIN
DNO := 50;
v_Return := GET_EMPS_BY_DEPT(
DNO => DNO
);
-- Modify the code to output the variable
-- DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
END;
However, at least it offers the chance to save any changes to file, so we can retain our investment in tweaking the harness...
DECLARE
DNO NUMBER;
v_Return sys_refcursor;
v_rec emp%rowtype;
BEGIN
DNO := 50;
v_Return := GET_EMPS_BY_DEPT(
DNO => DNO
);
loop
fetch v_Return into v_rec;
exit when v_Return%notfound;
DBMS_OUTPUT.PUT_LINE('name = ' || v_rec.ename);
end loop;
END;
The output from the same location:
Connecting to the database apc.
name = TRICHLER
name = VERREYNNE
name = FEUERSTEIN
name = PODER
Process exited.
Disconnecting from the database apc.
Alternatively we can use the old SQLPLus commands in the SQLDeveloper worksheet:
var rc refcursor
exec :rc := get_emps_by_dept(30)
print rc
In that case the output appears in Script Output pane (default location is the tab to the right of the Results tab).
The very earliest versions of the IDE did not support much in the way of SQL*Plus. However, all of the above commands have been supported since 1.2.1. Refer to the matrix in the online documentation for more info.
"When I type just var rc refcursor;
and select it and run it, I get this
error (GUI):"
There is a feature - or a bug - in the way the worksheet interprets SQLPlus commands. It presumes SQLPlus commands are part of a script. So, if we enter a line of SQL*Plus, say var rc refcursor and click Execute Statement (or F9 ) the worksheet hurls ORA-900 because that is not an executable statement i.e. it's not SQL . What we need to do is click Run Script (or F5 ), even for a single line of SQL*Plus.
"I am so close ... please help."
You program is a procedure with a signature of five mandatory parameters. You are getting an error because you are calling it as a function, and with just the one parameter:
exec :rc := get_account(1)
What you need is something like the following. I have used the named notation for clarity.
var ret1 number
var tran_cnt number
var msg_cnt number
var rc refcursor
exec :tran_cnt := 0
exec :msg_cnt := 123
exec get_account (Vret_val => :ret1,
Vtran_count => :tran_cnt,
Vmessage_count => :msg_cnt,
Vaccount_id => 1,
rc1 => :rc )
print tran_count
print rc
That is, you need a variable for each OUT or IN OUT parameter. IN parameters can be passed as literals. The first two EXEC statements assign values to a couple of the IN OUT parameters. The third EXEC calls the procedure. Procedures don't return a value (unlike functions) so we don't use an assignment syntax. Lastly this script displays the value of a couple of the variables mapped to OUT parameters.
I am not sure how to see the actual
rows/records that come back.
Stored procedures do not return records. They may have a cursor as an output parameter, which is a pointer to a select statement. But it requires additional action to actually bring back rows from that cursor.
In SQL Developer, you can execute a procedure that returns a ref cursor as follows
var rc refcursor
exec proc_name(:rc)
After that, if you execute the following, it will show the results from the cursor:
print rc
My recommendation is TORA
Have you heard of "SQuirreL SQL Client"?
http://squirrel-sql.sourceforge.net/
There are two possibilities, both from Quest Software, TOAD & SQL Navigator:
Here is the TOAD Freeware download: http://www.toadworld.com/Downloads/FreewareandTrials/ToadforOracleFreeware/tabid/558/Default.aspx
And the SQL Navigator (trial version): http://www.quest.com/sql-navigator/software-downloads.aspx

Resources