SetBindValue
Is it posible to bind one value to multiple variables with
DBMS_XMLQuery.setBindValue with out having to name all the
variables differently
In the case where I am using the same named variable twice.
i.e.
select role, granted_role from role_role_privs
where role = :INROLE and granted_role <> :INROLE
I have tried this and get a message
:Missing IN or OUT parameter at index 1
If I can't bind on value to two variables then can I call
setBindvalue('INROLE','ROLE'); twice to bind to the second one.
This code gives the error.
create or replace function getxml return clob is
Result CLOB;
queryCtx DBMS_XMLQuery.ctxType;
v_query varchar2(400);
begin
v_query := 'select role, granted_role from role_role_privs'||
' where role = :INROLE and granted_role <> :INROLE';
-- set the query context.
queryCtx := DBMS_XMLQuery.newContext(v_query);
--DBMS_XMLQuery.clearBindValues(queryCtx);
DBMS_XMLQuery.setBindValue(queryCtx,'INROLE','JAVASYSPRIV');
DBMS_XMLQuery.setBindValue(queryCtx,'INROLE','JAVASYSPRIV');
result := DBMS_XMLQuery.getXML(queryCtx,DBMS_XMLQuery.NONE); --
get the result
return(Result);
end getxml;
This next piece of code fixes the error but does not meet the
need I have. It does not work like other Oracle query options.
In PL/SQL all values are bound by name. In Native Dynamic SQL I
can bind by position. It seems I don't have that option here.
create or replace function getxml return clob is
Result CLOB;
queryCtx DBMS_XMLQuery.ctxType;
v_query varchar2(400);
begin
v_query := 'select role, granted_role from role_role_privs'||
' where role = :INROLE and granted_role <> :INROLE2';
-- set the query context.
queryCtx := DBMS_XMLQuery.newContext(v_query);
--DBMS_XMLQuery.clearBindValues(queryCtx);
DBMS_XMLQuery.setBindValue(queryCtx,'INROLE','JAVASYSPRIV');
DBMS_XMLQuery.setBindValue(queryCtx,'INROLE2','JAVASYSPRIV');
--DBMS_XMLQuery.setBindValue(queryCtx,'INROLE2','JAVASYSPRIV');
result := DBMS_XMLQuery.getXML(queryCtx,DBMS_XMLQuery.NONE); --
get the result
return(Result);
end getxml;
Any help appreciated
Rick Laird
It is a bug #1819703. It will be fixed in the next coming
release.
Similar Messages
-
Xmlgen.SetbindValue example
Can someone give me a code example of using xmlgen.setbindvalue and the proper format of the xmlgen.getxml() method.
ThanksI'm not exactly sure what your problem is. You are able to bind the same value to another variable with a different name. If you won't know how many variables will appear in your select statement then you have a problem with how the XSU works. The XSU requires you know the structure of the SQL statement you pass it.
You could execute v_query using Native Dynamic SQL in 8i with a using clause containing your bind values. This should allow you to dynamically build your query with n amount of bind variables.
Also, you really should be using DBMS_XMLQUERY instead of XMLGEN. XMLGEN is there for backward compatibility, but DBMS_XMLQUERY is the latest and greatest XSU.
See the Oracle XML Portal website for more info at www.webspedite.com/oracle.
Regards,
Jason M Cohen -
SetBindValue() not binding.
I am using the setBindValue() method on the XSU to avoid re-parsing my query. However, when looking at the parse/execute ratio, I noticed it is 1. It is parsing for every execution. Here is my code:
--Determine the correct number of transitions to return.
IF num_transitions = 0 THEN --Return ALL transitions for the specified negotiation.
--Define negotiation transition select string.
queryCtx := DBMS_XMLQuery.newContext('SELECT * FROM v_ngtn_party_trnstn WHERE ID = :ngtnid ');
ELSE --Return the current transition for the specified negotiation.
queryCtx := DBMS_XMLQuery.newContext('SELECT * FROM v_get_ngtn_wtransitions WHERE ID = :ngtnid ');
END IF;
--DBMS_XMLQuery.clearBindValues(queryCtx);
DBMS_XMLQuery.setBindValue(queryCtx,'ngtnid',ngtn_id);
--Set the necessary XML parameters for the negotiation node.
FormatXML := format_xml(QueryCTX,'NEGOTIATION', 'NEGOTIATIONS', 'ERROR_RESULT', 'ID');
-- get the result..!
cl_ngtn := DBMS_XMLQuery.getXML(queryCtx);
DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query handle..
nullntsiii wrote:
> How is "troubleEvent " getting populated to start with?
> Tracy
At this point it is not. It is using an AS data model and
defaulting to
empty|null values. I have figured out one way to bind the
model to the
form items using <mx.binding...> tags. I imagine there
is a cleaner way
to do this and would love to hear them.
Back to your question. I need to learn how to initially
populate the
'troubleEvent' with a remote object call based on the
selected item in a
data grid in another custom MXML control that called this
MXML control
when selected. -
How do i add a root node to a XMLType
Hi all
I have a problem inserting a root node in a xml document generated by DBMS_XMLGEN.newcontextfromhierarchy. The function get_site_map_nodes generates a document like this:
<?xml version="1.0"?>
<siteMapNode f_page_id="1" title="rot" PATH="1">
<siteMapNode f_page_id="2" title="1.1" PATH="1.1">
<siteMapNode f_page_id="4" title="1.1.1" PATH="1.1.1"/>
</siteMapNode>
<siteMapNode f_page_id="3" title="1.2" PATH="1.2"/>
<siteMap/>
</siteMapNode>
This is correct but i want to add a root node so the result shows as below:
<?xml version="1.0"?>
<siteMap>
<siteMapNode f_page_id="1" title="rot" PATH="1">
<siteMapNode f_page_id="2" title="1.1" PATH="1.1">
<siteMapNode f_page_id="4" title="1.1.1" PATH="1.1.1"/>
</siteMapNode>
<siteMapNode f_page_id="3" title="1.2" PATH="1.2"/>
<siteMap/>
</siteMapNode>
</siteMap>
The problem is that i have no clue how to accomplish this.
Best regards
Daniel Carlsson
PACKAGE BODY PKG_PAGE_STRUCTURE
IS
FUNCTION get_level_path (in_page_id IN page_structure.f_page_id%TYPE)
RETURN VARCHAR2
IS
l_path VARCHAR2 (4000) := '';
BEGIN
SELECT MAX (SYS_CONNECT_BY_PATH (f_show_order, '.'))
INTO l_path
FROM page_structure
START WITH f_page_id = in_page_id
CONNECT BY PRIOR f_parent_page = f_page_id;
l_path := RTRIM (l_path, '.');
RETURN l_path;
END get_level_path;
FUNCTION get_site_map_nodes (in_page_id IN page_structure.f_page_id%TYPE)
RETURN XMLTYPE
IS
qryctx DBMS_XMLGEN.ctxhandle;
l_xml XMLTYPE;
BEGIN
qryctx :=
DBMS_XMLGEN.newcontextfromhierarchy
('select level, xmlelement("siteMapNode", XMLAttributes(f_page_id as "f_page_id",
f_title_phrase as "title", pkg_page_structure.get_level_path(f_page_id) as path))
FROM PAGE_STRUCTURE
START WITH f_page_id = :in_page_id
connect by f_parent_page = prior f_page_id
ORDER siblings BY f_show_order'
DBMS_XMLGEN.setbindvalue (qryctx, 'in_page_id', TO_CHAR (in_page_id));
l_xml := DBMS_XMLGEN.getxmltype (qryctx);
DBMS_XMLGEN.closecontext (qryctx);
RETURN l_xml;
END get_site_map_nodes;
END PKG_PAGE_STRUCTURE;
CREATE TABLE page_structure
(f_page_id NUMBER(10,0) NOT NULL,
f_parent_page NUMBER(10,0),
f_show_order NUMBER(10,0),
f_title_phrase VARCHAR2(20),
f_created_by NUMBER(10,0),
f_created_date DATE,
f_updated_by NUMBER(10,0),
f_updated_date DATE)
INSERT INTO page_structure
(F_PAGE_ID,F_PARENT_PAGE,F_SHOW_ORDER,F_TITLE_PHRASE,F_CREATED_BY,F_CREATED_DATE,F_UPDATED_BY,F_UPDATED_DATE)
VALUES
(1,NULL,1,'rot',1,'30-MAR-2006',NULL,NULL)
INSERT INTO page_structure
(F_PAGE_ID,F_PARENT_PAGE,F_SHOW_ORDER,F_TITLE_PHRASE,F_CREATED_BY,F_CREATED_DATE,F_UPDATED_BY,F_UPDATED_DATE)
VALUES
(2,1,1,'1.1',1,'30-MAR-2006',NULL,NULL)
INSERT INTO page_structure
(F_PAGE_ID,F_PARENT_PAGE,F_SHOW_ORDER,F_TITLE_PHRASE,F_CREATED_BY,F_CREATED_DATE,F_UPDATED_BY,F_UPDATED_DATE)
VALUES
(3,1,2,'1.2',1,'30-MAR-2006',NULL,NULL)
INSERT INTO page_structure
(F_PAGE_ID,F_PARENT_PAGE,F_SHOW_ORDER,F_TITLE_PHRASE,F_CREATED_BY,F_CREATED_DATE,F_UPDATED_BY,F_UPDATED_DATE)
VALUES
(4,2,1,'1.1.1',1,'30-MAR-2006',NULL,NULL)
/Please try below steps.
1. Complete Prerequisite for adding cluster node
2. Verify the node is accessible to all other nodes in the cluster. Run the following command from the existing node in the cluster.
cluvfy stage -pre crsinst -n newNode
3. Run cluvfy from any existing node
cluvfy stage -pre nodeadd -n <New Node>
Note : If cluvfy in above step shows any errors fix those and then proceed with this step
4. Change Directory to Clusterware Home and execute addNode scripts from any existing node.
cd $CRS_HOME/oui/bin
./addNode.sh -silent "CLUSTER_NEW_NODES={ <NewNode > } CLUSTER_NEW_PRIVATE_NODE_NAMES={ <Interconnect >} CLUSTER_NEW_VIRTUAL_HOSTNAMES={ < Virtual Host Name >}"
At the end of addNode, script will prompt to run for root.sh on newly added node.
5. Verify Node is successfully added
cluvfy stage -post nodeadd -n <NewNode >
6. Verify CRS Stack is running on the new Node.
$CRS_HOME/bin/crs_stat -t
7. To extend the Oracle RAC Installation to include the new Node, run addNode from $ORACLE_HOME/oui/bin from existing node in the cluster
cd $CRS_HOME/oui/bin
./addNode.sh
When OUI displays the Specify Cluster Nodes to Add to Installation window, select the node to be added, then click Next .
Verify the summary and run root.sh on new node when it prompts.
8. Adding New Instance on the New Node
$CRS_HOME/bin/lsnrctl status
9.Run $ORACLE_HOME/bin/dbca from any of the existing RAC Instances Oracle Home.
Select Oracle Real Application Clusters database , and then click Next .
Select Instance Management , and then click Next .
Select Add an Instance , then click Next .
Click Next to accept default instance name or it can be changed.
Check the summary window.
Note: Please check these steps in test environment first.
HTH -
To generate xml code in encoding as specified in system profile options
Hi,
i have a customer bug wherein the report page which is generated after a particular process, which is a .xml file, does not open because we have special characters which are not getting encoded properly!..
the probable solution to this would be to encode the .xml file in the encoding format specified in system profile options.
After the content generation the following code is used to generate the tags and the .xml page:
DBMS_XMLGEN.setRowSetTag(l_qryCtx,'INVOICE_SET');
DBMS_XMLGEN.setRowTag(l_qryCtx, 'INVOICE_RECORD');
DBMS_XMLGEN.setBindValue(l_qryCtx,'BATCH_ID', p_batch_id);
DBMS_XMLGEN.setBindValue(l_qryCtx,'SUPPLIER_ID', rec.supplier_id);
DBMS_XMLGEN.setBindValue(l_qryCtx,'SITE_ID', rec.site_id);
l_result_clob :=DBMS_XMLGEN.GETXML(l_qryCtx);
l_result_clob := substr(l_result_clob,instr(l_result_clob,'>')+1);
l_temp_invoice_count := DBMS_XMLGEN.getNumRowsProcessed(l_qryCtx);
l_invoice_count := l_invoice_count + l_temp_invoice_count;
DBMS_XMLGEN.closeContext(l_qryCtx);
clob_to_file(l_result_clob);
here we have a transaction type in portugese like Nota de Crédito
and the issue summary is as follows
It contains some foreign language symbols which are not encoded in UTF-8 format hence IE is showing the error. Even though in mozilla the file is completely opened but the same foreign language symbol is not shown. So the error exists in all the browsers.
can you please suggest how the encoding maybe done so as to avoid the above problem!...
and also how to include the encoding as per mentioned in the system profile options.Hi,
>>>The XSD doesn't have any messages only simple and complex types - I can't seem to relate (via drag and drop) them to a data or message type to generate the required objects.
maybe it has some reference inside to some other types which you did not get?
if so you need to import into IR/ESR all files and put the correct reference (external archives)
this would be the proper way to get the file generated according to the xml schema
Regards,
Michal Krawczyk -
We are currently receiving XML messages from a business partner that goes
through a transformation/parser first to make sure the xml document was
in MISMO form (Mortgage Industry Standard Message Organization). Then the
document is stored in a clob in a table. The document is stored Without
the tags. We are storing these XML messages into a CLOB datatype for
later processing. I want to read the CLOB and then parse out the
individual fields to store into a table. What is the best way to
accomplish this in PL/SQL? Here is one sample record:
<MORTGAGEDATA>
<APPLICATION LoanPurposeType="OTHER">
<LenderCaseIdentifier>3631681</LenderCaseIdentifier>
<LendersBranchIdentifier>2966448</LendersBranchIdentifier>
</APPLICATION>
<PROPERTY PropertyUsageType="Primary">
<Address1>1335 test</Address1>
<City>las cruces</City>
<State>NM</State>
<PostalCode>88001</PostalCode>
</PROPERTY>
<SUBJECTPROPERTY>
<SubjectPropertyEstimatedValueAmount>69000</SubjectPropertyEstimatedValueAmount>
</SUBJECTPROPERTY>
<BORROWERRECONCILEDLIABILITY LiabilityType="HelocSubjectProperty">
<LiabilityUnpaidBalanceAmount>0</LiabilityUnpaidBalanceAmount>
<LiabilityMonthlyPaymentAmount>0</LiabilityMonthlyPaymentAmount>
</BORROWERRECONCILEDLIABILITY>
<BORROWERRECONCILEDLIABILITY LiabilityType="MortgageLoanSubjectProperty">
<LiabilityUnpaidBalanceAmount>0</LiabilityUnpaidBalanceAmount>
</BORROWERRECONCILEDLIABILITY>
<BORROWER>
<FirstName>scooby</FirstName>
<MiddleName/>
<LastName>doo</LastName>
<NameSuffix/>
<MothersMaidenName>velma</MothersMaidenName>
</BORROWER>
</MORTGAGEDATA>
NOTE: I have tried to use DBMS_XMLQUERY and it comes out like this using a
stored procedure called printclob: When I do this the data is put into
one field called xml_app_msg. The problem is how do I reference the
individual fields like FirstName and so on to store in another table? Can
I apply a stylesheet and if so, how?
Or do I create an object type called xml_app_msg with the fields lastname
and so on?
-- The table is raw_xml_msg_tbl and the field with the stored infomation is
xml_app_msg.
set serveroutput on size 50000
declare
queryCtx DBMS_XMLquery.ctxType;
result CLOB;
begin
queryCtx := DBMS_XMLQuery.newContext('select xml_app_msg from raw_xml_msg_tbl where app_id = :APP_ID');
-- DBMS_XMLQuery.clearBindValue(queryCtx);
DBMS_XMLQuery.setBindValue(queryCtx,'APP_ID','LT1001');
-- get the result..!
result := DBMS_XMLQuery.getXML(queryCtx);
-- Now you can use the result to put it in tables/send as messages..
printClobOut(result);
DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query handle..
end;
OUTPUT:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<XML_APP_MSG><MORTGAGEDATA>
<BORROWER>
<FirstName>Falls</FirstName>
<MiddleName/>
<LastName>Water</LastName>
<NameSuffix/>
<SSN>123-45-6789</SSN>
</BORROWER>
</MORTGAGEDATA>
</XML_APP_MSG>
</ROW>
</ROWSET>
nullI parse the XML doc into a domdocument and then loop through using xpath.valueof to pull the individual values from the nodes and then build a generic insert. It works quite well with a small number of columns. I'm not sure how it would work with a lot of columns. You can get code examples from Steve Muench's book "Developing Oracle XML Applications".
-
I need to pass a query in form of string to DBMS_XMLQUERY.GETXML package...the parameters to the query are date and varchar ..please help me build the string .Below is the query and the out put. ( the string is building fine except the parameters are with out quotes)
here is the procedure
create or replace
procedure temp(
P_MTR_ID VARCHAR2,
P_FROM_DATE IN DATE ,
P_THROUGH_DATE IN DATE ) AS
L_XML CLOB;
l_query VARCHAR2(2000);
BEGIN
l_query:= 'SELECT
a.s_datetime DATETIME,
a.downdate Ending_date,
a.downtime Ending_time,
TO_CHAR(ROUND(a.downusage,3),''9999999.000'') kWh_Usage,
TO_CHAR(ROUND(a.downcost,2),''$9,999,999.00'') kWh_cost,
TO_CHAR(ROUND(B.DOWNUSAGE,3),''9999999.000'') KVARH
FROM
(SELECT s_datetime + .000011574 s_datetime,
TO_CHAR(S_DATETIME ,''mm/dd/yyyy'') DOWNDATE,
DECODE(TO_CHAR(s_datetime+.000011574 ,''hh24:'
||'mi''), ''00:'
||'00'',''24:'
||'00'', TO_CHAR(s_datetime+.000011574,''hh24:'
||'mi'')) downtime,
s_usage downusage,
s_cost downcost
FROM summary_qtrhour
WHERE s_mtrid = '
||P_MTR_ID||
' AND s_mtrch = ''1''
AND s_datetime BETWEEN TO_DATE('
||P_FROM_DATE||
',''DD-MON-YY'') AND (TO_DATE('
||P_THROUGH_DATE||
',''DD-MON-YY'') + 1)
) a,
(SELECT s_datetime + .000011574 s_datetime,
s_usage downusage
FROM summary_qtrhour
WHERE s_mtrid = '
||P_MTR_ID||
' AND s_mtrch = ''2''
AND s_datetime BETWEEN TO_DATE('
||P_FROM_DATE||
',''DD-MON-YY'') AND (TO_DATE('
||P_THROUGH_DATE||
','' DD-MON-YY'') + 1)
) B
where a.S_DATETIME = B.S_DATETIME(+)';
SELECT DBMS_XMLQUERY.GETXML('L_QUERY') INTO L_XML FROM DUAL;
INSERT INTO NK VALUES (L_XML);
DBMS_OUTPUT.PUT_LINE('L_QUERY IS :'||L_QUERY);
END;
OUTPUT parameters are in bold (the issue is they are coming without single quotes otherwise th equery is fine
L_QUERY IS :SELECT
a.s_datetime DATETIME,
a.downdate Ending_date,
a.downtime Ending_time,
TO_CHAR(ROUND(a.downusage,3),'9999999.000') kWh_Usage,
TO_CHAR(ROUND(a.downcost,2),'$9,999,999.00') kWh_cost,
TO_CHAR(ROUND(B.DOWNUSAGE,3),'9999999.000') KVARH
FROM
(SELECT s_datetime + .000011574 s_datetime,
TO_CHAR(S_DATETIME ,'mm/dd/yyyy') DOWNDATE,
DECODE(TO_CHAR(s_datetime+.000011574 ,'hh24:mi'), '00:00','24:00', TO_CHAR(s_datetime+.000011574,'hh24:mi')) downtime,
s_usage downusage,
s_cost downcost
FROM summary_qtrhour
WHERE s_mtrid = N3165 AND s_mtrch = '1'
AND s_datetime BETWEEN TO_DATE(01-JAN-13,'DD-MON-YY') AND (TO_DATE(31-JAN-13,'DD-MON-YY') + 1)
) a,
(SELECT s_datetime + .000011574 s_datetime,
s_usage downusage
FROM summary_qtrhour
WHERE s_mtrid = N3165 AND s_mtrch = '2'
AND s_datetime BETWEEN TO_DATE(01-JAN-13,'DD-MON-YY') AND (TO_DATE(31-JAN-13,' DD-MON-YY') + 1)
) B
where a.S_DATETIME = B.S_DATETIME(+)The correct way to handle this is to use bind variables.
And use DBMS_XMLGEN instead of DBMS_XMLQUERY :
create or replace procedure temp (
p_mtr_id in varchar2
, p_from_date in date
, p_through_date in date
is
l_xml CLOB;
l_query VARCHAR2(2000);
l_ctx dbms_xmlgen.ctxHandle;
begin
l_query:= 'SELECT
a.s_datetime DATETIME,
a.downdate Ending_date,
a.downtime Ending_time,
TO_CHAR(ROUND(a.downusage,3),''9999999.000'') kWh_Usage,
TO_CHAR(ROUND(a.downcost,2),''$9,999,999.00'') kWh_cost,
TO_CHAR(ROUND(B.DOWNUSAGE,3),''9999999.000'') KVARH
FROM
(SELECT s_datetime + .000011574 s_datetime,
TO_CHAR(S_DATETIME ,''mm/dd/yyyy'') DOWNDATE,
DECODE(TO_CHAR(s_datetime+.000011574 ,''hh24:'
||'mi''), ''00:'
||'00'',''24:'
||'00'', TO_CHAR(s_datetime+.000011574,''hh24:'
||'mi'')) downtime,
s_usage downusage,
s_cost downcost
FROM summary_qtrhour
WHERE s_mtrid = :P_MTR_ID
AND s_mtrch = ''1''
AND s_datetime BETWEEN TO_DATE(:P_FROM_DATE,''DD-MON-YY'')
AND (TO_DATE(:P_THROUGH_DATE,''DD-MON-YY'') + 1)
) a,
(SELECT s_datetime + .000011574 s_datetime,
s_usage downusage
FROM summary_qtrhour
WHERE s_mtrid = :P_MTR_ID
AND s_mtrch = ''2''
AND s_datetime BETWEEN TO_DATE(:P_FROM_DATE,''DD-MON-YY'')
AND (TO_DATE(:P_THROUGH_DATE,'' DD-MON-YY'') + 1)
) B
where a.S_DATETIME = B.S_DATETIME(+)';
l_ctx := dbms_xmlgen.newContext(l_query);
dbms_xmlgen.setBindValue(l_ctx, 'P_MTR_ID', p_mtr_id);
dbms_xmlgen.setBindValue(l_ctx, 'P_FROM_DATE', to_char(p_from_date, 'DD-MON-YY'));
dbms_xmlgen.setBindValue(l_ctx, 'P_THROUGH_DATE', to_char(p_through_date, 'DD-MON-YY'));
l_xml := dbms_xmlgen.getXML(l_ctx);
dbms_xmlgen.closeContext(l_ctx);
insert into nk values (l_xml);
end; -
Dbms_xmlgen using pl-sql record type
Hi
I want to pass pl-sql record type and want to generate xml. Can dbms_xmlgen access pl-sql record type instead of query?
OR please let me know any other package to pass pl-sql record type and generate XML.
Thanks in advanceCan dbms_xmlgen access pl-sql record type instead of query?Don't think so, but can't you pass the individual record components:
SQL> declare
type rec is record
a int,
b varchar2 (30)
r rec;
ctx int;
x xmltype;
begin
r.a := 1;
r.b := 'Michael';
ctx := dbms_xmlgen.newcontext ('select :x id, :y name from dual');
dbms_xmlgen.setbindvalue (ctx, 'x', r.a);
dbms_xmlgen.setbindvalue (ctx, 'y', r.b);
x := dbms_xmlgen.getxmltype (ctx);
dbms_output.put_line (x.getstringval ());
dbms_xmlgen.closecontext (ctx);
end;
<ROWSET>
<ROW>
<ID>1</ID>
<NAME>Michael</NAME>
</ROW>
</ROWSET>
PL/SQL procedure successfully completed.? -
XML Generation Using DBMS_XMLQuery
Hi,
I am generating XML using "DBMS_XMLQuery".
Requirement: To generate blank xml tag(Without data).
e.g : Table XXX has A,B,C,D columns.
I am using SQL : SELECT a AA,b BB,c CC,d DD FROM XXX;
<AA>1 </AA>
<BB>2 </BB>
<CC>3 </CC>
(Note : Columns A,B and C has Values but "d" column does not have value).
Since "D" column doesnot have value,it is not generating XML tag.
So ,How to generate XML tag(e.g <DD> </DD>) without Value?
Any idea,how to achieve the above?
Thanks in advance.
Rgds,
Manoj
==========================
<?xml version = '1.0'?>
<ORDERS>
<ORDER num="1">
<MESSAGE_ID>1</MESSAGE_ID>
<SOURCE_SYSTEM>Oracle</SOURCE_SYSTEM>
<OPERATION>OrderRMA</OPERATION>
<DATETIME>3/21/2006 15:30:44</DATETIME>
<VERSION>1</VERSION>
<COUNTRY>AUS</COUNTRY>
<LANGUAGE>ENG</LANGUAGE>
<DESTINATION_SYSTEM>Manhattan</DESTINATION_SYSTEM>
<DESTINATION_WAREHOUSE>AUSVIS</DESTINATION_WAREHOUSE>
<ORDER_HEADER>
<ORDER_HEADER_ROW num="1">
----You can set the null attribute to true , so that the tag appears in your XML
see the statement in Bold.
DECLARE
queryCtx dbms_xmlquery.ctxType;
result CLOB;
BEGIN
-- set up the query context
queryCtx := dbms_xmlquery.newContext(
'SELECT empno "EMP_NO"
, ename "NAME"
, deptno "DEPT_NO"
, comm "COMM"
FROM scott.emp
WHERE deptno = :DEPTNO'
dbms_xmlquery.setRowTag(
queryCtx
, 'EMP'
dbms_xmlquery.setRowSetTag(
queryCtx
, 'EMPSET'
DBMS_XMLQUERY.useNullAttributeIndicator(queryCtx,true);
dbms_xmlquery.setBindValue(
queryCtx
, 'DEPTNO'
, 30
result := dbms_xmlquery.getXml(queryCtx);
insert into clobtable values(result);commit;
dbms_xmlquery.closeContext(queryCtx);
END;
select * from clobtable
<?xml version = '1.0'?>
<EMPSET>
<EMP num="1">
<EMP_NO>7499</EMP_NO>
<NAME>ALLEN</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>300</COMM>
</EMP>
<EMP num="2">
<EMP_NO>7521</EMP_NO>
<NAME>WARD</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>500</COMM>
</EMP>
<EMP num="3">
<EMP_NO>7654</EMP_NO>
<NAME>MARTIN</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>1400</COMM>
</EMP>
<EMP num="4">
<EMP_NO>7698</EMP_NO>
<NAME>BLAKE</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM NULL="YES"/>
</EMP>
<EMP num="5">
<EMP_NO>7844</EMP_NO>
<NAME>TURNER</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>0</COMM>
</EMP>
<EMP num="6">
<EMP_NO>7900</EMP_NO>
<NAME>JAMES</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM NULL="YES"/>
</EMP>
</EMPSET>
http://sqltech.cl/doc/oracle9i/appdev.901/a89852/d_xmlque.htm -
Problem for xml generation using DBMS_XMLGEN
Hi All,
i have problem during xml generation using Any help would be highly appreciate
how could we publish xml data using data base API DBMS_XMLGEN in oracle applications (APPS) i.e. at 'View Output" using
Any help would be highly appreciate.
Let me know if need more explanation, this is High priority for me.
Thanks and Regards,
[email protected]
Message was edited by:
user553699You can set the null attribute to true , so that the tag appears in your XML
see the statement in Bold.
DECLARE
queryCtx dbms_xmlquery.ctxType;
result CLOB;
BEGIN
-- set up the query context
queryCtx := dbms_xmlquery.newContext(
'SELECT empno "EMP_NO"
, ename "NAME"
, deptno "DEPT_NO"
, comm "COMM"
FROM scott.emp
WHERE deptno = :DEPTNO'
dbms_xmlquery.setRowTag(
queryCtx
, 'EMP'
dbms_xmlquery.setRowSetTag(
queryCtx
, 'EMPSET'
DBMS_XMLQUERY.useNullAttributeIndicator(queryCtx,true);
dbms_xmlquery.setBindValue(
queryCtx
, 'DEPTNO'
, 30
result := dbms_xmlquery.getXml(queryCtx);
insert into clobtable values(result);commit;
dbms_xmlquery.closeContext(queryCtx);
END;
select * from clobtable
<?xml version = '1.0'?>
<EMPSET>
<EMP num="1">
<EMP_NO>7499</EMP_NO>
<NAME>ALLEN</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>300</COMM>
</EMP>
<EMP num="2">
<EMP_NO>7521</EMP_NO>
<NAME>WARD</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>500</COMM>
</EMP>
<EMP num="3">
<EMP_NO>7654</EMP_NO>
<NAME>MARTIN</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>1400</COMM>
</EMP>
<EMP num="4">
<EMP_NO>7698</EMP_NO>
<NAME>BLAKE</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM NULL="YES"/>
</EMP>
<EMP num="5">
<EMP_NO>7844</EMP_NO>
<NAME>TURNER</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>0</COMM>
</EMP>
<EMP num="6">
<EMP_NO>7900</EMP_NO>
<NAME>JAMES</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM NULL="YES"/>
</EMP>
</EMPSET>
http://sqltech.cl/doc/oracle9i/appdev.901/a89852/d_xmlque.htm -
Dynamic populating object variable
Hi Experts!
I have object type:create or replace type r_attribs_t is table of varchar2(100);
create or replace type r_relations_t is table of varchar2(40);
create or replace type r_spatial_t is table of varchar2(100);
type recfull_ot is object (
r_type char(2),
r_class varchar2(10),
r_atype varchar2(10),
r_id varchar2(30),
r_idr varchar2(100),
r_status char(2),
r_dtu date,
r_dtw date,
attribs r_attribs_t,
relations r_relations_t,
spatial_data r_spatial_t,
map member function newer return date,
member function get_ID return varchar2,
member procedure load_record (p_type varchar2, p_id varchar2, p_idr varchar2)
);and some tables:CREATE TABLE "G5ADR" (
"ID" VARCHAR2(30 BYTE) NOT NULL ENABLE,
"STATUS" NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
"G5TAR" NUMBER(1,0),
"G5NAZ" VARCHAR2(200 BYTE),
"G5KRJ" VARCHAR2(200 BYTE),
"G5WJD" VARCHAR2(200 BYTE),
"G5PWJ" VARCHAR2(200 BYTE),
"G5GMN" VARCHAR2(200 BYTE),
"G5ULC" VARCHAR2(200 BYTE),
"G5NRA" VARCHAR2(200 BYTE),
"G5NRL" VARCHAR2(200 BYTE),
"G5MSC" VARCHAR2(200 BYTE),
"G5KOD" VARCHAR2(200 BYTE),
"G5PCZ" VARCHAR2(200 BYTE),
"G5DTW" DATE,
"G5DTU" DATE,
"IDR" VARCHAR2(100 BYTE),
CONSTRAINT "G5ADR_PK" PRIMARY KEY ("ID")
CREATE TABLE "G5DOK" (
"ID" VARCHAR2(30 BYTE) NOT NULL ENABLE,
"STATUS" NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
"G5IDM" VARCHAR2(200 BYTE),
"G5KDK" NUMBER(2,0),
"G5DTD" DATE,
"G5DTP" DATE,
"G5SYG" VARCHAR2(200 BYTE),
"G5NSR" VARCHAR2(200 BYTE),
"G5OPD" VARCHAR2(200 BYTE),
"G5DTW" DATE,
"G5DTU" DATE,
"IDR" VARCHAR2(100 BYTE),
CONSTRAINT "G5DOK_PK" PRIMARY KEY ("ID")
-- ... and others ...I need to write member procedure load_record loading data from one of that tables into the object variable. The table to load data from depends on p_type input parameter, howerer. This makes the problem difficult for me, because I realy don't know how to deal with that. The attribs nested table shoud be populated with all the G5% columns from the table.
Any suggestions?
Help, please...
Edited by: JackK on Nov 18, 2010 9:48 AMOK, I've been experimenting on an alternative for DBMS_SQL...
Here's a simplified test case based on the structures you gave.
It should work on release 10.2 and upwards (I've only tested it on 11.2 though).
create or replace type r_attribs_obj is object(col varchar2(30), val varchar2(100));
create or replace type r_attribs_tab is table of r_attribs_obj;
CREATE OR REPLACE TYPE recfull_ot IS OBJECT (
r_id varchar2(30),
r_idr varchar2(100),
attribs r_attribs_tab,
member procedure load_record (self in out recfull_ot, p_type varchar2, p_id varchar2, p_idr varchar2)
CREATE OR REPLACE TYPE BODY recfull_ot IS
MEMBER PROCEDURE load_record (self in out recfull_ot, p_type varchar2, p_id varchar2, p_idr varchar2)
IS
ctx dbms_xmlgen.ctxHandle;
res xmltype;
attribs_tab r_attribs_tab;
BEGIN
ctx := dbms_xmlgen.newContext('SELECT * FROM '||p_type||' WHERE id = :1 AND idr = :2');
dbms_xmlgen.setBindValue(ctx,'1',p_id);
dbms_xmlgen.setBindValue(ctx,'2',p_idr);
res := dbms_xmlgen.getXMLType(ctx);
dbms_xmlgen.closeContext(ctx);
self.r_id := p_id;
self.r_idr := p_idr;
SELECT cast(
multiset(
select col, val
from xmltable(
'for $i in /ROWSET/ROW/*
where fn:starts-with(local-name($i),"G5")
return element r
attribute col {local-name($i)},
$i/text()
passing res
columns col varchar2(30) path '@col',
val varchar2(100) path '.'
as r_attribs_tab
) INTO self.attribs
FROM dual
END;
END;
CREATE TABLE "G5ADR" (
"ID" VARCHAR2(30 BYTE) NOT NULL ENABLE,
"G5NAZ" VARCHAR2(200 BYTE),
"G5KRJ" VARCHAR2(200 BYTE),
"G5WJD" VARCHAR2(200 BYTE),
"IDR" VARCHAR2(100 BYTE),
CONSTRAINT "G5ADR_PK" PRIMARY KEY ("ID")
insert into g5adr (ID, G5NAZ, G5KRJ, G5WJD, IDR) values ('001', 'NAZ001', 'KRJ001', 'WJD001', '1');
insert into g5adr (ID, G5NAZ, G5KRJ, G5WJD, IDR) values ('002', 'NAZ002', 'KRJ002', 'WJD002', '1');
insert into g5adr (ID, G5NAZ, G5KRJ, G5WJD, IDR) values ('003', 'NAZ003', 'KRJ003', 'WJD003', '1');Verifying the nested table is correctly loaded...
SQL> set serveroutput on
SQL> DECLARE
2 obj recfull_ot := recfull_ot(null, null, null);
3 BEGIN
4 obj.load_record('G5ADR', '001', 1);
5 for i in 1..obj.attribs.count loop
6 dbms_output.put_line(obj.attribs(i).col||' = '||obj.attribs(i).val);
7 end loop;
8 END;
9 /
G5NAZ = NAZ001
G5KRJ = KRJ001
G5WJD = WJD001
PL/SQL procedure successfully completed -
Converting Query results into HTML email
Hi,
I am using oracle 11g. I' m using the following procedure to send out html emails from a static query in the procedure and it works fine. I wanted to make it dynamic and pass the sql query as a parameter to procedure and build the html tags based on the query. Any thoughts?
CREATE OR REPLACE PROCEDURE html_sql_results
is
v_rows clob;
v_header clob;
cursor v_cursor is
select SR_NO,STATE,DUE_DT,PROCESS_DT,STATUS,DAY_NO,SEQ_NO
from T_TABLE;
BEGIN
v_header := '<table border=1>
<tr style=''background:#8DB3E2''>
<td><p><b>SR_NO</b></p></td>
<td><p><b>STATE</b></p></td>
<td><p><b>DUE_DT</b></p></td>
<td><p><b>PROCESS_DT</b></p></td>
<td><p><b>STATUS</b></p></td>
<td><p><b>DAY_NO</b></p></td>
<td><p><b>SEQ_NO</b></p></td>
</tr>';
v_rows := Null;
FOR i in v_cursor
LOOP
v_rows := v_rows ||
'<tr>
<td> <p>' || I.SR_NO||'</p></td>
<td> <p>' || I.STATE||'</p></td>
<td> <p>' || I.DUE_DT ||'</p></td>
<td> <p>' || I.PROCESS_DT ||'</p></td>
<td> <p>' || I.STATUS||'</p></td>
<td> <p>' || I.DAY_NO ||'</p></td>
<td> <p>' || I.SEQ_NO||'</p></td>
</tr> ';
END LOOP;
if v_rows is not null then
v_rows:= v_header ||v_rows ||' </table> ' ;
dbms_output.put_line(v_rows);
email_results(v_rows);
end if ;
end ;
/A possible way :
SQL> var result clob
SQL> DECLARE
2
3 ctx dbms_xmlgen.ctxHandle;
4 qry varchar2(2000) := 'SELECT * FROM hr.employees WHERE department_id = :1';
5
6 xsl xmltype := xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
7 <xsl:output method="html"/>
8 <xsl:template match="/ROWSET">
9 <table border="1">
10 <tr style="background:#8DB3E2">
11 <xsl:for-each select="ROW[1]/*">
12 <td><p><b><xsl:value-of select="name()"/></b></p></td>
13 </xsl:for-each>
14 <xsl:apply-templates/>
15 </tr>
16 </table>
17 </xsl:template>
18 <xsl:template match="ROW">
19 <tr><xsl:apply-templates/></tr>
20 </xsl:template>
21 <xsl:template match="ROW/*">
22 <td><p><b><xsl:value-of select="."/></b></p></td>
23 </xsl:template>
24 </xsl:stylesheet>');
25
26 res clob;
27
28 BEGIN
29
30 ctx := dbms_xmlgen.newContext(qry);
31 dbms_xmlgen.setBindValue(ctx, '1', 90);
32 dbms_xmlgen.setNullHandling(ctx, dbms_xmlgen.EMPTY_TAG);
33 dbms_xmlgen.setXSLT(ctx, xsl);
34
35 :result := dbms_xmlgen.getXML(ctx);
36 dbms_xmlgen.closeContext(ctx);
37
38 --dbms_output.put_line(res);
39
40 END;
41 /
PL/SQL procedure successfully completed.
SQL> print result
RESULT
<table border="1"><tr style="background:#8DB3E2"><td><p><b>EMPLOYEE_ID</b></p></
td><td><p><b>FIRST_NAME</b></p></td><td><p><b>LAST_NAME</b></p></td><td><p><b>EM
AIL</b></p></td><td><p><b>PHONE_NUMBER</b></p></td><td><p><b>HIRE_DATE</b></p></
td><td><p><b>JOB_ID</b></p></td><td><p><b>SALARY</b></p></td><td><p><b>COMMISSIO
N_PCT</b></p></td><td><p><b>MANAGER_ID</b></p></td><td><p><b>DEPARTMENT_ID</b></
p></td><tr><td><p><b>100</b></p></td><td><p><b>Steven</b></p></td><td><p><b>King
</b></p></td><td><p><b>SKING</b></p></td><td><p><b>515.123.4567</b></p></td><td>
<p><b>17/06/03</b></p></td><td><p><b>AD_PRES</b></p></td><td><p><b>24000</b></p>
</td><td><p><b></b></p></td><td><p><b></b></p></td><td><p><b>90</b></p></td></tr
<tr><td><p><b>101</b></p></td><td><p><b>Neena</b></p></td><td><p><b>Kochhar</b></p></td><td><p><b>NKOCHHAR</b></p></td><td><p><b>515.123.4568</b></p></td><td><
p><b>21/09/05</b></p></td><td><p><b>AD_VP</b></p></td><td><p><b>17000</b></p></t
d><td><p><b></b></p></td><td><p><b>100</b></p></td><td><p><b>90</b></p></td></tr
<tr><td><p><b>102</b></p></td><td><p><b>Lex</b></p></td><td><p><b>De Haan</b></p></td><td><p><b>LDEHAAN</b></p></td><td><p><b>515.123.4569</b></p></td><td><p><
b>13/01/01</b></p></td><td><p><b>AD_VP</b></p></td><td><p><b>17000</b></p></td><
td><p><b></b></p></td><td><p><b>100</b></p></td><td><p><b>90</b></p></td></tr></
tr></table>Typically, XSLT stylesheets may be stored in the database too, so that you can modify and use different presentation templates without touching the code. -
Error XSQL-017 Running XML Document Demo
Environment: Oracle 8.1.6 (NT 4.0)
XSQL 1.0.4.1
JDK 1.1.8
While running the XML Document Demo, I enter the Author, Title, Stylesheet and XML Document fields, and click the "Validate and Insert" button. Then I get the messages shown below. Any ideas? Thanks.
===== ===== Start Of Messages ===== =====
XSQL-017: Unexpected Error Occurred
java.lang.NoClassDefFoundError: java/sql/Clob
at
oracle.jdbc.driver.OracleStatement.get_clob_value(OracleStatement.java:4447)
at
oracle.jdbc.driver.OracleStatement.getCLOBValue(OracleStatement.java:3025)
at
oracle.jdbc.driver.OracleCallableStatement.getCLOB(OracleCallableStatement.java:439)
at
oracle.xml.sql.dml.OracleXMLSave.createTempCLOBFromString(Compiled
Code)
at
oracle.xml.sql.dml.OracleXMLSave.getLobVal(OracleXMLSave.java:765)
at
oracle.xml.sql.dml.OracleXMLSave.getObjectVal(OracleXMLSave.java:690)
at oracle.xml.sql.dml.OracleXMLSave.getStructVal(Compiled
Code)
at
oracle.xml.sql.dml.OracleXMLSave.setBindValue(OracleXMLSave.java:1206)
at oracle.xml.sql.dml.OracleXMLSave.saveNodeVal(Compiled
Code)
at
oracle.xml.sql.dml.OracleXMLSave.saveNode(OracleXMLSave.java:2146)
at oracle.xml.sql.dml.OracleXMLSave.saveNodes(Compiled
Code)
at
oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:1954)
at
oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1060)
at
oracle.xml.xsql.actions.XSQLInsertRequestHandler.handleAction(XSQLInsertRequestHandler.java:126)
at oracle.xml.xsql.XSQLDocHandler.getDocument(Compiled
Code)
at oracle.xml.xsql.XSQLPageProcessor.process(Compiled Code)
at oracle.xml.xsql.XSQLServlet.doGet(XSQLServlet.java:60)
at oracle.xml.xsql.XSQLServlet.doPost(XSQLServlet.java:81)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at oracle.lite.web.JupServlet.service(JupServlet.java:186)
at oracle.lite.web.MimeServletHandler.handle(Compiled Code)
at oracle.lite.web.JupApplication.service(Compiled Code)
at oracle.lite.web.JupHandler.handle(Compiled Code)
at oracle.lite.web.HTTPServer.process(Compiled Code)
at oracle.lite.web.HTTPServer.handleRequest(Compiled Code)
at oracle.lite.web.JupServer.handle(Compiled Code)
at oracle.lite.web.SocketListener.process(Compiled Code)
at oracle.lite.web.SocketListener$ReqHandler.run(Compiled
Code)
===== ===== End Of Messages ===== =====
nullUsing JDK 1.1.8 you must use the JDBC 1.x driver in classes111.zip and the companion version of the XML SQL Utility xsu111.jar.
You'll need to download these from OTN from http://otn.oracle.com/tech/xml and then replace them in your classpath for the classes12.zip and xsu12.jar that you're using. -
Dbms_xmlgen.newcontext query from multiple tables and ||
I have two questions
How do I get a dbms_xmlgen.context to query from multiple tables? I have been able to make it work with using one table only, but not with multiple tables.
And how to get the || (concat) to work within my query for my output to an xml file?
Here is my current query:
create or replace function get_xml return clob is
result clob;
qryctx dbms_xmlgen.ctxHandle;
SELECT DBMS_XMLGEN.getxml('select prefix, suffix, fiscal_yr
FROM rcv.recv_accessions ra
where ra.prefix = 8 and ra.fiscal_yr = 11')xml into result FROM dual;
result := DBMS_XMLGEN.getXML(qryCtx);
This is what I desire:
SELECT DBMS_XMLGEN.getxml('select ra.prefix||'-'|| ra.suffix||'-'|| ra.fiscal_yr accession, ss.date_in, st.test
FROM rcv.recv_accessions ra, ser.sero_samples ss, ser.sero_tests st
where ra.prefix = 8 and ra.fiscal_yr = 11 and ss.raid = ra.id and st.ssid = ss.id')xml into result FROM dual;
On this both the reference to multiple tables and the concat function cause errors.
Thank you
Edited by: user583094 on Mar 2, 2011 3:36 PMHi,
for the concat do I use xmlconcat?No, XMLConcat is used to concatenate XMLType fragments.
The || operator will do fine, but you must escape any single quote inside the string :
SELECT DBMS_XMLGEN.getxml(
'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
ss.date_in,
st.test
FROM rcv.recv_accessions ra,
ser.sero_samples ss,
ser.sero_tests st
WHERE ra.prefix = 8
AND ra.fiscal_yr = 11
AND ss.raid = ra.id
AND st.ssid = ss.id'
INTO result
FROM dual;Or, use the quoting operator to define a custom string delimiter :
SELECT DBMS_XMLGEN.getxml(
q'{SELECT ra.prefix ||'-'|| ra.suffix ||'-'|| ra.fiscal_yr as accession,
ss.date_in,
st.test
FROM rcv.recv_accessions ra,
ser.sero_samples ss,
ser.sero_tests st
WHERE ra.prefix = 8
AND ra.fiscal_yr = 11
AND ss.raid = ra.id
AND st.ssid = ss.id
INTO result
FROM dual;BTW, a good practice would be to use bind variables for the query. DBMS_XMLGEN can handle them nicely :
CREATE OR REPLACE FUNCTION get_xml
RETURN CLOB
IS
qryctx DBMS_XMLGEN.ctxHandle;
v_out CLOB;
qrystr VARCHAR2(4000) :=
'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
ss.date_in,
st.test
FROM rcv.recv_accessions ra,
ser.sero_samples ss,
ser.sero_tests st
WHERE ra.prefix = :b_prefix
AND ra.fiscal_yr = :b_fiscal_yr
AND ss.raid = ra.id
AND st.ssid = ss.id';
BEGIN
qryctx := DBMS_XMLGEN.newContext(qrystr);
DBMS_XMLGEN.setBindValue(qryctx, 'b_prefix', '8');
DBMS_XMLGEN.setBindValue(qryctx, 'b_fiscal_yr', '11');
-- to generate empty elements if necessary :
DBMS_XMLGEN.setNullHandling(qryctx, DBMS_XMLGEN.EMPTY_TAG);
v_out := DBMS_XMLGEN.getXML(qryctx);
DBMS_XMLGEN.closeContext(qryctx);
RETURN v_out;
END; -
Insert new column after get then XML
Hello,
I use Oracle 8i and SQL Utility. I want to do a query and after that, modify or insert the values of some elements.
xmlgen.clearBindValues;
xmlgen.setBindValue('vCity', vCity);
xmlSQL := 'select name, depto from emp where city = :vCity';
xmlString := xmlgen.getXML(xmlSQL);
Now, I want to read each line and modify
the name or depto values before create the
XML file. How can I do this?
Thanks,
Arthur RafaelAgain, it depends.
If you just want to fix your query
Create Table TABLE AS
Select column1, to_char(column2) column2, column3 from Table1
UNION
Select column1, column2, column3 from Table2;If you want to fix Table1
ALTER TABLE table1
ADD( column2_varchar2 VARCHAR2(30) );
UPDATE table1
SET column2_varchar2 = to_char( column2 );
ALTER TABLE table1
DROP( column2 );
ALTER TABLE table1
RENAME COLUMN column2_varchar2 TO column2Taking a step back, though, why are you creating a new table that is the result of unioning two other tables? Is this a one-time data model change? Or is this part of some ongoing process?
Justin
Maybe you are looking for
-
Problem with servicegen and how to convert java classes to webservices
I am a beginner and am trying to convert all my java code into webservices,I have a java class Test.java and number of other third party libraries and my own java files that are reffered in Test.java. I want to expose the public methods in Test.java
-
[EJB:015001] error while deploying an ejb on weblogic app server
Hi, I'm trying to deploy an ear which has lot of modules and it is failing for one of the ejb module. The exception is as follows: <Mar 22, 2011 7:47:01 PM GMT+05:30> <Error> <Deployer> <WL-149265> <Failure occurred in the execution of deployment req
-
I can't load new itunes and the old itunes no longer works - why?
My old itunes worked perfectly and then just stopped working yesterday. I have tried for 3 hours to install the new version but without success.
-
Saving monitor views as quicktime file
For training purposes I would like to capture a series of actions from my screen and save as a quicktime file. I see Grab lets me take a single screen shot but I need to capture more than this. How can I do this? Thanks in advance
-
Categories, subcategories and items in one query
Hi, I have this situation. I have a category table, a subcategory table and an item table. The structure is like below: Category id_cat..........catname 1...................cat1 2...................cat2 3...................cat3 4...................ca