Development query?
Hi Friends
What is the diff bet badi development(badi already existing), custom development and bapi development(bapi already existing).If both badi and bapi exist. Which is preferred for modifications.
Regards
Ian
Hi,
BADI developments means implementation of a BADI.,custom development could be any kind of development like developing a report,implementing a BADI,creating a custom smartform i.e. basically any developments which fall under RICEFW (reports,Interface,conversion,Enhancement,Forms and Workflows).
Generally for modifications BADI is preferred.
Similar Messages
-
WEB BASED MAPPING APPLICATION TO DEVELOP QUERY UTILITY USING MAPVIEWER
Dear Sir,
please any one can answer me as soon as possible its very urgent
WEB BASED MAPPING APPLICATION TO DEVELOP QUERY UTILITY USING MAPVIEWER
I As oracle mapviewer Chapter 8 (Oracle Maps) says generating our own Web based mapping application we are trying to generate our own maps for our own data contains in our layers like example boundary lines and roads and etc. and we are following complete example as described in Oracle Mapviewer Document Chapter 8.
Before this step we tried with demo data downloaded from OTN mvdemo. And we downloaded latest demo today itself from the OTN and imported into our database schema called mvdemo. And we copied all three jar files mvclient and mvconnection and mvpalette into our jdeveloper .
II. We created a jsp to execute the following code from oracle mapviewer chapter 8 documents
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces/customizable" prefix="cust"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/jwcache.tld"
prefix="jwcache"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/fileaccess.tld"
prefix="fileaccess"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/jesitaglib.tld"
prefix="JESI"%>
<f:view>
<html>
<head>
<META http-equiv="Content-Type" content="text/html" charset=UTF-8>
<TITLE>A sample Oracle Maps Application</TITLE>
<script language="Javascript" src="jslib/loadscript.js"></script>
<script language=javascript>
var themebasedfoi=null
function on_load_mapview()
var baseURL = " http://localhost:8888/mapviewer/omserver";
// Create an MVMapView instance to display the map
var mapview = new MVMapView(document.getElementById("map"), baseURL);
// Add a base map layer as background
mapview.addBaseMapLayer(new MVBaseMap("mvdemo.demo_map"));
// Add a theme-based FOI layer to display customers on the map
themebasedfoi = new MVThemeBasedFOI('themebasedfoi1','mvdemo.customers');
themebasedfoi.setBringToTopOnMouseOver(true);
mapview.addThemeBasedFOI(themebasedfoi);
// Set the initial map center and zoom level
mapview.setCenter(MVSdoGeometry.createPoint(-122.45,37.7706,8307));
mapview.setZoomLevel(4);
// Add a navigation panel on the right side of the map
mapview.addNavigationPanel('east');
// Add a scale bar
mapview.addScaleBar();
// Display the map.
mapview.display();
function setLayerVisible(checkBox){
// Show the theme-based FOI layer if the check box is checked and
// hide the theme-based FOI layer otherwise.
if(checkBox.checked)
themebasedfoi.setVisible(true) ;
else
themebasedfoi.setVisible(false);
</script>
</head>
<body onload= javascript:on_load_mapview() >
<h2> A sample Oracle Maps Application</h2>
<INPUT TYPE="checkbox" onclick="setLayerVisible(this)" checked/>Show customers
<div id="map" style="width: 600px; height: 500px"></div>
</body>
</html>
</f:view>
<!--
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=windows-1252"/>
<title>mapPage</title>
</head>
<body><h:form binding="#{backing_mapPage.form1}" id="form1"></h:form></body>
</html>
-->
<%-- oracle-jdev-comment:auto-binding-backing-bean-name:backing_mapPage--%>
III. When we run this jsp it’s giving us following Two errors
1 Error: ‘MVMapView’ is undefined
Code: 0
URL: http://192.168.100.149:8988/MapViewerApp-WebProj-context-root/faces/mapPage.jsp
2 Error: ‘themebasedfoi’ is null or not an object
Code: 0
URL: http://192.168.100.149:8988/MapViewerApp-WebProj-context-root/faces/mapPage.jsp
Please let us know what could be problem as soon as possible. Very urgent
Please let us know where we can find Mapviewer AJAX API’s for Jdeveloper Extention
Thanks
KabeerI currently use parameters, and they are passed from the form to the report. Report is then generated based on a function returning ‘strongly typed’ cursor. The ‘strongly typed’ cursor in my case returns a record consisting of an orderly collection of fields.
This collection of fields is returned by another function that relies on the IF … THEN logic.
However, the number of IF ... THEN statements is quite large (currently 64 covering all possible combinations of 6 parameters available in the form).
I would like to avoid the large number of IF … THEN statements, and hope that there is a way of passing a string to a query, where the Dynamic SQL would in Select close and Where close reflect parameters passed by the form.
In addition to this I would like to avoid creating and populating a table or a view dedicated to the report, because this may lead to a conflict in case of multiple users concurrently generating reports with different choice of parameters.
Edited by: user6883574 on May 28, 2009 9:16 PM -
Sql developer query window corrupting on scroll
Hi there
I have a weird error - when I scroll in my SQL developer query window (tab) the text corrupts and only comes back if I click in the window somewhere or save. Has anyone else seen this? I'm on version 1.5.5 and don't really want to upgrade to the latest as I don't like the new layout (no dbmsoutput etc in the results window)
Cheers, Katesorted it by adding a line AddVMOption -Dsun.java2d.noddraw=true to the sqldeveloper.conf file, as per thread SQL Editor not refreshing after scroll on Windows Vista
-
Save layout of queries in SQL Developer query builder?
Sometimes queries are very complex and moving tables around in the graphical view is really helpfull to better understand them.
Unfortunately this layout does not get saved with "save" (because this is a simple text file).
Once upon there was a query builder (included with designer 2000 and later vom 1991 to 1998) that had a proprietary format (.brw) to just do that: Save a query including layout.
Any chance to save the layout of SQL Developer query builder queries?I dont think there is any way to save the layout for the query, you can request an enhancement on the Exchange for this http://sqldeveloper.oracle.com/
But if you only need to restore the query you are working with later, or move it to another workstation and continue editing using the query builder, you only need the SQL code generated; when you paste it in an opened worksheet (on the same database or even a clone with the same structure) the query builder is able to resume working just fine with default positioning for the table objects.
If you hand edit the query and insert some SQL manually then the query builder may stop working for particularly complex statements, in this case it will warn you and disable itself. -
I wnat to develop Query Builder
Hi Dear All
my requirement is to develop query builder because of genearting dynamic sql statement at run time. i'm using 9iDS and query builder is not provided with it as separate application. is there anyon who can help me how it should be get started. i'll be very thankful to u
Best Regards!!!Query Builder was desupported as a product as part of the developer suite.
see http://www.oracle.com/technology/products/forms/pdf/forms_upgrade_reference.pdf
Regards
Grant Ronald
Forms product Management -
Declare, Set, and Use a variable in a SQL Developer Query
I come from the SQL Server world and am trying to do something very simple: Declare, set, and use a variable in a query. For example:
Declare @lastPeriod date;
Set @lastPeriod = (select max(payperiod) from table 1 where payperiod < current_date);
Select field 1,
Field2
From table2
Where payperiod = @lastPeriod
The variable is going to be used in more areas in the query which is why I am simply not using a Sub-query in the where clause. I appreciate any assistance.This forum is for issues with the SQL Developer tool. You'd get more response in the SQL And PL/SQL forum.
That said, read up on bind variables and substitution variables.
Whenever you can you should use Bind variables (e.g. *:lastPeriod* ), as they increase performance. In sqldev, there's no need to declare as you will be prompted to enter them on execution (F9), but you do if you execute as script (F5) (e.g. VARIABLE lastPeriod VARCHAR2(30);).
Alternatively, Substitution variables (e.g. *&lastPeriod* ) will literally be substituted in your statement before the database parses it. In sqldev, there's no need to declare as you will be prompted to enter them on execution (either F9 or F5), but you can (DEF lastPeriod='TEST'; ).
Have fun,
K. -
SQL*Developer 'Query Results' Not Displaying
I have just recently installed SQL*Developer v3.2.2 and after I run a SQL query the tab 'Query Result' tab is not displayed. I have tried to show this tab and to use the arrow keys at the bottom of the screen to display this screen but I cannot view the query results. I have used v1.5.1 in the past and know that it should display when after running a query and can be resized if required but I cannot seem to show it is v3.2.2
Hi,
Yes, I did install to a clean directory. I have even deleted all contents of the directory and re downloaded
the software again to the same directory but this did not work either it still remembered the original settings.Keep in mind there are two locations that an installation updates:
1. The SQL Developer installation directory (which you deleted).
2. The User-Related Information (in your "user home" directory), which is updated by the settings migration
Perhaps Jim meant you should also remove the user settings for the last SQL Developer version installed and possibly even avoid migrating the old 1.5.x settings when you first start SQL Developer after that. See the following forum thread, probably unrelated to your situation, but containing where to find the location of user-related information in the Help:
Re: IDE issue - Query Result grid is not selectable or scrollable
Hope this helps,
Gary
SQL Developer Team -
Application Development : Query Response
My problem seems very simple, however I have been working on it for close to two days now. With the absence of a true DBA, I am at a loss. We have an Oracle 10G Box running an application on one of our "Retired Servers". The server only has 1 Gig Of member. However, this application has been utilizing this box for persitent storage for some time. My problem is with one of the queries that is executing on the box. The table that is being excecuted on is small, but I have a query that joins a couple of tables together on a "Form_ID" then at the end of the query there is constraint logic that is "where form_id = 25" for example. This query is now taking close to two minutes to run, however, if I remove that constraint the query returns in less than a second. The form_id is a unique key that is being utilized, and I even moved the constraint to a nested query before a join and the explain plan and result are exactly the same. The explain plan shows more cost, bytes, and cardinality on the query without the constraint, however, it returns almost immediately. This query has been in this application for over a year, so I am at a loss as to why that constraint would cause the issue. If i let the entire query run as a view then add the where form_id = "25" or whatever, the same problem exist, the initial query is very fast, it is just constraining it that is the problem. I appreciate any insight someone could give me. Thanks.
ShawnYou are in the wrong forum. You will get better responses in the "SQL and PL/SQL" forum.
You will also need to provide more detailed information if anyone is going to help you. -
New query for 'Manage Database' option in SQL Developer
Dear all,
I want to suggest a changed query for the 'Manage Database' option in SQL Developer (right-click on the connection), see the query below.
This query has the following changes;
- extra column with the Maximum disk space based on the datafiles (considering autoextend of datafiles); MAX_DATAFILES
- the PERCENT_USED and PCT_USED are based on the MAX_DATAFILES, as this is really important (and not the difference between ALLOCATED and USED)
- the results are shown in GB, as that is in my opinion more relevant in this time of data explosion
- rename of the column FREE to UNUSED_ALLOCATED, as this column identifies how much of the Allocated space is not used
I hope the query can replace the current one, to improve SQL Developer even more.
Thanks for the nice tool SQL Developer!
Kind regards,
Siebe
-- Manage Database - Changed Oracle SQL Developer query with regard to Usage of Tablespaces in GB (considering autoextend of datafiles)
SELECT "TABLESPACE_NAME", "PERCENT_USED", "PCT_USED", "MAX_DATAFILES", "ALLOCATED", "USED", "UNUSED_ALLOCATED", "DATAFILES" FROM(
select * from (
SELECT a.tablespace_name,
--'SQLDEV:GAUGE:0:100:0:0:'||nvl(ROUND(((c.bytes-nvl(b.bytes,0))/c.bytes)*100,2),0) percent_used,
--ROUND(((c.bytes-nvl(b.bytes,0))/c.bytes)*100,2) PCT_USED,
'SQLDEV:GAUGE:0:100:0:0:'||nvl(ROUND(((c.bytes-nvl(b.bytes,0))/c.maxbytes)*100,2),0) percent_used,
ROUND(((c.bytes-nvl(b.bytes,0))/c.maxbytes)*100,2) PCT_USED,
round(c.bytes/1024/1024/1024,2) allocated,
round(c.bytes/1024/1024/1024-nvl(b.bytes,0)/1024/1024/1024,2) used,
round(c.maxbytes/1024/1024/1024,2) max_datafiles,
round(nvl(b.bytes,0)/1024/1024/1024,2) unused_allocated,
c.datafiles
FROM dba_tablespaces a,
( SELECT tablespace_name, SUM(bytes) bytes FROM dba_free_space GROUP BY tablespace_name ) b,
( select count(1) datafiles, SUM(bytes) bytes, SUM(DECODE(autoextensible, 'YES', maxbytes, bytes)) maxbytes, tablespace_name from dba_data_files GROUP BY tablespace_name ) c
--( select count(1) datafiles, SUM(bytes) bytes, SUM(c.maxbytes) maxbytes, tablespace_name from dba_data_files GROUP BY tablespace_name ) c
WHERE b.tablespace_name (+) = a.tablespace_name
AND c.tablespace_name (+) = a.tablespace_name
ORDER BY nvl(((c.bytes-nvl(b.bytes,0))/c.maxbytes),0) DESC
) --sub1 order by 1 asc
)Very little technical information provided about the error.
"+IO error.+" - this likely refers to the client attempting to use a socket handle and the call to the handle failing.
+"The network adapter could not establish the connection.+" - this likely means that the IP address to connect to, could not be reached, or that the connection was not accepted on that port on the remote IP address. (typically hostname resolution errors would give a different error)
The easiest way to test connectivity is using the ping command to bounce an ICMP echo off the remote IP.
If that works, test access to remote port on that remote IP using the telnet command - this will check whether there is a service accepting connections on that port, and whether access to that port is allowed in case of firewalls en-route. -
Query help - Group by range of program set
Need help in developing query with the following set of data.
Program
req_id
parent_id
runtime
A
1
-1
30
A1
2
1
20
A2
3
-1
1
A3
4
3
5
A4
5
-1
7
A5
6
-1
4
A6
7
-1
3
A1
8
1
10
A2
9
-1
1
A3
10
9
2
A4
11
-1
3
A5
12
-1
2
A6
13
-1
2
The results I am looking for is in the following format.
Set
G1
G1_time
G2
G2_time
G3
G3_time
Set1
G1
6
G2
11
G3
3
Set2
G1
3
G2
5
G3
2
Can you please tell if this can be achieved using sql in Oracle 11g?
Thanks very much.Hi,
Depending on your requirements:
WITH got_grp AS
SELECT program
, LAST_VALUE ( CASE
WHEN program = 'A1'
THEN req_id
END
IGNORE NULLS
) OVER ( ORDER BY req_id ) AS grp
, req_id
, runtime
FROM a
, got_c_num AS
SELECT DENSE_RANK () OVER (ORDER BY grp) AS grp_num
, runtime
, CEIL ( ROW_NUMBER () OVER ( PARTITION BY grp
ORDER BY req_id
/ 2
) AS c_num
FROM got_grp
WHERE program NOT IN ('A', 'A1')
SELECT 'SET' || grp_num AS "SET"
, 'G1' AS g1
, g1_time
, 'G2' AS g2
, g2_time
, 'G3' AS g3
, g3_time
FROM got_c_num
PIVOT ( SUM (runtime)
FOR c_num IN ( 1 AS g1_time
, 2 AS g2_time
, 3 AS g3_time
ORDER BY grp_num
Output:
SET G1 G1_TIME G2 G2_TIME G3 G3_TIME
SET1 G1 6 G2 11 G3 3
SET2 G1 3 G2 5 G3 2 -
Apex 4.2 Report region sql query with "apex_item.text" renders wrongly
In APEX 4.2 page i have created region "Report data".
Type="SQl Query".
"User Interface"-->"Template"="Reports Region".
"Region Source"="select apex_item.text(1, '111') as c1 from dual".
Actually the select query is little bit more complex, but generally simplified it is such, that it uses function "select apex_item.text" to construct HTML textfield.
If i run in Sql Developer query
select apex_item.text(1, '111') as c1 from dual;Then result is:
<input type="text" name="f01" size="20" maxlength="2000" value="111" />But in APEX 4.2 the report is rendered so:
<td headers="c1">< ;input type=" ;text" ; name="f01" size="20" maxlength="2000" value="111" /> ;</td>(for this forum to display correctly i had to put extra spaces between" >" and ";" and so on)
And APEX 4.2 shows ugly html inside report cell/slot for me, displaying characters/symbols ">". The reason is that APEX HTML page source does not have symbol ">" but has " > ;" .
In APEX 3 i have similar query working well, without such anomaly.
What attribute should i change in APEX 4.2 region to display my query result as needed?
I need that function "apex_item.text", i cannot remove it.
Edited by: CharlesRoos on 13.02.2013 15:28
Edited by: CharlesRoos on 13.02.2013 15:29
Edited by: CharlesRoos on 13.02.2013 15:29CharlesRoos wrote:
In APEX 4.2 page i have created region "Report data".
Type="SQl Query".
"User Interface"-->"Template"="Reports Region".
"Region Source"="select apex_item.text(1, '111') as c1 from dual".
Actually the select query is little bit more complex, but generally simplified it is such, that it uses function "select apex_item.text" to construct HTML textfield.
If i run in Sql Developer query
select apex_item.text(1, '111') as c1 from dual;Then result is:
<input type="text" name="f01" size="20" maxlength="2000" value="111" />But in APEX 4.2 the report is rendered so:
<td headers="c1">< ;input type=" ;text" ; name="f01" size="20" maxlength="2000" value="111" /> ;</td>(for this forum to display correctly i had to put extra spaces between" >" and ";" and so on)
And APEX 4.2 shows ugly html inside report cell/slot for me, displaying characters/symbols ">". The reason is that APEX HTML page source does not have symbol ">" but has " > ;" .
In APEX 3 i have similar query working well, without such anomaly.
What attribute should i change in APEX 4.2 region to display my query result as needed?Ensure that the Display As Column Attribute for the C1 column is Standard Report Column. -
Query for vendor details in F-53
Hi,
Need help on query development for vendor payment through F-53 with selection criteria Co. code, Fiscal Year, Fiscal Period, Transaction code and document type. Required output would be Co. code, Fiscal year, vendor number, document number and amount.
I tried to develope query using tables BKPF & BSEG but system did not allow BSEG as it's a structure. Then tried with BKPF & BSAK but it's not pulling any data for query.
Also, would like to know is there any standard report available for vendor payment through F-53?Hi Hein,
Thanks for your reply.
The issue in FBL1N is I cannot enter the TCode F-53 and the document type used for F-53 , is used by other transactions also. Hence I am not getting the correct report.
Any help on developing a querry for this.
Thanks
Rajesh -
SQL query or function...
Hi everyone,
Please help me to clarify this question
I have a "patient" table and a "address" table.And each patient has differnt types of addresses
like PMI,Mailing and default address i need to pick patient address in the order of preference
(PMI,Mailing ,Default)
I have two options to get the address of a patient.Either write a SQL query to get the address of a
patient(according to preference)
or write a function which checks
if there is PMI,Mailing and default
take PMI
or
If there is mailing and Default
take mailing
or
take default.
which one is the best method to get the address of a patient? SQL query or function..
Definitely everyone will say that it should be direct SQL query instead of multiple function calls.
But in my organization there are many developers which will get "patient address" in their application
or SQL code or PL/SQL code or from some
'X' Business intelligence tool.
At this scenario is it best to have a function which every one will call and get a standardized output
for every one.
Question:
In my scenario which one is the best to have "SQL query or function"?
if i choose "function" i have to sacrifice the performance
if i choose "SQL query" i am not sure whether each and every developer querying the same way as it would be
Sorry if it is a dumb question to ask.
Thanks in advance
phaniquestion for hoek: what if i have to choose between SQL query and function? (suppose they dont accept to create a view)If views are not accepted (which is very strange imo), but you do need some 'standard object' which everybody can use, then you'd choose to use a function instead of everybody having 'their own query'.
It's a trade-off between maintaining standards and performance (calling PL/SQL from SQL is usually to be avoided due to context-switching, the other way around is OK).
One advantage of a view: no hassle with parameters you have to enter but never will use, you just pick the columns you need and there you go.
Other one: it's straightforward, simple and clear.
It's easier to maintain.
But it all depends on what your function will return.
Perhaps a REF CURSOR?
Your question reminds me of this interesting discussion:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:672724700346558185
Edited by: hoek on Jul 1, 2009 4:39 PM tyop's -
How to document a query/report from HR-Infoset
Hi,
we developed some queries from our own HR-Infoset. As our users are not
allowed to work directly on this infoset or its queries every query has its
generated report. The users call these reports through a transcation code.
Unfortunately we have not found a solution to make some documentation for
each query. As the reports are generated, documentation is not allowed there.
If i press F1(Help) on a report of personnel administration (e.g. S_PH9_46000216 jubilee list)
a browser is opened with an appropriate description of the pa-reports.
Do you know any possibility to document a self developed query/its generated report?
Thanks in advance.
HaraldFound it..Query name is P2. It was in a different query area..Standard area and not custom area where I was initially looking at.
Edited by: Shareen Hegde on Aug 22, 2008 5:14 PM -
Problem inserting and querying XML data with a recursive XML schema
Hello,
I'm facing a problem with querying XML data that is valid against a recursive XML Schema. I have got a table category that stores data as binary XML using Oracle 11g Rel 2 on Windows XP. The XML Schema is the following:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="bold_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="keyword_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
<xs:element name="plain_text" type="xs:string"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="emph_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="text_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="parlist_type">
<xs:sequence>
<xs:element name="listitem" minOccurs="0" maxOccurs="unbounded" type="listitem_type"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="listitem_type">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="parlist" type="parlist_type"/>
<xs:element name="text" type="text_type"/>
</xs:choice>
</xs:complexType>
<xs:element name="category">
<xs:complexType>
<xs:sequence>
<xs:element name="name"/>
<xs:element name="description">
<xs:complexType>
<xs:choice>
<xs:element name="text" type="text_type"/>
<xs:element name="parlist" type="parlist_type"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id"/>
</xs:complexType>
</xs:element>
</xs:schema>I registered this schema and created the category table. Then I inserted a new row using the code below:
insert into category_a values
(XMlElement("category",
xmlattributes('categoryAAA' as "id"),
xmlforest ('ma categ' as "name"),
(xmlelement("description", (xmlelement("text", 'find doors blest now whiles favours carriage tailor spacious senses defect threat ope willow please exeunt truest assembly <keyword> staring travels <bold> balthasar parts attach </bold> enshelter two <emph> inconsiderate ways preventions </emph> preventions clasps better affections comes perish </keyword> lucretia permit street full meddle yond general nature whipp <emph> lowness </emph> grievous pedro')))
The row is successfully inserted as witnessed by the results of row counting. However, I cannot extract data from the table. First, I tried using SqlPlus* which hangs up and quits after a while. I then tried to use SQL Developer, but haven't got any result. Here follow some examples of queries and their results in SQL Developer:
Query 1
select * from category
Result : the whole row is returned
Query 2
select xmlquery('$p/category/description' passing object_value as "p" returning content) from category
Result: "SYS.XMLTYPE"
now I tried to fully respect the nested structure of description element in order to extract the text portion of <bold> using this query
Query 3
select xmlquery('$p/category/description/text/keyword/bold/text()' passing object_value as "p" returning content) from category_a
Result: null
and also tried to extract the text portion of element <text> using this query
Query 4
select xmlquery('$p/category/description/text/text()' passing object_value as "p" returning content) from category_a
Result: "SYS.XMLTYPE".
On the other hand, I noticed, from the result of query 1, that the opening tags of elements keyword and bold are encoded as the less than operator "<". This explains why query 3 returns NULL. However, query 4 should display the text content of <text>, which is not the case.
My questions are about
1. How to properly insert the XML data while preserving the tags (especially the opening tag).
2. How to display the data (the text portion of the main Element or of the nested elements).
The problem about question 1 is that it is quite unfeasible to write a unique insert statement because the structure of <description> is recursive. In other words, if the structure of <description> was not recursive, it would be possible to embed the elements using the xmlelement function during the insertion.
In fact, I need to insert the content of <description> from a source table (called category_a) into a target table (+category_b+) automatically .
I filled category_a using the Saxloader utility from an flat XML file that I have generated from a benchmark. The content of <description> is different from one row to another but it is always valid with regards to the XML Schema. The data is properly inserted as witnessed by the "select * from category_a" instruction (500 row inserted). Besides, the opening tags of the nested elements under <description> are preserved (no "<"). Then I wrote a PL/SQL procedure in which a cursor extracts the category id and category name into varchar2 variables and description into an XMLtype variable from category_a. When I try to insert the values into a category_b, I get the follwing error:
LSX-00213: only 0 occurrences of particle "text", minimum is 1which tells that the <text> element is absent (actually it is present in the source table).
So, my third question is why are not the tags recognized during the insertion?
Can anyone help please?Hello,
indded, I was using an old version of Sqlplus* (8.0.60.0.0) because I had a previous installation (oracle 10g XE). Instead, I used the Sqlplus* shipped with the 11g2database (version 11.2.0.1.0). All the queries that I wrote work fine and display the data correctly.
I also used the XMLSERIALIZE function and can now display the description content in SQL Developer.
Thank you very much.
To answer your question Marco, I registered the XML Schema using the following code
declare
doc varchar2(4000) := '<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="bold_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="keyword_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
<xs:element name="plain_text" type="xs:string"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="emph_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="text_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="parlist_type">
<xs:sequence>
<xs:element name="listitem" minOccurs="0" maxOccurs="unbounded" type="listitem_type"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="listitem_type">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="parlist" type="parlist_type"/>
<xs:element name="text" type="text_type"/>
</xs:choice>
</xs:complexType>
<xs:element name="category">
<xs:complexType>
<xs:sequence>
<xs:element name="name"/>
<xs:element name="description">
<xs:complexType>
<xs:choice>
<xs:element name="text" type="text_type"/>
<xs:element name="parlist" type="parlist_type"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id"/>
</xs:complexType>
</xs:element>
</xs:schema>';
begin
dbms_xmlschema.registerSchema('/xmldb/category_auction.xsd', doc, LOCAL => FALSE,
GENTYPES => FALSE, GENBEAN => FALSE, GENTABLES => FALSE,
FORCE => FALSE,
OPTIONS => DBMS_XMLSCHEMA.REGISTER_BINARYXML,
OWNER => USER);
end;then, I created the Category table as follows:
CREATE TABLE category_a of XMLType XMLTYPE store AS BINARY XML
XMLSCHEMA "xmldb/category_auction.xsd" ELEMENT "category";Now, there still remains a problem of how to insert the "description" content which I serialized as a CLOB data into another table as XML. To this purpose, I wrote a view over the Category_a table as follows:
CREATE OR REPLACE FORCE VIEW "AUCTION_XWH"."CATEGORY_V" ("CATEGORY_ID", "CNAME", "DESCRIPTION") AS
select category_v."CATEGORY_ID",category_v."CNAME",
XMLSerialize(content ( xmlquery('$p/category/description/*' passing object_value as "p" returning content)) as clob) as "DESCRIPTION"
from auction.category_a p,
xmltable ('$a/category' passing p.Object_Value as "a"
columns category_id varchar2(15) path '@id',
cname varchar2(20) path 'name') category_v;Then, I wrote a procedure to insert data into the Category_xwh table (the source and target tables are slightly different: the common elements are just copied wereas new elements are created in the target table). The code of the procedure is the following:
create or replace PROCEDURE I_CATEGORY AS
v_cname VARCHAR2(30);
v_description clob ;
v_category_id VARCHAR2(15);
cursor mycursor is select category_id, cname, description from category_v;
BEGIN
open mycursor;
loop
/*retrieving the columns*/
fetch mycursor into v_category_id, v_cname, v_description ;
exit when mycursor%notfound;
insert into category_xwh values
(XMlElement("category",
xmlattributes(v_category_id as "category_id"),
xmlelement("Hierarchies", xmlelement("ObjHierarchy", xmlelement ("H_Cat"),
xmlelement ("Rollsup",
(xmlelement("all_categories",
xmlattributes('allcategories' as "all_category_id")))
xmlforest (
v_cname as "cat_name",
v_description as "description")
end loop;
commit;
close mycursor;
END I_CATEGORY;When I execute the procedure, I get the following error:
LSX-00201: contents of "description" should be elements onlyso, I just wonder if this is because v_description is considered as plain text and not as XML text, even if its content is XML. Do I need to use a special function to cast the CLOB as XML?
Thanks for your help.
Doulkifli
Maybe you are looking for
-
I am trying to back up my new Iphone on to ICloud. It shows I dont have enough storage because it still has stuff from the old IPhone. How can I back up this phone and erase from the other. Apple kept the other phone when they replaced it. If I h
-
Iphone 4s problems after 5.1.1 upgrade
Hi all, I know this has been posted many previous times however having read through most of those I am confused as to what to do next... I recently updated my Iphone 4s with the 5.1.1 OS. For the next few days following this the phone displayed 'inva
-
Based on the lack of users in this forum and the lack of reporting information on the WEB, it looks like most have given up on the report builder. Personally would love it to work, but most of the day I've been trying to get a simply report up and ru
-
Getting the colour of a pixel in an Image?
Can I get the colour of a pixel in J2ME, like BufferedImage.getRGB(int x, int y) in J2SE? Thanks.
-
No suitable replenishment strategy
Hi, While creating control cycle for kanban i am getting this error, No suitable replenishment strategy. strategy has been assign to plant .