Columns used in packages
Hi. Can I get the column names also that I use in packages from some metadata table?
Also read similar question over there:
http://database.itags.org/oracle/80300/
You can have source code of the package as a big text available to you, you can perhaps run some regular expressions over that text to finde the column names.
Similar Messages
-
New Columns Used in a Package Declaration
I added the following new columns to a table:
alter table J48PLTEQUIP add
LOCBYUSER Char ( 1) Default 'N', UPF85 VarChar2(6) Default To_Char(SysDate,'MMDDRR'),
COFFSETDV VarChar2( 8) , UPF86 VarChar2(6) Default To_Char(SysDate,'MMDDRR'),
COFFSETEV VarChar2( 8) , UPF87 VarChar2(6) Default To_Char(SysDate,'MMDDRR'),
COFFSETEU VarChar2( 8) , UPF88 VarChar2(6) Default To_Char(SysDate,'MMDDRR'),
ROFFSETDV VarChar2( 8) , UPF89 VarChar2(6) Default To_Char(SysDate,'MMDDRR'),
ROFFSETEV VarChar2( 8) , UPF90 VarChar2(6) Default To_Char(SysDate,'MMDDRR'),
ROFFSETEU VarChar2(15) , UPF91 VarChar2(6) Default To_Char(SysDate,'MMDDRR')
Then I tried adding the new columns to a package declaration (see code below) and for some reason I am getting some errors when I compile it:
TYPE tab_coloffsetdv IS TABLE OF J48PLTEQUIP.COLOFFSETDV%TYPE index by binary_integer;
TYPE tab_coloffsetev IS TABLE OF J48PLTEQUIP.COLOFFSETEV%TYPE index by binary_integer;
TYPE tab_coloffseteu IS TABLE OF J48PLTEQUIP.COLOFFSETEU%TYPE index by binary_integer;
TYPE tab_coloffsetdir IS TABLE OF J48PLTEQUIP.COLOFFSETDIR%TYPE index by binary_integer;
TYPE tab_rowoffsetdv IS TABLE OF J48PLTEQUIP.ROWOFFSETDV%TYPE index by binary_integer;
TYPE tab_rowoffsetev IS TABLE OF J48PLTEQUIP.ROWOFFSETEV%TYPE index by binary_integer;
TYPE tab_rowoffseteu IS TABLE OF J48PLTEQUIP.ROWOFFSETEU%TYPE index by binary_integer;
TYPE tab_rowoffsetdir IS TABLE OF J48PLTEQUIP.ROWOFFSETDIR%TYPE index by binary_integer;
SQL> show error
Errors for PACKAGE PWRADMIN.PLAKCOMP:
LINE/COL ERROR
78/4 PL/SQL: Declaration ignored
78/47 PLS-00302: component 'COFFSETDV' must be declared
79/4 PL/SQL: Declaration ignored
79/47 PLS-00302: component 'COFFSETEV' must be declared
80/4 PL/SQL: Declaration ignored
80/47 PLS-00302: component 'COFFSETEU' must be declared
81/4 PL/SQL: Declaration ignored
81/48 PLS-00302: component 'COFFSETDIR' must be declared
82/4 PL/SQL: Declaration ignored
82/47 PLS-00302: component 'ROFFSETDV' must be declared
83/4 PL/SQL: Declaration ignored
LINE/COL ERROR
83/47 PLS-00302: component 'ROFFSETEV' must be declared
84/4 PL/SQL: Declaration ignored
84/47 PLS-00302: component 'ROFFSETEU' must be declared
85/4 PL/SQL: Declaration ignored
85/48 PLS-00302: component 'ROFFSETDIR' must be declared
359/4 PL/SQL: Declaration ignored
362/52 PLS-00302: component 'COFFSETDV' must be declared
Do you have any clues why I am getting this error?
Your help is really appreciated.
AlexTodd, thanks for your prompt answer.
I apologize, I pasted the wrong segment of the code. The TYPE statements should have been the following:
TYPE tab_coffsetdv IS TABLE OF J48PLTEQUIP.COFFSETDV%TYPE index by binary_integer;
TYPE tab_coffsetev IS TABLE OF J48PLTEQUIP.COFFSETEV%TYPE index by binary_integer;
TYPE tab_coffseteu IS TABLE OF J48PLTEQUIP.COFFSETEU%TYPE index by binary_integer;
TYPE tab_coffsetdir IS TABLE OF J48PLTEQUIP.COFFSETDIR%TYPE index by binary_integer;
TYPE tab_roffsetdv IS TABLE OF J48PLTEQUIP.ROFFSETDV%TYPE index by binary_integer;
TYPE tab_roffsetev IS TABLE OF J48PLTEQUIP.ROFFSETEV%TYPE index by binary_integer;
TYPE tab_roffseteu IS TABLE OF J48PLTEQUIP.ROFFSETEU%TYPE index by binary_integer;
TYPE tab_roffsetdir IS TABLE OF J48PLTEQUIP.ROFFSETDIR%TYPE index by binary_integer;
Hopefully, this will clear things out. I am still out of luck with this issue. Thanks in advance again to all the gurus for your help... -
Error using dbms_redefinition package
Hi,
I am trying to use dbms_redefinition package to add a column to a table using primary key method
SQL> conn / as sysdba
Connected.
SQL> grant execute on sys.dbms_redefinition to hr;
Grant succeeded.
SQL> grant dba to hr;
Grant succeeded.
SQL> conn hr/<password>
Connected.
SQL> create table tab1(roll_no number constraint roll_pk primary key,last_name varchar2(30));
Table created.
SQL> insert into tab1 values (1,'Hall');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into tab1 values (2,'Mall');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into tab1 values (3,'Roll');
1 row created.
SQL> commit;
Commit complete.
Adding required column
SQL>
SQL> alter table tab1 add(first_name varchar2(30));
Table altered.
Checking if table can be redefined
SQL> exec dbms_redefinition.can_redef_table('HR','TAB1',DBMS_REDEFINITION.CONS_USE_PK);
PL/SQL procedure successfully completed.
Creating interim table
SQL> create table tab2 as select roll_no,first_name,last_name from tab1 where 1=2;
Table created.
Adding primary key to interim table
SQL> alter table tab2 add constraint roll_pk_1 primary key (roll_no);
Table altered.
Starting redefinition :
SQL> exec dbms_redefinition.start_redef_table('HR','TAB1','TAB2','ROLL_NO,FIRST_NAME,LAST_NAME');
BEGIN dbms_redefinition.start_redef_table('HR','TAB1','TAB2','ROLL_NO,FIRST_NAME,LAST_NAME'); END;
ERROR at line 1:
ORA-00439: feature not enabled: Advanced replication
ORA-06512: at "SYS.DBMS_REDEFINITION", line 52
ORA-06512: at "SYS.DBMS_REDEFINITION", line 1646
ORA-06512: at line 1
SQL>
Could you please help.
Thanks,
HaiderYou can, yes. That's why CAN_REDEF_TABLE and START_REDEF_TABLE both have an OPTIONS_FLAG argument that lets you specify whether you want to use the primary key or the ROWID to redefine the table.
SQL> drop table foo;
Table dropped.
SQL> create table foo( col1 number, col2 number );
Table created.I can't redefine the table using the primary key since there is no primary key
SQL> ed
Wrote file afiedt.buf
1 begin
2 sys.DBMS_REDEFINITION.CAN_REDEF_TABLE ( 'SCOTT', 'FOO' );
3* end;
SQL> /
begin
ERROR at line 1:
ORA-12089: cannot online redefine table "SCOTT"."FOO" with no primary key
ORA-06512: at "SYS.DBMS_REDEFINITION", line 139
ORA-06512: at "SYS.DBMS_REDEFINITION", line 1782
ORA-06512: at line 2But I can use the ROWID
SQL> ed
Wrote file afiedt.buf
1 begin
2 sys.DBMS_REDEFINITION.CAN_REDEF_TABLE ( 'SCOTT', 'FOO', dbms_redefinition.cons_use_rowid );
3* end;
SQL> /
PL/SQL procedure successfully completed. Justin -
Error when using DBMS_XMLDOM package
Hello,
I have created a set of triggers that use the DBMS_XMLDOM packages. These triggers were created on a Win 2k install of 9.2.0.2.1. A brand new user was created and a specific set of permissions granted. The permissions were:
GRANT CONNECT, RESOURCE, AQ_ADMINISTRATOR_ROLE, AQ_USER_ROLE
GRANT EXECUTE ON DBMS_AQADM
GRANT EXECUTE ON DBMS_AQ
grant execute on dbms_aqin
execute dbms_java.grant_permission('<USER>', 'java.net.SocketPermission', 'localhost:1024-', 'accept, listen, resolve');
execute dbms_java.grant_permission( '<USER>', 'SYS:java.lang.RuntimePermission', ' getClassLoader', '' )
execute dbms_java.grant_permission( '<USER>', 'SYS:java.lang.RuntimePermission' , 'setContextClassLoader', '' )
I then went to install these triggers on our application database server. This is a Solaris installation that started out as 9.2.0.1.0 and was then upgraded to 9.2.0.2.0. I created the user and granted the exact same permissions on this database. However, everytime I attempt to execute the triggers, or anything else that uses DBMS_XMLDOM packages, I get the following error:
doc dbms_xmldom.DOMDocument;
ERROR at line 3:
ORA-06550: line 3, column 11:
PLS-00201: identifier 'DBMS_XMLDOM.DOMDOCUMENT' must be declared
I did not create the application database instance on the Solaris machine, but from what I've talked with the DBA, it was created as a general database, which is how I created my test databases. I also verified that the users in both databases have Execute on SYS.XMLDOM granted.
Any ideas on why I might be getting this error?
Thanks,
AndrewWhen I try the describe, it says object not found. If I go into OEM, I don't see that package either. Again, I didn't create that database, but I thought the XML DB stuff was installed by default with the database. Is there a way to add that package after the database is created?
Thanks,
Andrew -
Error logging using DBMS_ERRLOG package
Hi All,
We have following tables, which are growing day-by-day and giving performance problems.
There are total 25 tables (1 parent and 24 child tables, with different structures).
Here i gave some Samples, NOT actual table structures.
Actually we don't require all the data for our regular activities.
So we thought of moving part of the data into Other (Archive) tables, on daily basis.
Using SOME criteria, we are finding eligible records to be moved into Archive tables.
All child records follows the Parent.
Original Tables
==================
create table customer (c_id number(5), c_name varchar2(10),c_address varchar2(10));
create table orders (o_id number(5),c_id number(5),o_info clob);
create table personal_info (p_id number(5),c_id number(5), age number(3), e_mail varchar2(25), zip_code varchar2(10)):
Archive Tables
==============
create table customer_arch (c_id number(5), c_name varchar2(10),c_address varchar2(10));
create table orders_arch (o_id number(5),c_id number(5),o_info varchar2(100));
create table personal_info_arch (p_id number(5),c_id number(5), age number(3), e_mail varchar2(25), zip_code varchar2(10)):
Temp table
==========
create table C_temp (rnum number(5), ids number(5));
Sample Code
============
PROCEDURE payment_arch
IS
l_range_records NUMBER (4) := 2000;
l_total_count NUMBER(10) := 0;
l_prev_count NUMBER(10) := 0;
l_next_count NUMBER(10) := 0;
BEGIN
--Finding eligible records to be moved into Archive tables.
INSERT INTO C_TEMP
SELECT ROWNUM,c_id FROM customer;
SELECT NVL(MAX(ID),0) INTO l_total_count FROM OPP_PAYMENT_ID_TEMP;
IF l_total_count > 0 -- Start Count check
THEN
LOOP -- Insert Single payments
IF ((l_total_count - l_prev_count) >= l_next_count )
THEN
l_next_count := l_prev_count + l_range_records;
ELSE
l_next_count := l_total_count;
END IF;
l_prev_count := l_prev_count ;
INSERT INTO customer_ARCH
SELECT * FROM customer a
WHERE c_id in (SELECT c_id
FROM C_TEMP b WHERE rnum BETWEEN l_prev_count AND l_next_count);
INSERT INTO orders_ARCH
SELECT * FROM orders a
WHERE c_id in (SELECT c_id
FROM C_TEMP b WHERE rnum BETWEEN l_prev_count AND l_next_count);
INSERT INTO personal_info_ARCH
SELECT * FROM personal_info a
WHERE c_id in (SELECT c_id
FROM C_TEMP b WHERE rnum BETWEEN l_prev_count AND l_next_count);
-- Delete Archived Single Payments
DELETE customer a
WHERE c_id in (SELECT c_id
FROM C_TEMP b WHERE ID BETWEEN l_prev_count AND l_next_count);
COMMIT;
IF l_next_count = l_total_count
THEN
EXIT;
else
l_prev_count := l_next_count;
END IF;
END LOOP; -- Insert Single payments
END IF; -- End Count check
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
RAISE_APPLICATION_ERROR('-20002','payment_arch: ' || SQLCODE ||': ' || SQLERRM);
END Payment_Arch;
In production, we may require to archive 25000 Parent records and 25000*4*3 child records per day.
Now the problem is:
By any chance, if record fails, We want to know the Exact record ,just "c_id" for the particular table
where the error raised and Error message.
We thought of using DBMS_ERRLOG package, but we CAN NOT log errors of Different tables into SINGLE error log table.
In the above case It require 3 Different tables and it logs all columns from the original table.
It's a un-necessary burden on the database.
We would be very glad, if anyone can help us with some good thought.
Thanks in advance.
srinivasduplicate post
Insufficient privilege error when executing DBMS_ERRLOG through PLSQL -
Table name input. and output i need all rows and columns using procedures
hi,
question: table name input. and output i need all rows and columns by using procedures.
thanks,
To AllAn example of using DBMS_SQL package to execute dynamic SQL (in this case to generate CSV data in a file)...
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
ELSE
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
END CASE;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required. -
How to find length of string after encryption using DBMS_CRYPTO package
Hi,
I am planning do data encryption using DBMS_CRYPTO package. I want to find how much will be string length after encryption.
e.g When I try to encrypt string of length between 1-15 characters it gives me encrypted string of 32 characters. When I try with 16 charcters encrypted string is of 64 characters.
Is ther any formula to calculate length of encrypted string?
Thanks
PravinThe length change is dependent upon the algorithm you are using which can be a combination of cipher block, padding, and chaining.
The best solution is determine the method you are going to use and apply it to the l ongest possible strings you are going to proces, then add some safety margin. There iis no penalty for defining your column as VARCHAR2(4000). -
Negative effects by using DBMS_REDEFINITION package
Hello everybody,
I am looking for all 'bad' side effects of using the package.
I am in project where the definition of tables changes.
Sometimes a column needs to be placed in the middle of the table.
Up to now there are scripts which doing a lot of drops of columns, updates, add adds again.
My idea was to use the package, which I could test successfully.
Now I learned, that the grants to the table are lost.
What else should be concerned by using the package?
ThanksHi,
Sometimes a column needs to be placed in the middle of the table.hmm and why do you need some redefinition/reorg for the table - just put the columns on the right place in the select statement?
Now I learned, that the grants to the table are lost.hmm not "really"... have a look at the procedure "COPY_TABLE_DEPENDENTS".
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_redefi.htm#sthref5656
-> This subprogram is used to clone the dependent objects like grants, triggers, constraints and privileges from the table being redefined to the interim table (which represents the post-redefinition table).
Side effects:
You need to create/rebuild the indexes.. because of the rowids change.
Btw. your scenario seems a little bit "strange" to me...
Regards
Stefan -
File to Mail using Mail Package
Hello,
I have a requirement where we receive a csv file having mutiple columns, one of them being the email address.
I need to get this email address from the file and send this file as an attachment to the same email address.(Dynamic email address)
I have used the Mail xsd and have done graphical mapping to achieve this.
Now,the problem is,if I use Mail package for dynamic email address,I am not able to get the source file as an attachment because the payload here is a mail structure.
If I get source file as an attachment using PayloadSwapBean and MessageTransformBean,I cannot have dynamic email address.
Can anyone please suggest a solution to this?
Thanks in advance for your help.
Regards,
ShwetaHi Stefan,
Thanks for the reply.
But I think,I am not able to understand the solution mentioned by you.
I can find following fields in ASMA mail adapter:
Meaning
Technical name
User
TServerLocation
Authentication Keys
TAuthKey
Mail header 'from' field
THeaderFROM
Mail header 'to' field
THeaderTO
Mail header 'Cc' field
THeaderCC
Mail header 'Bcc' field
THeaderBCC
Mail header 'subject' field
THeaderSUBJECT
Mail header field for reference to mail which is being replied to
THeaderIN-REPLY-TO
Mail header 'reply to' field
THeaderREPLY-TO
Mail header field for mail client program
THeaderX-MAILER
Mail header field for delivery acknowledgement
THeaderDISPOSITION-NOTIFICATION-TO
Mail header field for priority
THeaderPRIORITY
Mail header field for message importance
THeaderIMPORTANCE
I couldn't find a field related to attachments.
I can see the xml version of file in inbound message in SXI_MONITOR.
But after mapping,I get Mail package structure.
Could you please explain again.Sorry for this.
Thanks.
Regards,
Shweta -
Using Oracle package variables in JDBC.
Can anybody know how we can use Oracle Package variable in Java/JDBC?
I am using a insert trigger on a table which will initialize the login user
from a package variable.In my log4j configuration file, while inserting data into this table, I am updating the user with my current user. But the insert statement is not identifying the user and it is inserting null.
PLease let me know.Siva,
You said:
It is not inserting the user in the tableI see no table, here. Only a variable in a PL/SQL package.
You also said:
But the same is working in Oracle.Do you mean in SQL*Plus?
Siva, try to forget how you are doing it, and tell me what you are trying to do.
Do you have some UPDATE_USER column in your database tables where you record the username of the person who did the operation?
Are you trying to write a trigger that populates this column?
If so, then all you need is something like:
create or replace trigger MY_TRIG
after insert or update
on MY_TABLE
for each row
begin
:new.UPDATE_USER := user;
end;Good Luck,
Avi.
P.S. By the way, what has this to do with OC4J? -
What is the change occured by using the package in select statement
Hi all,
Can some one please tell me using the following package in the select statement of the view does it restricts the data or fetches the data
what is the change occurred using the package for fetching the date column
hr_discoverer.check_end_date (per_assignments_f.effective_end_date)
Thanks in advanceYou can check the code -
-- this function checks to see if a date is equivalent to the end of time(31-Dec-4712)
-- if this is true it will return null else the actual end-date
Cheers,
Vignesh -
Update some columns using case....
Hi ,
Is it possible to update some columns using case statement...????
For example when col1 is null then update to a value 'x' else update it to the value '*' , when col2 is null then update to a value y else update it to compute the running total up to that time....
This update statement is contained in db packaged procedure and it receives the values...as parameters....
How can i write down this update statement...?????
Many thanks,
SimonHi ,
Cant' it be used for two or more columns that have to be updated....????
i mean
update table set col_a = case when col_a is null then col_a else '*',
col_b = case when col_b is null then col_b else col_b+col_b_var
end
where .....The above in bold is running total.... This update is defined in a procedure and it receives numbers as parameters, so the need is to add them for every record it receives...., that's why i set above col_b+col_b_var... where col_b_var is the parameter of the procedure....
SORRY...IT IS POSSIBLE.....
Thanks , a lot
Simon
Message was edited by:
sgalaxy -
Required to create a script for base table update using XMLSTORE package.
Hi can anybody provide me some help full suggestion on how to update base table using XMLSTORE package.
I created a simple script for Employee table and can able to do the basic operation like Insert and update on the table.
Query is as follow's
DECLARE
insCtx DBMS_XMLSTORE.ctxType;
rows NUMBER;
xmlDoc CLOB :=
'<ROWSET>
<ROW num="1">
<EMPLOYEE_ID>922</EMPLOYEE_ID>
<SALARY>1801</SALARY>
<HIRE_DATE>17-DEC-2007</HIRE_DATE>
<JOB_ID>ST_CLERK</JOB_ID>
<EMAIL>RAUSSJACK</EMAIL>
<LAST_NAME>JACK</LAST_NAME>
<DEPARTMENT_ID>20</DEPARTMENT_ID>
</ROW>
<ROW>
<EMPLOYEE_ID>923</EMPLOYEE_ID>
<SALARY>2001</SALARY>
<HIRE_DATE>31-DEC-2005</HIRE_DATE>
<JOB_ID>ST_CLERK</JOB_ID>
<EMAIL>PATHAK</EMAIL>
<LAST_NAME>PRATIK</LAST_NAME>
<DEPARTMENT_ID>20</DEPARTMENT_ID>
</ROW>
</ROWSET>';
BEGIN
insCtx := DBMS_XMLSTORE.newContext('EMPLOYEES'); -- Get saved context
DBMS_XMLSTORE.clearUpdateColumnList(insCtx); -- Clear the update settings
-- Set the columns to be updated as a list of values
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'EMPLOYEE_ID');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'SALARY');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'HIRE_DATE');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'JOB_ID');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'EMAIL');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'LAST_NAME');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'DEPARTMENT_ID');
-- Insert the doc.
rows := DBMS_XMLSTORE.insertXML(insCtx, xmlDoc);
--COMMIT;
DBMS_OUTPUT.put_line(rows || ' rows inserted.');
-- Close the context
DBMS_XMLSTORE.closeContext(insCtx);
END;
SELECT employee_id, LAST_name FROM employees WHERE employee_id = 114;
DECLARE
updCtx DBMS_XMLSTORE.ctxType;
rows NUMBER;
xmlDoc CLOB :=
'<ROWSET>
<ROW>
<EMPLOYEE_ID>114</EMPLOYEE_ID>
<LAST_NAME>PRABHU</LAST_NAME>
</ROW>
</ROWSET>';
BEGIN
updCtx := DBMS_XMLSTORE.newContext('EMPLOYEES'); -- get the context
DBMS_XMLSTORE.clearUpdateColumnList(updCtx); -- clear update settings
-- Specify that column employee_id is a "key" to identify the row to update.
DBMS_XMLSTORE.setKeyColumn(updCtx, 'EMPLOYEE_ID');
rows := DBMS_XMLSTORE.updateXML(updCtx, xmlDoc); -- update the table
DBMS_XMLSTORE.closeContext(updCtx); -- close the context
commit;
END;
Nowi want little modification on this above query like as i am passing static XML tags and i want it to pick the dynamic XML from web and use the XMLSTORE for the update.
and also for complex XML having 2-3 levels how this query needs to be changed.As i am new to this Oracle utillity any help from xepert will be a great help for me.
ThanksNowi want little modification on this above query like as i am passing static XML tags and i want it to pick the dynamic XML from webFrom a Web Service?
You'll need UTL_HTTP or HttpUriType interface to send the request and receive the XML response.
Search in the forum, there are already a lot of useful examples available.
and also for complex XML having 2-3 levels how this query needs to be changed.DBMS_XMLStore is OK for readily processing a canonical XML format (/ROWSET/ROW/COLUMN structure or alike).
However, if you have to deal with a more complex structure, you either have to :
- use a target object table that matches the XML structure
- preprocess the input document using XSLT to transform it to canonical format
That's why DBMS_XMLStore is not appropriate for multilevel documents, especially if they contain nested repeating groups.
In this case, XMLTable is a more flexible way of parsing the XML and process it relationally at the same time.
Depending on the size of the document, performance may be improved with schema-based object-relational storage.
For more help, please post a new thread in the {forum:id=34} forum, with the following information :
- database version (select * from v$version)
- a sample XML document (the complex one)
- DDL of your target table
- mapping between XML elements and columns (ie which tag goes to which column?)
- an XML schema (if you have one) -
Error while sending a mail using UTP_MAIL package in Oracle 10g
Hi,
We are using UTP_MAIL package to send a mail from Oracle 10g.We have follwed the following steps ...
SQL> connect sys/password as sysdba
Connected.
SQL> @$ORACLE_HOME/rdbms/admin/utlmail.sql
Package created.
Synonym created.
SQL> @$ORACLE_HOME /rdbms/admin/prvtmail.plb
Package body created.
SQL > alter system set smtp_out_server = '<mail_server_ip:25>' scope =spfile;
System altered..
Now we try the code
begin
utl_mail.send(
sender => 'sender's mail',
recipients => 'receiver mail',
CC => 'optional',
subject => 'Testing utl_mail',
message => 'Test Mail'
end;
But we get the following error...
ERROR at line 1:
ORA-29278: SMTP transient error: 421 Service not available
ORA-06512: at "SYS.UTL_SMTP", line 21
ORA-06512: at "SYS.UTL_SMTP", line 97
ORA-06512: at "SYS.UTL_SMTP", line 139
ORA-06512: at "SYS.UTL_MAIL", line 405
ORA-06512: at "SYS.UTL_MAIL", line 594
ORA-06512: at line 2
We also tried connecting to the mail server through telnet .But it is not getting connected..
Please help us to solve the issue.From your own posting you may have the clue, if you try to access your mail server through telnet and it is not successful, it means the service is down or there are networking issues.
On pre 10gR2 versions there was a bug 4083461.8. It could affect you if you are on 10gR1
"Bug 4083461 - UTL_SMTP.OPEN_CONNECTION in shared server fails with ORA-29278 Doc ID: Note:4083461.8"
This was fixed on 10gR2 base and on 9.2.0.8.0
~ Madrid -
Not able to display data in different columns using Unicode encoding
Hi,
Iam using Unicode encoding in my Java appln to support Japanese characters while downloading CSV report. But using the Unicode encoding displays all data in the first column of Excel sheet.
Please let me know how to display data in different columns using Unicode encoding in Excel sheet.Hi Venkat,
After extracting data into DSO check the request whether active or not.
Check data in DSO in contents.
If is there any restrictions on info providers in Queries.
Let us know status clearly.......
Reg
Pra
Maybe you are looking for
-
Selection Screen field selection in logical db PCH
Is any one have any idea how to code the select option part such as.. report should run if PCHOBJID is selected or any other (custom define field in parameter) field which is not PCH field. I will really appreciate.
-
Deletion and Creation of storage location.
Dear Experts, Plz advise how can we un-assign any storage location from any material & how can we create the new storage location. Regards Sumit Kalyan
-
BAPI_SALESORDER_CREATEFROMDAT2 with ref. SO
Hi experts, I'm facing a issue while using BAPI_SALESORDER_CREATEFROMDAT2 to create a sales order with reference to another sale order.The sale order is created whereas the document flow is not being mainteined... I think im not clear about supplying
-
New MySites does not use the specified permissions
I've changed the MySite Settings in Central Admin so that only my AD group called "DOMAIN\All employees" is added to the Read Permission Level setting. I've removed "All" and "All Windows". Now users create MySites, and at first the permissions seems
-
Okay. I was given the advice to make sure I had the latest Java. So I uninstalled all versions of Java. Reinstalled latest version of Java 6 update 23. Tried to reinstall Mozilla Firefox and got as far as the box that says: Import wizard settings and