Xsql:dml question
This is what I am trying:
<?xml version="1.0"?>
<page connection="egemdev" xmlns:xsql="urn:oracle-xsql">
<xsql:dml>
begin
ord_cancel_pkg.cancel_order('{@order}');
exception
when others then raise;
end;
</xsql:dml>
<xsql:query >
select order_status .....
from orders
where order_number = '{@order}'
</xsql:query>
</page>
However, I don't want the query part to work if the dml part raises an exception. How do I do that?
Best approach is either to use:
<xsql:ref-cursor-function>
and invoke a pl/sql stored function
that calls your pkg.cancel(), then
returns a REF CURSOR to the query if successful and a null REF CURSOR (or a REF CURSOR to a query like "SELECT 1 FROM DUAL WHERE 1 = 2" in case calling the proc throws an exception.
Similar Messages
-
Xsql:dml update... does not get executed?
I was testing a simple one field update in <xsql:dml> block and getting the following statement:
<xsql-status action="xsql:dml" rows="0"/>
What might be the problem?The issue is that JDBC returns a row count only for simple DML statements.
Whenever you use a BEGIN...END block, JDBC doesn't know how many rows your statement has affected.
If you try the latest XSQL 9.0.2B release, and use:
<xsql:dml>
update emp set ename='FORD2' where empno=7844
</xsql:dml>
You'll see that it shows one row was affected. -
Delete in xsql:dml vs xsql:delete-request and returned rows attribute
There is a difference in the number of rows returned between using a delete in xsql:dml vs xsql:delete-request. If I issue a delete via xsql:dml and the row I wish to delete is not in the table, then I get a result with rows equal to 0 as expected. However if I issue a delete via xsql:delete-request and the row I wish to delete is again not in the table, then I get a result with rows equal to 1.
It appears that the value of rows in the response to xsql:delete-request is the number of rows to be processed, ie the number of rows in the posted document, whereas the value of rows in the response to xsql:dml is the number of rows processed in the database.
I'd expect that the result that we want is the number of rows processed in the database. Thus xsql:delete-request should use the rows attribute in the response to reflect the number of rows processed in the database and thus be consistent with xsql:dml, and possibly use another attribute to reflect the number of rows to be processed.
The same problem occurs with an update in xsql:dml vs xsql:update-request.
http://aetius/xsql/demo/dmldelete.xsql?cxn=demo&bind=ename&ename=COMPAQ&sql=delete+from+EMP+where+ENAME+%3d+?
result is
<xsql-status action="xsql:dml" rows="0"/>
where dmldelete.xsql is
<xsql:dml
null-indicator="yes"
connection="{@cxn}"
bind-params="{@bind}"
xmlns:xsql="urn:oracle-xsql">
{@sql}
</xsql:dml>
http://aetius/xsql/demo/reqdelete.xsql?cxn=demo&table=EMP&key=ENAME
where posted document is
<ROWSET><ROW><ENAME>COMPAQ</ENAME></ROW></ROWSET>
result
<xsql-status action="xsql:delete-request" rows="1"/>
where reqdelete.xsql is
<xsql:delete-request
connection="{@cxn}"
key-columns="{@key}"
table="{@table}"
xmlns:xsql="urn:oracle-xsql">
</xsql:delete-request>
Steve.If you post as an HTML parameter, then you can directly reference the parameter value as either a lexical parameter:
<xsql:dml>
insert into foo(xml_column) values ('{@paramname}')
</xsql:dml>
or as a bind parameter:
<xsql:dml bind-params="paramname">
insert into foo(xml_column) values (?)
</xsql:dml>
I'd recommend the latter since it's more robust to the presence of quotes in the XML that's being posted.
If you post the XML HTTP body, then you'd have to write a custom action handler that called the getPageRequest().getPostedDocument() to get hold of the posted XML Document. -
How do I get parameter values for xsql:dml
Hi -
If I have an xml file like:
<stuff>
<arecord>
<item1> some data </item1>
<item2> more data </item2>
</arecord>
... more arecords ...
</stuff>
and I want to run an xsql script against it sending every "arecord" to a stored procedure by:
<xsql:dml>
begin
my_package.do_something(a_parm, a_parm2)
end;
</xsql>
how do I get the values in the <item1> and <item2> tags for every record into a_parm and a_parm2 in the call to do_something?
Thanks in advance,
-- STYou need to post your XML file to an XSQL page that uses the:
<xsql:insert-request>
action element. You'll need to provide an associated XSLT stylesheet to transform your XML input document into the canonical XML format for the target table.
Then, you'll get each <arecord> (transformed into <ROW>) inserted into the columns of the target table.
For example, if your file looks like:
<stuff>
<arecord>
<item1> some data </item1>
<item2> more data </item2>
</arecord>
... more arecords ...
</stuff>and your table looks like:
ITEM1 VARCHAR2
ITEM2 VARCHAR2Then you'll need to provide a stylesheet that transforms your XML input into the format:
<ROWSET>
<ROW>
<item1>some data</item1>
<item2>more data</item2>
</ROW>
</ROWSET>and then the data will be inserted.
If the target table is actually a view, then you can create an INSTEAD OF INSERT trigger on your view to do additional custom processing for each row.
My "Building Oracle XML Applications" book has examples of doing all of this.
Steve Muench
Development Lead, Oracle XSQL Pages Framework
Lead Product Manager for BC4J and Lead XML Evangelist, Oracle Corp
Author, Building Oracle XML Applications
null -
Hello,
I have a question on OLAP DML. Please consider the following example (this is from the sample PERMIT_READ from the supplied global schema). It is an sql import statement which is supposed to be faster than a fetch loop.
sql import c1 into -
:_item -
:_family -
:_class -
:_totprod then <product_isvisible (product _item) = true -
product_isvisible (product _family) = true -
product_isvisible (product _class) = true -
product_isvisible (product _totprod) = true -
>
The assumption here is that the cursot c1 has been defined earlier that selects some relational table in four variables.
The statement then assigns isvisible attribute with true for the different members of product dimension.
Now here - if the any of the variables (_item, family, class or _totprod) have fetched a value that does not find a match in the dimension I get the following error -
ERROR: (MXXEQ35) %a %k %j
%1p is not a valid %2p.
ERROR: (ORA-34370) Permission to attach analytic workspace GLOBAL.GLOBAL denied by a PERMIT program.
How can I ignore such errors? and continue with the import execution? If possible, i do not want to use fetch loop.
THanks.
pxsheth.Here's the full text of the PERMIT_READ program. I added the MATCHSKIPERR but I still get the same errors. I am actually dealing with different dimension here. But that should not matter for the sake of this discussion.
"* This program scopes the available business_unit dimension members.
"* This program is called automatically whenever this AW has been attached read-only,
"* regardless of the mechanism (thru SQL,Discoverer, Spreadsheet Addin, third parties, etc.)
"* Fine grained access control has been applied to the gc_sec_bu_opr view.
"* This program reads this table
"* to determine the business_units and nodes that should be visible to the user
vrb _bu text
trap on error
oknullstatus = yes
permiterror = no "Do not throw error when attempting to access scoped data
limit bu to all
bu_isvisible = NA
SQL DECLARE c1 CURSOR FOR -
select business_unit -
from gcdemo.gc_sec_bu_opr
sql open c1
if sqlcode ne 0
then show sqlerrm
sql begin
sql import c1 into -
:MATCHSKIPERR bu then <buisvisible (bu _bu) = true>
sql exception
sql when others then
sql null
sql end
if sqlcode eq -1
then show sqlerrm
SQL close c1
SQL CLEANUP
cns bu
permit read when nafill(bu_isvisible, no)
alldone:
return true
error:
return false
"**************************************************************************************** -
R KIMBALL & OLAP DML QUESTIONS
Hi. I'm a OLAP DML student and like a lot of you (i guess it) i have read Ralph kimbal Books, specifically "The Data Warehouse Lifecycle Toolkit" to undertand multidimesional modeling.
So.... here i a´m questioning to me how do i put all my multidimensional modeling into Analytic Workspaces Objects. My questios are:
1) Does exist some documents that teach how to pass from teory to practice, i mean from multidimensional modeling to AW objetcs? (i can pay for it !!!). (I have read all Oracle Examples - SH and Global) and them always show the same - everyiting is ready to work and work-.
2) Puntually, how do i represent non-hierarchial attributes and how do i use them. I feel that non-hierarchial attributes are not useful to make analysis.... please correct me.
3) How do i define a default herarchy using OLAP DML and if my dimension have more than one hierarchy how do i work wiht them.Hello Lisandro,
1) The easiest way to create AW objects is to use the AWM application, that comes with online documentation. You can start creating the basic objects (dimensions, cubes, measures, and simple calculations) using the AWM GUI, and continue with the OLAP Worksheet for the other objects, eg. models, aggregation/allocation maps, relations etc. At least the first part of this is also within the scope of a present or upcoming OLAP 10g course from Oracle University.
2) I'm not sure what you mean by your question. Attributes are global to a dimension (which is obvious if you use a value based dimension), otherwise AWM etc. lets you define attribute projections (limit attributes) to hierarchies and levels.
3) You can specifically assign a default hierarchy using AWM, or the OLAP AW Java API, Hierachy setIsDefault() method. Also, there is a Normal Form relation DEFAULT_HIER between a dimension and its default hierarchy, but I don't know if you can just add to this relation to make it work.
Regards, Hans Henrik
Message was edited by:
hheriksen 17-Oct-2005 09:53 CET -
Is it possible to log in to a database without using the connectiondefs in the XSQLconfig.xml.
If not, could username and password be passed as parameters to this XSQLconfig.xml?
nullThanks , that works great.
However if the procedure/function that I am calling has some pl/sql update and insert statements and i do
<xsql:query>
select update_status('XYZ') from dual
</xsql:query>
I do get an error that says "ORA-06051 FUNCTION update_status not allowed to update the database".
In this scenario how do I output the XML for the return status code?
Thanks in advance , and I hope my questions are not off base.
null -
DML question about LAG function
Hello,
I am trying to get a month-to-date number on a value that is stored as YTD in the cube. That is, for today's month-to-date number, I want to subtract today's value, from last month's value. I am trying to do this with the following statement:
data - lag(chgdims(data limit lmt(time to parents using time_parentrel)),1,time)
I'm pretty new to DML, but I know that this is clearly not the correct formula. Does anyone have any ideas on how to do this?
ThanksDear Fred-san
Thank you very much for your support on this.
But, may I double check about what you mentioned above?
So, what you were mentioning was that if some user executes the query with
the function module (RFC_READ_TABLE), under the following conditions, he can access to
the HR data even when he does not have the authorizations for HR transactions?
<Conditions>
1. the user has the authorization for HR database tables themselves
2. RFC_READ_TABLE is called to retrieve the data from HR database
<example>
Data: LF_HR_TABLE like DD02L-TABNAME value 'PA0000'.
CALL FUNCTION 'RFC_READ_TABLE'
EXPORTING
query_table = LF_HR_TABLE
TABLES
OPTIONS =
fields =
data = .
But then, as long as we call this function module for a non-critical tables such as
VBAP (sales order) or EKKO (purchase order) within our query, it wouldn't seem to be
so security risk to use RFC_READ_TABLE...
Besides, each query (infoset query) has got the concept of user groups, which limits
the access to the queries within the user group.
※If someone does not belong to the user group, he cannot execute the queries within that
user group, etc
So, my feeling is that even infoset queries does have authorization concept...
Would you give me your thought on this?
I also thank you for your information for SCU0.
That is an interesting transaction
Kind regards,
Takashi -
Hi, i have a form with two regions, in every region i have some fields for data entry
the first region work on table A and in the second region work on table B
is possible to manage automated fetch row e automated row process in both table A & B in the same form?
Thanks,
RobiRobi - It might work if the two tables have no column names in common, otherwise no.
Scott -
Hi,
Can someone kind soul please enlighten me?
I would like to know whether can XSQL do an update on a record in the database. So far, it seems to me that only retrieving and writing is allowed.
Thanks in advance,
JerryYou should be able to call a procedure using <xsql:dml> or <xsql:include-owa> that does the trick.
-->cristian -
Unable to use the values returned by a PL/SQL stored procedure in a XSQL page
Hi,
I've been messing around with XML and XSQL in particular. I was trying to write a xsql page to display a report with account totals...I have the following .xsql which calls a PL/SQL stored procedure :
<?xml version="1.0"?>
<xsql:query connection="pfcdm" xmlns:xsql="urn:oracle-xsql">
<xsql:set-session-param name="zasset_total" value="100">
<xsql:dml connection="pfcdm">
rraman.sp_vw_id(zasset_total,zinvm_total,zmkt_val);
</xsql:dml>
</xsql:set-session-param>
select 'Asset total is {@zasset_total}' as "ASSET_TOTAL" from dual
</xsql:query>
My procedure sp_vw_id returns the values that it should. But, I am not sure how to declare variables within a page, and to output the return values. There is very scanty documentation on the usage of <xsql:dml> or <xsql:ref-cursor-function>.
Any response would be greatly appreciated.
Thanks,
RajaHere is the example from the Oracle9i (complete rewrite) of the XSQL Chapter in our Oracle documentation.
Question
I using <xsql:dml> to call a stored procedure which has one OUT parameter, but I was not able to see any results. The executed code results in the following statement:
<xsql-status action="xsql:dml" rows="0"/>
Answer
You cannot set parameter values by binding them in the position of OUT variables in this release using <xsql:dml>. Only IN parameters are supported for binding. You can create a wrapper procedure that constructs XML elements using the HTP package and then your XSQL page can invoke the wrapper procedure using <xsql:include-owa> instead.
For an example, suppose you had the following procedure:
CREATE OR REPLACE PROCEDURE addmult(arg1 NUMBER,
arg2 NUMBER,
sumval OUT NUMBER,
prodval OUT NUMBER) IS
BEGIN
sumval := arg1 + arg2;
prodval := arg1 * arg2;
END;You could write the following procedure to "wrap" it, taking all of the IN arguments that the procedure above expects, and then "encoding" the OUT values as a little XML datagram that you print to the OWA page buffer:
CREATE OR REPLACE PROCEDURE addmultwrapper(arg1 NUMBER, arg2 NUMBER) IS
sumval NUMBER;
prodval NUMBER;
xml VARCHAR2(2000);
BEGIN
-- Call the procedure with OUT values
addmult(arg1,arg2,sumval,prodval);
-- Then produce XML that encodes the OUT values
xml := '<addmult>'| |
'<sum>'| |sumval| |'</sum>'| |
'<product>'| |prodval| |'</product>'| |
'</addmult>';
-- Print the XML result to the OWA page buffer for return
HTP.P(xml);
END;This way, you can build an XSQL page like this that calls the wrapper procedure:
<page connection="demo" xmlns:xsql="urn:oracle-xsql">
<xsql:include-owa bind-params="arg1 arg2">
BEGIN addmultwrapper(?,?); END;
</xsql:include-owa>
</page>This allows a request like:
http://yourserver.com/addmult.xsql?arg1=30&arg2=45
to return an XML datagram that reflects the OUT values like this:
<page> <addmult><sum>75</sum><product>1350</product></addmult>
</page> -
XSQL arbitrary adhoc query - misleading error
Newbie question: How can I allow arbitrary adhoc queries without getting misleading errors? (I am aware this can be a security hazard)
Trying
CREATE table test5(tla varchar2(3), description varchar2(80), primary key (tla))
on the following .xsql page
<?xml version="1.0"?>
<xsql:query connection="demo" xmlns:xsql="urn:oracle-xsql"
null-indicator="yes"
allow-client-style="yes">
{@query}
</xsql:query>
yields a
<?xml version="1.0" ?>
<ERROR>oracle.xml.sql.OracleXMLSQLException: ORA-01009: missing mandatory parameter</ERROR>
Note that despite the error the test5 database is actually created and usable in SQLPlus.
Retrying the same xsql query a little later confirms this and yields
<?xml version="1.0" ?>
- <xsql-error code="955" action="xsql:query">
<statement>create table test5(tla varchar2(3), description varchar2(80), primary key (tla))</statement>
<message>ORA-00955: name is already used by an existing object</message>
</xsql-error>
Any ideas on how to avoid the misleading error message?
Otherwise XSQL works nicely.
Thanks.
null<xsql:query> expects a query to be done.
Use <xsql:dml> if you want other kinds of DML/DDL statements to be done. -
XSQL error when trying to insert record
hi,
I encounter a problem using INSERT statement in xsql:query action. If I try to use INSERT statement in my xsql page like this:
<xsql:ze_action bean="TaskentryIn">
<xsql:query>
INSERT
Grundtab( Datum,Startzeit,Endzeit)
VALUES
('{@date}',{'@begin}','{@ende}')
</xsql:query>
</xsql:ze_action>
I always get this xsql-error:
Statement.executeQuery - No result sets were produced by 'INSERT...'
So far so good, I think this shouldn't be an error rather a warning.
But this is not my primary problem.
Anyway the record is inserted in the DB. But since I call the above <xsql:query>, from within my own action handler, I call a sendRedirect() to my next page after the <xsql:query> tag was processed.
After sendRedirect(), when I am on my next page, I check the DB for the inserted records, and it shows up that the insert was made two times, so I have two identically records in my DB.
If I am not sendRedirect() to the next xsql page, then the insert is only made once. So I assume that there is a problem if an xsql-error occurs and afterwards a sendRedirect().
I am using the same way to make my SELECT statements and I dont have any trouble with them. Only when I use INSERT.
Any adive or help is appreciated.
Peter<xsql:query> is only for queries.
Use <xsql:dml> for a DML statement. -
Error when trying to run a procedure from the .xsql file
Here is the error message pasted below.
- <test>
- <xsql-error action="xsql:include-owa">
<statement>declare buf htp.htbuf_arr; param_names owa.vc_arr; param_values owa.vc_arr; rows integer := 32767; outclob CLOB;begin param_names(1) := 'HTTP_COOKIE'; param_values(1) := ''; param_names(2) := 'SERVER_NAME'; param_values(2) := 'shanthi.ijs.com'; param_names(3) := 'SERVER_PORT'; param_values(3) := '8080'; param_names(4) := 'SCRIPT_NAME'; param_values(4) := '/xsql/test/myex.xsql'; param_names(5) := 'PATH_INFO'; param_values(5) := ''; param_names(6) := 'HTTP_USER_AGENT'; param_values(6) := 'Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)'; owa.init_cgi_env(6,param_names,param_values); scott.get_date; owa.get_page(buf,rows); dbms_lob.createtemporary(outclob,true,dbms_lob.session); for i in 1..rows loop dbms_lob.writeappend(outclob,length(buf(i)),buf(i)); end loop; ? := outclob; ? := DBMS_LOB.INSTR(outclob,CHR(10)| |CHR(10));end;</statement>
<message>ORA-06550: line 3, column 75: PLS-00302: component 'SESSION' must be declared ORA-06550: line 3, column 28: PL/SQL: Statement ignored ORA-06550: line 3, column 120: PLS-00302: component 'WRITEAPPEND' must be declared ORA-06550: line 3, column 111: PL/SQL: Statement ignored</message>
</xsql-error>
<xsql-error action="xsql:include-owa" />
</test>
My .xsql file is:
<test connection="system" xmlns:xsql="urn:oracle-xsql">
<xsql:include-owa>
scott.get_date;
</xsql:include-owa>
</test>
Any help in this regard is greatly appreciated.
Shanthi
nullI tried this way:
<?xml version="1.0"?>
<datapage connection="system" xmlns:xsql="urn:oracle-xsql">
<xsql:dml>
begin
get_rec;
end;
</xsql:dml>
</datapage>
Here it doesn't give any error, Why is it that it works here but not with <xsql:include-owa>, ofcourse I need to get a proper output from the procedure yet. Looks like the procedure doesn't support "out" variable, should I specifically use a function ?
Anyhelp will be appreciated.
Shanthi -
ANN: XSQL Servlet 0.9.8.6 Release Available
Oracle is excited to announce the 0.9.8.6 technology preview
release of Oracle XSQL Pages and the XSQL Servlet with major
new functionality.
-----------------[ Download Info ]-------------------
http://technet.oracle.com/tech/xml/xsql_servlet/
Click on "Software" to Download
Click on "Release Notes" for Full Documentation
XSQL Pages are server-side XML templates that make it easy
to exploit the powerful combination of SQL, XML and XSLT to
prototype and deploy dynamic, data-powered sites and web
services.
The XSQL Servlet installs into your favorite Java Servlet
environment and works with your favorite relational database,
making it dead easy to:
-> Assemble XML "DataPages" from multiple SQL Query
Results (including full support for Oracle8i's
richly-structured XML Objects Views), local or remote
XML resources, Stored Procedure Calls, etc.
-> Transform the "DataPages" in the server using XSLT,
optionally using stylesheets that are appropriate to
the requesting client, including the ability to
let the client to the stylesheet processing for IE5
or other clients in the future that support this.
Our online support forum for XML is at:
http://technet.oracle.com/support/bboard/discussions.htm
The XSQL Servlet demos (included in the release) are
installed on Oracle's OTN site and can be tested from the
comfort of your browser before you download if you choose:
http://technet.oracle.com/tech/xml/demo/demo1.htm
This new 0.9.8.6 release includes...
More Documentation
==================
More extensive documentation and new tutorial material.
New Demos
=========
New and enhanced demos with additional notes describing key
points each demo is trying to illustrate.
New API's and JavaDoc
=====================
Programmatically process XSQL Pages from your own Java
programs using a new XSQLRequest object, as well as write
custom page "action handlers" with new JavaDoc and
example code.
New Features
============
<xsql:query>
The <query> element from previous releases is now part of
the xsql namespace and is referred to using the new
<xsql:query> syntax in your XSQL Page. A new section details
how to use <xsql:query> to produce XML query results with
nested structure.
<xsql:dml>
Do DML and call stored procedures anywhere you need to in
your XSQL Pages.
<xsql:stylesheet-param>
Use parametrized XSLT Stylesheets and set the stylesheet
parameter values from your XSQL Page.
<xsql:insert-request>
Automatically insert posted XML or HTML Form parameters into
the database.
<xsql:include-xml>
Include arbitrary XML resources at any point in your page by
relative or absolute URL.
<xsql:include-request-params>
Include key information like HTTP Parameters, Session
Variable values and Cookies into your XSQL Page for
addressing them in your stylesheet.
<xsql:include-xsql>
Include the results of one XSQL Page at any point inside
another. This allows sophisticated combinations of multiple
XML data sources and multiple XSLT transformations.
<xsql:include-owa>
Include the results of executing a stored procedure that
makes use of the Oracle Web Agent (OWA) packages inside the
database to generate XML.
<xsql:action>
Invoke a user-defined action handler, implemented in Java,
for executing custom logic and including custom XML
information into your XSQL Page.
nullThat error message is outdated and should read:
Cannot find XSQLConfig.xml in your server-side classpath. The error is definitely that it's not finding XSQLConfig.xml on your classpath. The likely cause is that you did not add the directory:
./xsql/lib
to your CLASSPATH in the JRun Servlet Engine Java environment.
Maybe you are looking for
-
Airplay after upgrading itunes
I'm running itunes on a windows Vista pc. Unfortunately I let itunes install the latest V11 and since then I can't get airplay to work. Following some googling I've found out it's windows firewall. If I turn off the firewall all works fine. The r
-
hi please send me one example of follwing reports 1.alv 2.interactive report 3.classical
-
Hi all ; I have some confusion regarding redo apply Vs real time apply. When applying redo data in standby site , how do we find whether it was done by redo apply or real time apply ? Please discuss in detail. I need some clarification about this.
-
Redirect Document Recovery using registry setting or Group Policy
Hi all, I am deploying In Design CS5.5 (version 7.5) on several Windows 2008 R2 SP1 Citrix servers. The users login to the server and use the server desktop to run applications. For many apps we have used redirection for cache folders etc to try and
-
Problem with ActionListener firing multiple times
I have a GUI class, GUIView, with a no-arg constructor and a static getInstance() method. The GUI class has a JButton called btnB1 with a method: void addB1Listener(ActionListener al){ btnB1.addActionListener(al); }The Controller