Xmlgen.getxml(query) -issue from PL/SQL
Hi!
Have anyone tried this? I just get errors when I use my SQL-statemensts in Oracle 9i R.1.
I'm trying to update my small PL/SQL based web ap. to start using XML, the function returns ORA-00094 errors
when I use a where-clause. When I don't, the function returns a valid XML page. But I wanna sort, and restict the output
before XML is beeing produced, hence a WHERE-clause.
My function looks like this:
create or replace function SOKER
(s_sok IN VARCHAR2 default null) RETURN CLOB is
converted VARCHAR2(500) default NULL;
query VARCHAR2(200);
begin
select replace(s_sok,'*', '%')into converted from dual;
-- I have to denote my WHERE-clause or this statement will fail!
query := 'select * from oaadm.oa_folder';
-- where contains(REFERANSENR, converted, 1)>0 or contains(SOKNAD,converted, 2)>0 or contains(GJENNOMFORT,converted, 3)>0 ';
RETURN xmlgen.getxml(query);
end soker;
This function works fine in a cursor with HTP.P for each row. But that is not what I want. I wanna dynamically produce XML from a query.
The old dbxml would let med do this (I think.). My table OA_FOLDER does not contain any NULL values.
Any ideas people?
Regards,
Andreas Kjeldsen (NORWAY).
Hi!
Have anyone tried this? I just get errors when I use my SQL-statemensts in Oracle 9i R.1.
I'm trying to update my small PL/SQL based web ap. to start using XML, the function returns ORA-00094 errors
when I use a where-clause. When I don't, the function returns a valid XML page. But I wanna sort, and restict the output
before XML is beeing produced, hence a WHERE-clause.
My function looks like this:
create or replace function SOKER
(s_sok IN VARCHAR2 default null) RETURN CLOB is
converted VARCHAR2(500) default NULL;
query VARCHAR2(200);
begin
select replace(s_sok,'*', '%')into converted from dual;
-- I have to denote my WHERE-clause or this statement will fail!
query := 'select * from oaadm.oa_folder';
-- where contains(REFERANSENR, converted, 1)>0 or contains(SOKNAD,converted, 2)>0 or contains(GJENNOMFORT,converted, 3)>0 ';
RETURN xmlgen.getxml(query);
end soker;
This function works fine in a cursor with HTP.P for each row. But that is not what I want. I wanna dynamically produce XML from a query.
The old dbxml would let med do this (I think.). My table OA_FOLDER does not contain any NULL values.
Any ideas people?
Regards,
Andreas Kjeldsen (NORWAY).
Similar Messages
-
Use evdre to query data from a SQL View
Hi all
I believe that it is possible to use evdre to query data from a SQL View. If this is possible then how does one go about setting it up in the evdre options (assuming that the view has already been created)?
Regards,
ByronByron, perhaps this is no longer supported, it might be worth opening up a case at service.sap.com on this. However, I did find the following on Page 11 of the "Usages and Considerations of EVDRE" pdf file. This doc is imbedded in the helpfile for BPC 7 SP5 (which was released in August of 2009, well after note 1315011 was last updated.
It looks like you are limited to one custom view per application, since you have to name the view in a parameter at the APPLICATION level. Go into BPC Administration, login to the application related to the custom view, choose "Set Application Parameters" and enter the name of the view to the Application Parameter called "EVDRE_QUERYVIEWNAME" If it is not listed, go ahead and create it at the bottom of the Application parameter screen.
Also: I interpreted the following info from Page 10 of the same doc:
In your EVDRE, set the following options:
QueryEngine: MANUAL
QueryType: enter either NEXJ OR TUPLE see below:
NEXJ - Use two-dimensional queries using the nonemptycrossjoin function
TUPLE - Use two-dimensional queries using tuples"
And I'm assuming you'd enter a Y for the following two parameters:
QueryViewName
"..to enforce the query engine to use a used-defined SQL view of the fact tables, when trying to read the values using SQL queries. This option is typically used in conjunction with the SQLOnly option (see below). "
Option SQLOnly
"..to enforce the query engine to only execute SQL queries, when reading data. This can be achieved using this option." -
Query data from MS SQL db through Oracle ? By using JAVA ?
Hi folks,
I would like to sync our one table in oracle db with table in different system, stored in MS SQL database.
What would be the easiest option for connection from Oracle to MS SQL db to be able to query data from MS SQL through some Oracle package?
If possible, I would like to keep all "tricky steps" within Oracle database. I heard about option with Java, but so far we have no experience with java in Oracle.
Our database: Oracle 11g Database Standard Edition One
Many thanks,
TomasC:\Users\tomeo>dg4pwd HELIOS
ORACLE Gateway Password Utility
Constructing password file for Gateway SID HELIOS
For user account SYSTEM
OPW-00001: Unable to open password-file (RC=0)
C:\Users\tomeo> -
Query ODSEE from windows SQL server
Hello,
I have a windows server running SQL EXPRESS 2012 and I need to retrieve some data from an external server that uses LDAP.
Normally I'm able to query this server using LDP.exe and it shows the version as:
vendorname: Oracle Corporation;
vendorversion: Sun-Directory-Server/11.1.1.5.0;
I have found some examples on how to connect the SQL instance to a Microsoft Active Directory Server and make queries in a SQL-like way, and I was wondering if there is any connector that will allow me to do the same with an ODSEE LDAP server.
Thanks in advance.Hello,
Yes, as I said, I have no problems in launching queries from ldp.exe, but I want to automatize it using a SQL query from SQL server.
SQL Express 2012 has a built-in controller for Active Directory that can be configured somehow to run queries to a LDAP server. Has anyone configured something like this?
Thanks -
PL/SQL & xmlgen.getXML problem
Hi All.
I am just starting to investigate options with regards to procedures which return the results of queries, in XML format.
I have written the following function:
CREATE OR REPLACE FUNCTION returnXML(id NUMBER) RETURN CLOB IS
query VARCHAR2(100);
BEGIN
query := 'SELECT *
FROM test_table
WHERE id = '||id;
RETURN xmlgen.getXML(query);
END;
I am then calling this as such:
SQL> SELECT returnXML(1) FROM dual;
My problem is that when I call this function, it seems to only produce some of the output ! ie. I get the XML header, first ROWSET and ROW tags, but then a number of chars further inot my output it stops ! I have also tried calling thsi function from within another PL/SQL block, and the same thing happens. No error is generated at all.
Does anyone have any ideas, or has anyone seen this problem before ?
Thanks,
Kristian.It just might be that SQL Plus is not printing out all the contents of the CLOB.
You can do:
SQL> set LONG 1000
and run your query again. Or you can create a function similar to this one (from Oracle XDK Documentation):
CREATE OR REPLACE PROCEDURE printClobOut(result IN OUT NOCOPY CLOB) is
xmlstr varchar2(32767);
line varchar2(2000);
begin
xmlstr := dbms_lob.SUBSTR(result,32767);
loop
exit when xmlstr is null;
line := substr(xmlstr,1,instr(xmlstr,chr(10))-1);
dbms_output.put_line('| '||line);
xmlstr := substr(xmlstr,instr(xmlstr,chr(10))+1);
end loop;
end;
To use:
set serveroutput on
declare
result CLOB;
begin
-- get the result
result := returnXML(<some ID>);
-- print the result
printClobOut(result);
end; -
Best Practice on querying Data from Database
Hello and I was wondering what is the preferred and best practice for querying data from an SQL database inside a JSP page. Is it using the JSTL library or another method? Thanks
It depends on the size of the application really.
The "correct and preferred" approach in a large MVC app would be to have a seperate class that does all the database access, retrieving the data into java objects.
Check out [url http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html] DAO pattern
You then "save" the data into request/session attributes, and forward to a jsp page to render the result.
Most approaches recommend a separation between JSP (the view) and SQL code.
The JSTL sql tags are provided more for "quick and dirty" code applicable in small applications, or for fast prototyping. That approach is not really robust for large scale applications.
Cheers,
evnafets -
Xmlgen.getxml Nested Cursors with LONG RAW and BLOB Data Types
I am trying to use a nested cursor with xmlgen.getxml that has a long raw or blob column. In either case, it will not return to me any data in the xml document pertaining to that LONG RAW or BLOB column. If I do not use a nested cursor, it works fine.
Example:
SELECT xmlgen.getxml('SELECT x, CURSOR(SELECT y FROM y_tab WHERE y_tab.x_id = x_tab.x_id) y FROM x_tab') FROM dual;
This will not produce the information I am after.
However, simply running:
SELECT xmlgen.getxml('SELECT y FROM y_tab WHERE y_tab.x_id = <somevalue>') FROM dual;
Works???
Any ideas out there? Does anyone know if DBMS_XMLQUERY has this limitation?
Thanks,
BradIt doesn't appear that I am able to attach the PDF files. Can you supply your email (or I can supply mine) so I can send you the three files:
1.) A good PDF (manually extracted from our old application)
2.) Dump of the same PDF file (includes header/footer info)
3.) A partially fixed PDF file (but some of the pictures / pages are cut off - specifically pages 3,5,9,10,12,14)
The way that we have tried to fix the file (in example 3 above) is the following:
a.) Find the First Occurrence of "%PDF-"
b.) Find the Last Occurrence of "%%EOF"
c.) if the first "%PDF-" is found AND the last "%%EOF" is found, then
i.) Remove all data before the first %PDF-
ii.) Remove all data after the last %%EOF
Let me know if you need any other information.
Thanks,
Mike -
Why are results from xmlgen.getxml truncated?
I have a table with 25 rows in it that displays all contents with a SELECT * statement. However, if I wrap this statement in an xmlgen.getxml the result is truncated. I'm sure this is a novice issue, and this novice would appreciate any insight.
Thanks in advance,
Rich
query:
SELECT xmlgen.getxml('SELECT * FROM dbotemp.portfolio') xml from dual
result:
XML
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<PORTFOLIO_ID>187</PORTF
1 row selected.you get a clob and clobs are normely truncated
when you use the statement ins SQL*PLus try: "set long 10000"
and you will see the whole result -
I am attempting to connect to a Progress database using JDBC and am having a few issues with my SQL statement. The code concerned looks like this:
// Get a statement from the connection
Statement stmt = conn.createStatement() ;
// Execute the query
ResultSet rs = stmt.executeQuery( "SELECT * FROM pub.cust" ) ;
// Loop through the result set
while( rs.next() )
System.out.println( rs.getString( "cust-code" ) ) ;
That works just fine. Prints out each of the cust-code values. My issue comes when I try to refine the query to be:
ResultSet rs = stmt.executeQuery( "SELECT * FROM pub.cust WHERE cust.Cust-code='100001-0'" ) ;
or even
ResultSet rs = stmt.executeQuery( "SELECT Cust-code FROM pub.cust" ) ;
Both of these give me an error saying Column not found/specified.
if I wrap Cust-code in single quotes, the script prints Cust-code on each line, not the value for it. If I escape Cust-code like Cust\-code, I get an Illegal escape character. Any ideas?I have never used Progress, but maybe you have to fully qualify the field names like this:
ResultSet rs = stmt.executeQuery( "SELECT * FROM pub.cust WHERE pub.cust.Cust-code='100001-0'" ) ;
ResultSet rs = stmt.executeQuery( "SELECT pub.cust.Cust-code FROM pub.cust" ) ;Just a thought. -
Performance issues while query data from a table having large records
Hi all,
I have a performance issues on the queries on mtl_transaction_accounts table which has around 48,000,000 rows. One of the query is as below
SQL ID: 98pqcjwuhf0y6 Plan Hash: 3227911261
SELECT SUM (B.BASE_TRANSACTION_VALUE)
FROM
MTL_TRANSACTION_ACCOUNTS B , MTL_PARAMETERS A
WHERE A.ORGANIZATION_ID = B.ORGANIZATION_ID
AND A.ORGANIZATION_ID = :b1
AND B.REFERENCE_ACCOUNT = A.MATERIAL_ACCOUNT
AND B.TRANSACTION_DATE <= LAST_DAY (TO_DATE (:b2 , 'MON-YY' ) )
AND B.ACCOUNTING_LINE_TYPE != 15
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 3 0.02 0.05 0 0 0 0
Fetch 3 134.74 722.82 847951 1003824 0 2
total 7 134.76 722.87 847951 1003824 0 2
Misses in library cache during parse: 1
Misses in library cache during execute: 2
Optimizer mode: ALL_ROWS
Parsing user id: 193 (APPS)
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
1 1 1 SORT AGGREGATE (cr=469496 pr=397503 pw=0 time=237575841 us)
788242 788242 788242 NESTED LOOPS (cr=469496 pr=397503 pw=0 time=337519154 us cost=644 size=5920 card=160)
1 1 1 TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=59 us cost=1 size=10 card=1)
1 1 1 INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=40 us cost=0 size=0 card=1)(object id 181399)
788242 788242 788242 TABLE ACCESS BY INDEX ROWID MTL_TRANSACTION_ACCOUNTS (cr=469494 pr=397503 pw=0 time=336447304 us cost=643 size=4320 card=160)
8704356 8704356 8704356 INDEX RANGE SCAN MTL_TRANSACTION_ACCOUNTS_N3 (cr=28826 pr=28826 pw=0 time=27109752 us cost=28 size=0 card=7316)(object id 181802)
Rows Execution Plan
0 SELECT STATEMENT MODE: ALL_ROWS
1 SORT (AGGREGATE)
788242 NESTED LOOPS
1 TABLE ACCESS MODE: ANALYZED (BY INDEX ROWID) OF
'MTL_PARAMETERS' (TABLE)
1 INDEX MODE: ANALYZED (UNIQUE SCAN) OF
'MTL_PARAMETERS_U1' (INDEX (UNIQUE))
788242 TABLE ACCESS MODE: ANALYZED (BY INDEX ROWID) OF
'MTL_TRANSACTION_ACCOUNTS' (TABLE)
8704356 INDEX MODE: ANALYZED (RANGE SCAN) OF
'MTL_TRANSACTION_ACCOUNTS_N3' (INDEX)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
row cache lock 29 0.00 0.02
SQL*Net message to client 2 0.00 0.00
db file sequential read 847951 0.40 581.90
latch: object queue header operation 3 0.00 0.00
latch: gc element 14 0.00 0.00
gc cr grant 2-way 3 0.00 0.00
latch: gcs resource hash 1 0.00 0.00
SQL*Net message from client 2 0.00 0.00
gc current block 3-way 1 0.00 0.00
********************************************************************************On a 5 node rac environment the program completes in 15 hours whereas on a single node environemnt the program completes in 2 hours.
Is there any way I can improve the performance of this query?
Regards
Edited by: mhosur on Dec 10, 2012 2:41 AM
Edited by: mhosur on Dec 10, 2012 2:59 AM
Edited by: mhosur on Dec 11, 2012 10:32 PMCREATE INDEX mtl_transaction_accounts_n0
ON mtl_transaction_accounts (
transaction_date
, organization_id
, reference_account
, accounting_line_type
/:p -
Xmlgen.getxml("select * from table") returns null pointer exception
I am running oracle 8i on solaris server and clinet on windows
NT and i am this select statement
select xmlgen.getxml("select * from table") from dual ,its
returning null pointer exception,i have tried it through
jdbc,even then its returning xml as
<?xml version = '1.0'?>
<ERROR>java.lang.NullPointerException</ERROR>
can any body tell me the error.Help will be really appreciated.I
need an urgent response,if some one can guide me please.
My email is [email protected],if you can give me a quick
response on this email,your effot will be appreciated.
thanks
MasoodWhat is actually throwing the NullPointerException? rs.getMetaData() or table.setModel()?
-
Parse SQL: How to extract column names, table names from a SQL query
Hi all,
I have a requirement wherein a SQL query will be given in a text file.
The text file has to be read (probably using text_io package), the SQL query needs to be parsed and the column names, table names and where clauses have to be extracted and inserted into separate tables.
Is there a way to do it using PL/SQL ?
Is there a PL/SQL script available to parse and extract column names, table names etc ?
Pls help.
Regards,
SamI think I jumped to conclusion too early saying it is completely possible and straight forward. But after reading through your post for one more time I realised you are not interested only in the column_names, also the table_names and the predicates .
>
SQL query needs to be parsed and the column names
>
The above is possible and straight forward using the dbms_sql package.
I am pasting the same information as I did in the other forum.
Check this link and search for Example 8 and .
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm#sthref6136
Also check the working example from asktom
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1035431863958
>
table names and where clauses have to be extracted
>
Now this is the tricky bit. You can extract the list of tables by getting the sql_id from v$sql and joining it with v$sql_plan. But sometimes you may not get all the results because the optimizer may choose to refine your query (check this link)
http://optimizermagic.blogspot.com/2008/06/why-are-some-of-tables-in-my-query.html
and you can get the predicate information from the same table v$sql_plan but I will leave that area for you to do some R&D.
Regards
Raj
Edited by: R.Subramanian on Dec 10, 2008 3:14 AM -
Get Number of rows from a sql query.
I am reading data from a sql query in a BLS transaction and I would like to know the number of rows returned.
Is there an easy way to do this without looping through the table?
Thanks JasperHi Jasper,
You can use the XPATH count function similar to this:
GetTagList.Results{count(/Rowsets/Rowset/Row)}
Kind Regards,
Diana Hoppe -
Best way to spool DYNAMIC SQL query to file from PL/SQL
Best way to spool DYNAMIC SQL query to file from PL/SQL [Package], not SqlPlus
I'm looking for suggestions on how to create an output file (fixed width and comma delimited) from a SELECT that is dynamically built. Basically, I've got some tables that are used to define the SELECT and to describe the output format. For instance, one table has the SELECT while another is used to defined the column "formats" (e.g., Column Order, Justification, FormatMask, Default value, min length, ...). The user has an app that they can use to customize the output...which leaving the gathering of the data untouched. I'm trying to keep this formatting and/or default logic out of the actual query. This lead me into a problem.
Example query :
SELECT CONTRACT_ID,PV_ID,START_DATE
FROM CONTRACT
WHERE CONTRACT_ID = <<value>>Customization Table:
CONTRACT_ID : 2,Numeric,Right
PV_ID : 1,Numeric,Mask(0000)
START_DATE : 3,Date,Mask(mm/dd/yyyy)The first value is the kicker (ColumnOrder) as well as the fact that the number of columns is dynamic. Technically, if I could use SqlPlus...then I could just use SPOOL. However, I'm not.
So basically, I'm trying to build a generic routine that can take a SQL string execute the SELECT and map the output using data from another table to a file.
Any suggestions?
Thanks,
JasonYou could build the select statement within PL/SQL and open it using a cursor variable. You could write it to a file using the package 'UTL_FILE'. If you want to display the output using SQL*Plus, you could have an out parameter as a ref cursor.
-
Retreiving a value from and SQL query
If anyone can give me sample code or pointers to retreive a value from an sql query, I'd be greatful.
Source code I've muddled together so far:
Class seqNumType = Class.forName(nameOfClass);
Constructor theConstructor = seqNumType.getConstructor(null);
Object seqNumInstance = theConstructor.newInstance(null);
String theStatement = "SELECT value INTO v_seqnum FROM DUAL;";
OracleCallableStatement ocs = (OracleCallableStatement)conn.prepareCall(theStatement);
ocs.registerOutParameter( 1, OracleTypes.NUMBER, 0);
Method method = seqNumInstance.getClass().getMethod("getORADataFactory", null);
seqNumInstance = ocs.getORAData(1, (ORADataFactory)method.invoke(null,null));
ocs.execute();
Problem with this seems to be the ORADataFactory isn't a method of the class, but as I'm thumbling around in the dark here a little, I've no idea where to go from here. Is this just generally overkill anyway?
Suggestions?
Cheers for any help.Like this:
ResultSet resultSet=statement.executeQuery("SELECT * FROM TEST");
while(resultSet.next())
for(int i=0;i<resultSet.getMetaData().getColumnCount();i++)
System.out.print(resultSet.getObject(i+1).toString()+" ");
System.out.println();
Maybe you are looking for
-
I was asking if it would be possible exporting a Pages file in a pdf file with sections, making these usable in Preview or another pdf reader. The exporting process works fine with the hyperlinks, but not with the favorites. Maybe I asking too much t
-
Hi i am having SELECT-OPTIONS: s_erdat FOR vbak-erdat. i am getting s_erdat - low value from one table which is from program logic . high value = sy-datun -1. when you run this program it is coming good. now, the problem is, i want to crate a varia
-
File handles don't close when the pdf is closed?
Using Acrobat X on Windows 7 Pro in a networked environment. Once I open a PDF file in Acrobat, as long as I have acrobat running, (even after I have closed the file and moved on) I cannot change/move/rename the file. Since I spend a lot of time revi
-
AIP-51505 5081: XEngine error - Invalid guideline for EDI 5010
Hi, We're unable to process a 5010 version 210 document, if we turn off validation we get failed guideline error if we turn on the vaidation its complaining about Repetition Separator. Element ISA11 is a coded list element. Code ':' is not allowed. S
-
Mac Mini (2012) as Wireless Gateway
I want to turn my mac mini into a wireless gateway. I have "pf" I need to know how to turn on wireless ap mode on? What command line tools are available? OpenBSD has "hostapd" for this. I plan to have my mini serve as my gateway router as well as me