Creating a CSV of a pl/sql procedure
Hello worldI would like to know how to write a pl/sql procedure, where I need to check if they are all records in a table 'Table A' say
If they are all records in the Table 'A', then we need to write these records in the Table 'A' in the CSV file.
Is there no record then we insert a record in the CSV file that 'no records are in the 'table A'.
Could someone please help?
Thanks in advance
see this
OPS$tkyte@8i > create or replace procedure dump_table_to_csv (p_tname in varchar2,
2 p_dir in varchar2,
3 p_filename in varchar2)
4 is
utl_file.file_type l_output 5;
6 whole l_theCursor default dbms_sql.open_cursor;
l_columnValue 7 varchar2 (4000);
8 whole l_status;
9 l_query varchar2 (1000)
10 by default ' select * from '. p_tname;
11 l_colCnt number: = 0;
l_separator 12 varchar2 (1);
13 l_descTbl dbms_sql.desc_tab;
14 start
15 l_output: = utl_file.fopen (p_dir, p_filename, 'w');
16 immediate execution "alter session set nls_date_format =" dd-mon-yyyy hh24:mi:ss ""
';
17
18 dbms_sql.parse (l_theCursor, l_query, dbms_sql.native);
19 dbms_sql.describe_columns (l_theCursor, l_colCnt, l_descTbl);
20
21 because I in 1... l_colCnt loop
22 utl_file.put (l_output, l_separator |) '"' || l_descTbl (i) .col_name | '"'
);
23 dbms_sql.define_column (l_theCursor, i, l_columnValue, 4000);
24 l_separator: = ', ';
25 end of loop;
26 utl_file.new_line (l_output);
27
28 l_status: = dbms_sql.execute (l_theCursor);
29
30 in a loop (dbms_sql.fetch_rows (l_theCursor) > 0)
31 l_separator: = ";
32 because I in 1... l_colCnt loop
33 dbms_sql.column_value (l_theCursor, i, l_columnValue);
34 utl_file.put (l_output, l_separator | l_columnValue);
35 l_separator: = ', ';
36 end loop;
37 utl_file.new_line (l_output);
38 end loop;
39 dbms_sql.close_cursor (l_theCursor);
40 utl_file.fclose (l_output);
41
42 run immediately "alter session set nls_date_format =" LUN-JJ-AA "';"
43 exception
44 so that others then
45 run immediately "alter session set nls_date_format =" LUN-JJ-AA "';"
46 raise him;
end 47;
48.
Created procedure.
OPS$tkyte@8i > dump_table_to_csv exec ('emp', ' / tmp', 'tkyte.emp');
PL/SQL procedure successfully completed.
Tags: Database
Similar Questions
-
Cannot create Materialized View using the PL/SQL procedure
Hello
I have a question related to the creation of materialized view.
I have a stored procedure that creates the materialized view. When you try to perform this procedure, I get not enough privileges error: ORA-01031.
When I run the content of this procedure as a PL/SQL block anonymous their materialized view is created without any complications.
Can you please advice me on this subject?
It is even possible to create a materialized view in the stored procedure as I found no info on this subject.
Thank you
PetrHi chudapet,
Whenever you make in procedure, you must have direct subsidies and not through a role.
Most likely the grant to create a materialized view is available via a role to your username.
Assign a direct grant to the user:grant create materialized view to scott; {code}
-
Creating a fichierXML using the pl/sql procedure.
Hello
I have a scenario here. I need to create an XML file, in a format of perticular. Since this is not a well-formed XML format, I am facing questions during the creation of the file.
The XML file format is as below.
ARTICLE <>10-B < / SECTION >
<? XML version = "1.0" encoding = "UTF-8"? >
< name >
< first > CBA < / first >
BCD < middle > < / Middle >
< Lastt > CBA < / last >
<>brands
< > 89 Subj1 < / Subj1 >
< Subj2 > 89 < / Subj2 >
< Subj3 > 89 < / Subj3 >
< / brands >
< / name >
<? XML version = "1.0" encoding = "UTF-8"? >
< name >
< first > CBA < / first >
BCD < middle > < / Middle >
< Lastt > CBA < / last >
<>brands
< > 89 Subj1 < / Subj1 >
< Subj2 > 89 < / Subj2 >
< Subj3 > 89 < / Subj3 >
< / brands >
< / name >
--
--
--
< SECTIONCNT > 6 < / SECTIONCNT >
I tried to create the file using the utl functions, but it did not work. I would like to know is there any other approach?
-AnuThis should keep you in suspense:
DECLARE xml_prolog clob := ''; xml_header clob; xml_trailer clob; tmp_xml clob; tmp_file clob; cursor c_invoice is select xmlelement ("ABCD", xmlelement ("BankSvcRq", ... ) ).getclobval() as invoice_xml from ap_invoices_all ai where batch_id = :c_batch_id and org_id = :c_ord_id; BEGIN -- create the temporary clob : dbms_lob.createtemporary(tmp_file, true); -- fetch the header : select xmlelement ("BATCHHEADER", batch_name).getclobval() into xml_header from ap_batches_all ab where ab.batch_id = :c_batch_id and ab.org_id = :c_org_id; -- fetch the trailer : select xmlelement ("BATCHTRAILER", count(*)).getclobval() into xml_trailer from ap_invoices_all ai where ai.invoice_id = nvl (:c_invoice_id, ai.invoice_id) and ai.batch_id = :c_batch_id and ai.org_id = :c_org_id; -- append header dbms_lob.append(tmp_file, xml_header); -- fetch the invoices and append : for r in c_invoice loop dbms_lob.append(tmp_file, xml_prolog); dbms_lob.append(tmp_file, r.invoice_xml); end loop; -- append trailer : dbms_lob.append(tmp_file, xml_trailer); -- write file to directory : dbms_xslprocessor.clob2file(tmp_file, 'TEST_DIR', 'test.dat', nls_charset_id('AL32UTF8')); dbms_lob.freetemporary(tmp_file); END; /
-
Create table or MV in PL/SQL
Hey everybody,
It is probably a very simple question, but I can't seem to create a table in a PL/SQL procedure. I have something like this:
PROCEDURE TEST_PROC IS
BEGIN
RUN IMMEDIATELY "CREATE TABLE TEST_TBL AS SELECT * FROM DUAL';"
END TEST_PROC;
I get an error of privs when I try to execute the proc. I also tried everything first create a view, materialized in a very similar way, but it also did not work.
I did some research and on a blog, they created a table by using the statement of full table create for example CREATE TABLE NAME (COLUMN1 TYPE1, etc...);
But I want to create the table using the clause 'AS' and the definition of a query.
Is there a specific privilege that I have to be able to do this? It seems simple enough.
Thank you!
-JoeNo, you need (again) CREATE TABLE privilege. CREATE ANY TABLE is to create arrays in other patterns.
-
Need to check delays in update of 1000 lines using the PL/SQL procedure.
Hi all
I'm new to PL/SQL. I need your help to build a procedure that executes the following statement and follows the time of update of 1000 rows. This is to check the performance of the database. I need to print the timestamp of start before the update and end timestamp after update. I need to do for the 1000 lines. The statement that will be used in the procedure is:
SELECT
'UPDATE XXAFL_MON_FACTS_F SET TASK_WID =' | NVL (TO_CHAR (TASK_WID), 'NULL') |', EXECUTION_PLAN_WID =' | NVL (TO_CHAR (EXECUTION_PLAN_WID), 'NULL').
', DETAILS_WID =' | NVL (TO_CHAR (DETAILS_WID), 'NULL') |', SOURCE_WID =' | NVL (TO_CHAR (SOURCE_WID), 'NULL') |', TARGET_WID = ' | NVL (TO_CHAR (TARGET_WID), 'NULL').
', RUN_STATUS_WID =' | NVL (TO_CHAR (RUN_STATUS_WID), 'NULL') |', SEQ_NUM =' | NVL (TO_CHAR (SEQ_NUM), 'NULL') |', NAME = "' | NVL (TO_CHAR (NAME), 'NULL').
"', NO_POSITION =" ' | NVL (TO_CHAR (INSTANCE_NUM), e ') | " ', INSTANCE_NAME = "' | NVL (TO_CHAR (INSTANCE_NAME), 'NULL').
"', TYPE_CD =" ' | NVL (TO_CHAR (TYPE_CD), e ') | " ', STATUS_CD = "' | NVL (TO_CHAR (STATUS_CD), e ') | " ', START_TS =' | NVL (TO_CHAR (START_TS), 'NULL').
', END_TS =' | NVL (TO_CHAR (END_TS), 'NULL') |', DURATION = ' | NVL (TO_CHAR (DURATION), 'NULL') |', STATUS_DESC = "' | NVL (TO_CHAR (STATUS_DESC), 'NULL').
"', DBCONN_NAME =" ' | NVL (TO_CHAR (DBCONN_NAME), e ') | " ', SUCESS_ROWS =' | NVL (TO_CHAR (SUCESS_ROWS), 'NULL').
', FAILED_ROWS =' | NVL (TO_CHAR (FAILED_ROWS), 'NULL') |', ERROR_CODE = ' | NVL (TO_CHAR (ERROR_CODE), 'NULL') |', NUM_RETRIES =' | NVL (TO_CHAR (NUM_RETRIES), 'NULL').
', READ_THRUPUT =' | NVL (TO_CHAR (READ_THRUPUT), 'NULL') |', LAST_UPD = ' | NVL (TO_CHAR (LAST_UPD), 'NULL') |', RUN_STEP_WID = "' | NVL (TO_CHAR (RUN_STEP_WID), 'NULL').
"', W_INSERT_DT = ' | NVL (TO_CHAR (W_INSERT_DT), 'NULL') |', W_UPDATE_DT = ' | NVL (TO_CHAR (W_UPDATE_DT), 'NULL').
', START_DATE_WID =' | NVL (TO_CHAR (START_DATE_WID), 'NULL') |', END_DATE_WID = ' | NVL (TO_CHAR (END_DATE_WID), 'NULL') |', START_TIME =' |
NVL (TO_CHAR (START_TIME), 'NULL') |', END_TIME =' | NVL (TO_CHAR (END_TIME), 'NULL'). "WHERE INTEGRATION_ID ="' | INTEGRATION_ID | " « ; » OF XXAFL_MON_FACTS_F;
The above query creates instructions of update that must be executed 1000 times and the time required to update the 1000 lines should be followed.
Thanks in advance!
Code horribly wrong!
Why this approach?
Dynamic SQL is almost NEVER needed in PL/SQL. And if you think it's necessary and taking into account what is displayed as being problems here, you have a 99% chance of being wrong.
This 1% where dynamic SQL is necessary, he will WITH bind variables to create shareable SQL, decrease memory requests, decrease the likelihood of a fragmented shared reel and decrease the burning CPU cycles on hard analysis.
An example below. Your approach is the 1st. One that is slower than the correct approach to 37 (x_!) ...
SQL> create table t ( n number ); Table created. SQL> SQL> var ITERATIONS number; SQL> exec :ITERATIONS := 100000; PL/SQL procedure successfully completed. SQL> SQL> SQL> TIMING START "INSERTs using Hard Parsing" SQL> declare 2 i integer; 3 begin 4 for i in 1..:ITERATIONS 5 loop 6 execute immediate 'insert into t values ('||i||')'; 7 end loop; 8 commit; 9 end; 10 / PL/SQL procedure successfully completed. SQL> TIMING SHOW timing for: INSERTs using Hard Parsing Elapsed: 00:02:00.33 SQL> SQL> TIMING START "INSERTs using Soft Parsing" SQL> declare 2 i integer; 3 begin 4 for i in 1..:ITERATIONS 5 loop 6 execute immediate 'insert into t values ( :1 )' using i; 7 end loop; 8 commit; 9 end; 10 / PL/SQL procedure successfully completed. SQL> TIMING SHOW timing for: INSERTs using Soft Parsing Elapsed: 00:00:06.06 SQL> drop table t; Table dropped. SQL> create table t( n number ); Table created. SQL> SQL> SQL> TIMING START "INSERTs using a single parse and repeatable statement handle " SQL> declare 2 i integer; 3 begin 4 for i in 1..:ITERATIONS 5 loop 6 insert into t values ( i ); 7 end loop; 8 commit; 9 end; 10 / PL/SQL procedure successfully completed. SQL> TIMING SHOW timing for: INSERTs using a single parse and repeatable statement handle Elapsed: 00:00:04.81 SQL>
-
Convert .xls in .csv file using pl/sql or any other method (oracle 9i)
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production
With partitioning, OLAP and Oracle Data Mining options
Release 9.2.0.8.0 - Production jserver
10.1.2.0.2 generator
ORACLE Server Release 10.1.0.4.2
Oracle 10.1.2.0.2 procedure generator
Oracle ORACLE PL/SQL V10.1.0.4.2 - Production
Oracle 10.1.0.4.0 Production CORE
Integration Services 10.1.2.0.2 tools Oracle
Space common tools Oracle 10.1.2.0.2
Oracle Toolkit 2 for 32-bit Windows, 10.1.2.0.2 platforms
Resource object 10.1.2.0.2 store
Oracle Help 10.1.2.0.2
Oracle Sqlmgr 10.1.2.0.2
Query Oracle 10.1.2.0.2 - Production Designer
PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
Oracle ZRC 10.1.2.0.2
Oracle XML Developers Kit 10.1.0.4.2 - Production
Virtual graphics system Oracle 10.1.2.0.2
Image of Oracle 10.1.2.0.2
Widget media Oracle 10.1.2.0.2
The GUI utility 10.1.2.0.2 tools Oracle
I had seen a very old post of 2009.
Convert .xls in .csv file using pl/sql
I know that it s a long time but just wanted to know if there is a way to convert excel .csv.
I have a directory say 'F:\purple_top\ '. I'll get the .xls file in this directory. I need to change to .csv and tables load external oracle. Any ideas or advance coding on it since 2009 so far?
A few other options might be:
- Java code, which can be used from within Oracle, which makes use of utility libraries (e.g. Aspose.Cells) open source (for example Apache POI) or "save under" CSV, or read the source cells and their output to a CSV file.
- COM Automation, using available open source (for example, JACOB or j-interop) or commercial libraries, which can automate Excel to open a XLS file and "Save as" a CSV file. In addition, Oracle has a feature of COM Automation (available since version 8 but abandoned after Oracle 11g). I have successfully used this read (non-macro-enabled) Excel files in PL/SQL.
- Other approaches using Perl or PHP can be found by googling 'convert xls to csv.
Gerard
-
How to expose a pl/sql procedure via slot shape of apex
Hi gurus
I have a form that is create from a procedure.
I put the auth to pubic_user if it is available to the public.
So now I need is to know how to find a way to imitate the button submit and draw the corresponding URL
while I can expose my PL/SQL via a URL through apex procedure.
I have attached a screenshot of my form
Thx for all the help.
Here's the URL of my pl/sql
https://Apex.Oracle.com/pls/Apex/f?p=30141:1:5404118417577:
and I look at the code with tool from dev on chrome for the Send button
If only show.
< a href = "javascript:apex.submit ('SUBMIT'); "class ="uButton"id ="B67074418713946955629"role ="button"> < span > Submit </span > < /a >
So how do I know what return? Thx for all the help
Hi Kazuneric,
kazuneric wrote:
I intend to pass the parameter in the URL for a user to click through
You will find the following useful threads:
Call a rendering of APEX (EPG) form of procedure within the error
403 Forbidden error URL the PL/SQL procedure call
I hope this helps!
Kind regards
Kiran
-
Problem with pl/sql procedure, trying to get the value of the user during execution
Hello
Using oracle 11.2.0.3
Can run sql that gets the value of the user during the fine workmanship and also via an anonymous block.
uses of SQL & Enter_Product_Number
anonymous block using: Enter_Product_number.
However, get problems when trying to create a pl/sql procedure, use one of the above
relevant below tried code part & and: buit works do not error, try bad bind variable if used: and ora-600 if try use &.
How can we have a procedure from pl/sql that can call and receives a value of user during execution?
Only way around what I can think of is to pass parameters to the procedure
Thank you
create or replace procedure ins_into_issues is
v_nd_rec_cnt number (10);
v_normal_rec_cnt number (10);
Start
Select count (*)
in v_nd_rec_cnt
refmast.issues I have
where i.iss_product_num = & old_nd_product_number;
Select count (*)
in v_normal_rec_cnt
refmast.issues I have
where i.iss_product_num = & normal_product_number;
-code below commented above works.
end;
Hello
what something like this:
create or replace procedure INS_INTO_ISSUES ( in_normal number, in_old number ) is v_nd_rec_cnt number(10); v_normal_rec_cnt number(10); begin select count(*) into v_nd_rec_cnt from refmast.issues i where i.iss_product_num = in_old; -- select count(*) into v_normal_rec_cnt from refmast.issues i where i.iss_product_num = in_normal; end;
concerning
Kay
-
How to pass parameter in a concurrent program like PL/Sql procedure
Hello experts,
I created a simultaneous the Plsql procedure type executable program.
In the procedure, I have three user settings
1 p_fnd_user in
2. out errbuf
3. out retcode
I created the simultaneous program with parameter
1 p_fnd_user
the token is disable.
I entered the user id at the time of submitting the application.
I don't get the p_fnd_user inside the procedure.
Please help me.
Thank you inadvance.
Yoann
You can try and reorganize the parameters in your pl/sql procedure to errbuf outside, out retcode, p_fnd_user in
-
anonymous block of pl/sql procedure ended with no result
started just learning oracle pl/sql and I am facing a problem here.
I have no problem to compile, but whenever I run the nth procedure would seem except the following message is displayed and not showing any output that should not be the case: block anonymous filled
I tried to set serveroutput size 50000; changes but nth.
Here is my pl/sql procedure not sure if I'm doing things.
CREATE OR REPLACE PROCEDURE CHECK AS
empnum NUMBER;
EmpName VARCHAR2 (50);
BEGIN
Select employee.e #.
, Employee.Name since it is
in empnum
empname
Join driver used on driver.e # employee.e = #.
Mechanic to join on mechanic.e # driver.e = #;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT. Put_line ('ok');
END CHECK;
/
I'm trying to achieve the same result in the following sql query:
select employee.name, employee.e#
from employee join driver
on driver.e# = employee.e#
join mechanic
on mechanic.e# = driver.e#
where rownum = 1;If there is no similar records if it will display the employee name and numbers. If there is no such document found it will show an ok message.
My bad, NO_DATA_FOUND is not triggered when a select statement is used like that. This is a way to approach it.
create or replace procedure check
as
number of empnum;
EmpName varchar2 (50);
is_exist boolean;
Start
I'm in)
Select employee.e #.
, Employee.Name since it is
Join driver used on driver.e # employee.e = #.
Mechanic to join on mechanic.e # driver.e = #.
)
loop
is_exist: = true;
dbms_output.put_line (' e #-' | lpad (IE #, 20, ' ') |) ' name ' - | i.Name);
end loop;If not is_exist then
raise the no_data_found;
end if;exception
When no_data_found then
dbms_output.put_line ('ok');
end check;
/This isn't a very elegant way of doing things. But I am limited to knowledge of the requirement of the company. Therefore, the best I could come up with. If you can explain how you're going to put this procedure into your business situation we could help you better.
-
ORA-900 sql not valid reporting error while calling the optimize_index pl/sql procedure
Hi Experts,I'm on Oracle 11.2.0.3 on Linux and I have installed in my database Oracle text. I want to configure annex dbms_job to optimize my oracle text index. So first, I created a pl/sql procedure to optimize indexes. It gives me error ORA-900, but the sql even if I run in sqlplus works very well! Can you please help me the question is to find:
Here is the procedure:
(Either incidentally CTXAPP role has been granted in the schema where these Oracle text indexes are created and where the below procedure to optimize the index is running.)
CREATE OR REPLACE PROCEDURE optimize_ora_txt_indexes_debug IS CURSOR cur_context_indexes IS SELECT index_name FROM user_indexes WHERE index_type = 'DOMAIN' AND ROWNUM<2 ORDER BY INDEX_NAME; v_user VARCHAR2 (30); v_pod VARCHAR2 (30); v_start_time TIMESTAMP; v_end_time TIMESTAMP; v_elapsed VARCHAR2 (40); v_msg VARCHAR2 (1000); v_error_code NUMBER; v_error_msg VARCHAR2 (1000); v_sql VARCHAR2 (1000); BEGIN FOR c IN cur_context_indexes LOOP BEGIN v_sql:= 'ctx_ddl.optimize_index (idx_name =>'||chr(39)|| c.index_name||chr(39)||', optlevel => '||chr(39)||'FULL'||chr(39)||')'; dbms_output.put_line(v_sql); execute immediate v_sql; EXCEPTION WHEN OTHERS THEN v_error_code := SQLCODE; v_error_msg := SQLERRM; v_msg := 'Error while optimizing the index ' || c.index_name || ' ' || TO_CHAR (v_error_code) || ' ' || v_error_msg; DBMS_OUTPUT.put_line (v_msg); END; END LOOP; EXCEPTION WHEN OTHERS THEN v_error_code := SQLCODE; v_error_msg := SQLERRM; v_msg := 'Error while in the optimize index procedure' || ' ' || TO_CHAR (v_error_code) || ' ' || v_error_msg; DBMS_OUTPUT.put_line (v_msg); END optimize_ora_txt_indexes_debug; / --the procedure compiles successfully. Now when I run it , I get the error: SQL>exec optimize_ora_txt_indexes_debug; ctx_ddl.optimize_index (idx_name =>'ACCESS_CLNT_IDX04', optlevel => 'FULL') Error while optimizing the index ACCESS_CLNT_IDX04 -900 ORA-00900: invalid SQL statement --When I run the same command from sqlplus as execute statement , it works fine: SQL>exec ctx_ddl.optimize_index (idx_name =>'ACCESS_CLNT_IDX04', optlevel => 'FULL'); PL/SQL procedure successfully completed.
If everything runs from sqlplus, but fails in plsql... I'll be very grateful for pointers solve the problem.
Thanks,
OrauserN
Hello
It is a problem of pl/sql syntax. A call with EXEC is the same using BEGIN... Code of... END of block;
SO, you need to include a beginning and an end to your call:
v_sql:= 'BEGIN ctx_ddl.optimize_index (idx_name =>'||chr(39)|| c.index_name||chr(39)||', optlevel => '||chr(39)||'FULL'||chr(39)||'); END;';
That's all.
Herald tiomela
-
FND_REQUEST PL/SQL procedure with parameters
Hi guys
I created a concurrent program, using the PL/SQL procedure that has 2 parameters. I try to call the concurrent program to help
v_req_id: = FND_REQUEST. SUBMIT_REQUEST ('INV', 'OMS_POP_INVVALUES_P',
NULL, SYSDATE, FALSE, l_on_date, l_org_id,.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
);
COMMIT;
However, the competitor programming always fail with
* Starts * August 26, 2013 14:02:31 error ORACLE 6550 for Cause of FDPSTP: FDPSTP failed due to the ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in the call to 'OMS_POP_INVVALUES_P' ORA-06550: line 1, column 7: PL/SQL: statement ignored
and I doubt that it is because the database procedure call is not correct.
I put four parameters with the simultaneous program, as they were with the procedure itself, which are
p_on_date BY DATE, NUMBER, errbuff OUT VARCHAR2, OUT VARCHAR2 retcode p_org_id
Help, please
Kind regards
REDA
Okay I solved the problem of
1. change the order of the parameters in the procedure
CREATE OR REPLACE PROCEDURE OMS_POP_INVVALUES_P)
errbuff OUT VARCHAR2, retcode ON NUMBER, p_on_date AS, p_org_id in NUMBER)
IS
and by changing the call of simultaneous program as follows
l_req_id: =.
fnd_request.submit_request ('INV', 'OMS_POP_INVVALUES_P',
NULL, SYSDATE, FALSE, l_in_date, l_org_id, CHR (0));
: SYSTEM. Message_Level: = '25';
COMMIT;
After removing all the parameters of the list of program parameters. No need to pass a value for errbuff and retcode, just pass other parameters and put an end to the list of parameters with CHR (0). Hope it's useful for someone else there.
Kind regards
REDA
-
table/view not found when creating a package, but can execute sql...
I'm trying to create a package I'm ora-00942 table or view does not exsit, but when I run with the same user tries to create the package in the sql statement that gives NO error through fine.
Any idea what can cause that?
-drop table demo_hdr_trgt
-drop table demo_hdr_stg
-It's the tabe belong to the other user not my own schema
connect tstdata/tstdata
create the table demo_hdr_stg as floor (dbms_random.value (1,101)) select id, floor (dbms_random.value (1001,100001)) double amt connect by level < = 100
/
-It's my diagram
connect me3/me3
create the table demo_hdr_trgt in select * from hdr_stg where 1 = 0
/
Select * from tstdata.demo_hdr_stg by id
/
Select * from demo_hdr_trgt by id
/
-business for this temporary table to demo rule
ALTER TABLE demo_hdr_trgt add PRIMARY KEY (id)
/
-table to the control of the error for the DML
Start
DBMS_ERRLOG. CREATE_ERROR_LOG('tstdata.) DEMO_HDR_STG');
end
/
-Follow-up of the load table if he succeeds
CREATE TABLE demo_RESULT_TAB
(VARCHAR2 (100) 'RUN_NAME',)
VARCHAR2 (100) "V_MODULE."
VARCHAR2 (100) "V_ACTION."
NUMBER OF "ROWCOUNT".
)
/
-Follow-up of the other error table
CREATE TABLE demo_ERROR_TAB
(VARCHAR2 (100) 'RUN_NAME',)
VARCHAR2 (100) "V_MODULE."
VARCHAR2 (100) "V_ACTION."
NUMBER OF "SQLCODE"
"SQLERRM' VARCHAR2 (4000).
"CALL_STACK' CLOB
)
/
-package charge demo
create or replace package demo_hdr_pkg as
procedure hdr_ldr (run_name varchar2);
end demo_hdr_pkg
/
create or replace package body demo_hdr_pkg as
procedure hdr_ldr (run_name varchar2) is
number of v_sqlcode;
v_sqlerrm varchar2 (1000);
v_module varchar2 (100): = "demo_hdr_pkg.hdr_ldr";
v_action varchar2 (100): = "insert into hdr_trgt";
number of v_rowcount;
Start
DBMS_APPLICATION_INFO.set_module (module_name = > v_module,)
action_name = > v_action);
-the sql code that gives ora-00942 errors that I can review independent
-INSERT / * + append PARALLEL * /.
INSERT / * + PARALLEL * /.
IN demo_hdr_trgt, SELECT id, tstdata.demo_hdr_stg amt
LOG ERRORS IN tstdata. ERR$ (run_name) _demo_HDR_STG
REJECT LIMIT UNLIMITED;
v_rowcount: = number of lines sql %;
INSERT into demo_result_tab (run_name, v_module, v_action, rowcount) values (run_name, v_module, v_action, v_rowcount);
commit;
exception when others then
dbms_output.put_line(SQLCODE||) e '|| SQLERRM);
v_sqlcode: = sqlcode;
v_sqlerrm: = sqlerrm;
insert into demo_error_tab (run_name, v_module, v_action, sqlcode, sqlerrm, call_stack) values (run_name, v_module, v_action, v_sqlcode, v_sqlerrm, dbms_utility.format_call_stack);
commit;
-dbms_scheduler to analyze the error table and send e-mail
end;
end demo_hdr_pkg
/
-test
declare
v_runname varchar2 (100): = to_char (sysdate, 'YYYY_MM_DD_HH24_MI_SS');
Start
demo_hdr_pkg.hdr_ldr (v_runname);
end
/
Select * from demo_hdr_stg by id
/
Select * from demo_hdr_trgt by id
/
Select * from demo_error_tab
/
Select * from demo_result_tab
/
This question is asked almost every day...
Summary, you need a DIRECT grant (not through a role), or you could modify the procedure to use the rights of the appellant (the default is rights define).
See you soon,.
-
PL - SQL procedures and functions
Hi all
When playing on the PL - SQL procedures, I came across a concept, which says that we cannot include bind or host variables in procedures because the compiler cannot resolve the reference to bind the variable.
Can someone please explain more carefully.
Thank you.983037 wrote:
When playing on the PL - SQL procedures, I came across a concept, which says that we cannot include bind or host variables in procedures because the compiler cannot resolve the reference to bind the variable.
Fix. This code cannot compile the way he needs to a connection variable to respect:
create or replace function GetEmpName return varchar2 is empName emp.ename%Type; begin select e.ename into empName from emp where emp_no = :BIND_VARIABLE; return( empName ); end;
Stored code cannot include bind variables as what compiler Oracle to know the data type of +: BIND_VARIABLE + - or run the service running when the code is already compiled, but it lacks a bind call to provide a value for +: BIND_VARIABLE +?
If the code should look like the following instead:
create or replace function GetEmpName( empID number ) return varchar2 is empName emp.ename%Type; begin select e.ename into empName from emp where emp_no = empID; return( empName ); end;
The variable from PL/SQL empID is treated (transparent) as a variable binding when the SQL SELECT in this function is parsed and executed as a SQL cursor.
You as a visitor, however need to provide variable bind when you call this function from an external client (such as SQL * Plus, Java, C/C++, etc.). For example
--// using sqlplus as example - create 2 sqlplus host variables var name varchar2(100) var id number --// assign a value to a host variable exec :id := 12345; --// execute the stored function code binding host variables as bind variables begin :name := GetEmpName( :id ); end; / --// display host variable print name
-
How to write a pl/sql procedure that checks the remote db?
Hi all
I have one criticism PROD remote database I want to check every 10 minutes for its connectivity. If the connection fails then an email and a text Message is sent to me.
My question is what is the best way to check if the remote database is running?
Can I use sqlplus system/manager@PROD? But sometimes this has taken so long and suspended. I want the best response time?
How can I write a pl/sql procedure control connection? What do something like the ff:
I created a table for my tnsname.ora entries.
Something like that?cursor is c1 select dbname from tnsnames_tbl; begin connect system/[email protected]; print c1.dbname || 'DB Connection OK'; exception when others; print c1.dbname || 'DB Connection Not OK'; end; end;
Thank you
KinzNot really feasible at the level of PL/SQL.
The reason is that the greatest strength of TCP's robustness. TCP will try as hard as possible to succeed, before failing. It was designed to still work on the severely damaged or broken communication as a result of nuclear infrastructure. A TCP connection can take up to 15 minutes, maybe even more, before failing. It can be as slow as a turtle-, but he's wearing a hardshell. (unlike the UDP, which is the opposite)
So if you want to test the TCP connectivity, you must design your own custom code to implement your assumptions about the latency of packets, earthquakes and drops and so on.
Otherwise, you will need to use a standard TCP socket, set a time limit, try to login - and hope for the best.
This approach, I have demonstrated in {message identifier: = 10111306}.
If the TCP test works, it means that the listener is in place. Does not mean that the database itself is in place. Which means then using a database link to be tested. And this in turn can hang due to problems with archive record being stuck, not enough idle servers shared, etc..
Maybe you are looking for
-
Hi, I have a Nas (qnap 212) and wants to get access to my work. but firefox denies access because there is an invalid certificate, how to solve this, I hope, little problem (https://87.210.77.168:8081 / musicstation /) Grtzz Luis van dijkHolland
-
Installing drivers Lenovo no? Yoga 2 Pro - video drivers for DX 11 games
So, I use a Yoga 2 Pro. I love this laptop / Tablet what you want to call it, but the biggest problem I always seem to have is related to video games. I realize this isn't a game system, but it would be nice to play some. The game I'm most interested
-
Sof2 on Windows 7?
-
I am trying to load windows 7, but it tells me that my version of windows needs an update sp1a or sp2. When I try to download I am told that the server does not respond and try again. After several times, he search the site for the service center f
-
audio player on windows XP Pro THAT has been disabled. How to activate?
audio driver Windows xp pro has been disabled. How to activate?