Sybase stored proc, no rows in the resultset
Hi!
I have a sybase stored proc that looks more like -
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
BEGIN
DROP PROCEDURE dbo.ETC_DETAILS
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
PRINT '<<< FAILED DROPPING PROCEDURE dbo.ETC_DETAILS >>>'
ELSE
PRINT '<<< DROPPED PROCEDURE dbo.ETC_DETAILS >>>'
END
go
CREATE PROCEDURE dbo.ETC_DETAILS
@trade_id id,
@broker_cd code,
@contact_group_id int,
@product_id id,
@security_type_id smallint
AS
if(cond1)
begin
select distinct
cd=t.cd,
name=t.name,
t.trade_id,..........
from
table1 t,
table2 tt,
table3 b,.......
where t.trade_id = tt.trade_id
and t.transaction_type_id = ttt.transaction_type_id
and .....
end
else
select distinct
cd=t.cd,
name=t.name,
t.trade_id,..........
from
table4 t,
table5 tt,
table6 b,.......
where t.trade_id = tt.trade_id
and t.transaction_type_id = ttt.transaction_type_id
and .....
end
go
GRANT EXECUTE ON dbo.ETC_DETAILS TO public
go
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
PRINT '<<< CREATED PROCEDURE dbo.ETC_DETAILS >>>'
ELSE
PRINT '<<< FAILED CREATING PROCEDURE dbo.ETC_DETAILS >>>'
go
EXEC sp_procxmode 'dbo.ETC_DETAILS','unchained'
go
GRANT EXECUTE ON dbo.dbo.ETC_DETAILS TO public
go
When run through SQL Editor - runs and returns me rows. But does not return any rows when invoked from Java. "gotResultSet" is true, but the while loop does not execute. Any clues, why? Here is the Java code.
public class AllocationExtractor {
public Collection getAllocations(int tradeId, String brokerCode, int contactGroupID, int productID, int securityTypeID) throws SQLException
Connection c = null;
String query = "{ call ETC_DETAILS(?,?,?,?,?) }";
CallableStatement stmt = null;
ResultSet rs = null;
boolean gotResults = false;
try{
c = ConnectionFactory.getSybaseConnection(url, user, pwd);
stmt = c.prepareCall(query);
stmt.setInt(1, tradeId);
stmt.setString(2, brokerCode);
stmt.setInt(3, contactGroupID);
stmt.setInt(4, productID);
stmt.setInt(5, securityTypeID);
gotResults = stmt.execute();
if(gotResults)rs = (ResultSet) stmt.getResultSet();
if (rs != null){
System.out.println("Got resultSet");
while(rs.next()){
System.out.println("Iterating the resultset");
Allocation a = new Allocation();
a.setTradeID(rs.getString("trade_id"));
System.out.println(a.getTradeID());
allocations.add(a);
public static void main(String args[]){
AllocationExtractor e=new AllocationExtractor();
Collection c = null;
int tradeID = 3115;
String broker_cd = new String("327");
int product_id = 20;
int contact_group_id = 1;
int security_type_id = 1219;
e.user = "developer";
e.url = "jdbc:sybase:Tds:devbox:12344";
e.pwd = "developer";
try{
c = e.getAllocations(tradeID, broker_cd, product_id, contact_group_id, security_type_id);
catch(SQLException se){
se.printStackTrace();
Silly me! had switched the parameters to the method in Java.
Similar Messages
-
Java.sql.SQLException: No current row in the ResultSet
Hi All,
I use JTDS 1.2.
I get the following error:
java.sql.SQLException: No current row in the ResultSet.
when I run the following code:
public void QueryToCust(){
String username = "sa";
String password = "";
String url = "jdbc:jtds:sqlserver://localhost:1433/OkyanusPINAR2006;tds=8.0";
setSQLcode("select * from firma where kod='123'");
try{
Class.forName("net.sourceforge.jtds.jdbc.Driver");
} catch (Exception e){
setErrMsg(e.toString() + " cannot register class.");
return;
Statement stmt = null;
Connection con = null;
try{
con = DriverManager.getConnection(url,username,password);
} catch (Exception e){
setErrMsg(e.toString() + " cannot connection!");
return;
try{
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sqlCode);
if(rs != null){
String name = new String(rs.getString("name"));
setCustName(name);
rs.close();
con.close();
} catch (Exception e){
setErrMsg(e.toString());
return;
setErrMsg("jdbc: No error!");
}This sql code running with msSQL Enterprise Manager SQL tools return to row. But can not run it in java! Why?you need to call
rs.next(); -
Getting error while invoking relational physical DS for sybase stored proc
*com.bea.dsp.das.exception.DASException: com.bea.dsp.wrappers.rdb.exceptions.RDBWrapperException: {bea-err}RDBW0004: Error executing SQL query: [BEA][Sybase JDBC Driver][Sybase]SELECT INTO command not allowed within multi-statement transaction+.*
I have created a physical DS function using "relational" in the wizard and connecting to sybase ASE stored procedure that is in unchained mode. I had configured the JDBC pool using BEA sybase non-XA 12.x driver.
When i run the physical DS (or logical DS), i get the above error. The sybase srever(and stored proc) is hosted by an external system and right now i do not have access/contacts to change anything.
After hours spent googling, it appears that the fix may possibly be setting "set chained off" before calling the stored proc. To achieve that, i tried the below two methods but nothing seems to work:
- In the JDBC URL, set property via ?chained=off (also tried false instead of "off")
- In Admin console/JDBC connection pool configuration/initSQL tried "SQL SET CHAINED OFF" and "SET CHAINED OFF"
My ODSI version is 10gR3
Oracle Workshop for WebLogic
Version: 10.3
Build id: 1137967
I tried using java physical DS and get the same error. I wrote a test stored proc in my local PC sybase ASE and it runs fine. But i connected as "sa".
I would like to exhaust all possible options from my side before making the long process of getting something changed in the external sybase DB like setting the proc mode to "anymode".
Please help.
Thank you.mikereiche wrote:
Did the test stored proc use "SELECT INTO"?Yes. But it did not do much(code below)
>
Was the test stored proc tagged the same as the one that fails (chained/unchained?)Yes. "sp_procxmode" confirms that the test stored proc is in "unchained" transaction mode.
>
Can you get jdbc code that successfully calls the stored proc using the datasource?Yes, my colleague was trying the jdbc code and i was trying in the workshop with relational. She has left for the day so will post tomorrow. Please note that this is only for the test stored proc. The java jdbc also gets the same error for the "real" stored proc.
>
BTW - if you used "SET CHAINED OFF" as initSql, unless you have a table named SET, the sql will fail and the datasource will not be created. So that casts some doubt on whether the other setting "SQL SET CHAINED OFF" was applied.
Also - the connections are reset to default when they are returned to the connection pool, so I think "SQL SET CHAINED OFF" should be used as the "Test Table Name" and Test On Reserve should be checked.Tried it now, but it does not work. I'm getting the same error.
test stored proc:
create procedure dbo.getCustomerMulti @cid_inp varchar(40)
as
begin
select dbo.Customer.FirstName, dbo.Customer.cid, dbo.Customer.LastName, dbo.Customer.DateCreated, dbo.Customer.id into #temp from dbo.Customer
select dbo.Customer.FirstName, dbo.Customer.cid, dbo.Customer.LastName, dbo.Customer.DateCreated, dbo.Customer.id from dbo.Customer where cid LIKE @cid_inp + '%'
end
Thank you. -
Writing a Stored Proc which will execute the Queries passed to it as args
Hi,
I need to write a Stored Proc which gets the Query to be executed as an Argument and return the results in an OUT Variable.
The Stored Proc i wrote is
CREATE OR REPLACE PROCEDURE SP_FETCH_RESULTS(l_query in varchar2,
l_returnValue out clob )
is
l_output utl_file.file_type;
l_theCursor integer ;
l_columnValue clob;
l_status integer;
l_results clob;
begin
l_theCursor := dbms_sql.open_cursor;
-- Parse the Query
dbms_sql.parse( l_theCursor, ':x', dbms_sql.native );
DBMS_SQL.BIND_VARIABLE(l_theCursor, ':x', l_query);
-- Define the coulmnValue Variables
dbms_sql.define_column( l_theCursor, 1, l_columnValue);
-- Execute the Query
l_status := dbms_sql.execute(l_theCursor);
-- Get the Results and prepare the return Value.
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
dbms_sql.column_value( l_theCursor, 1, l_columnValue );
DBMS_LOB.APPEND(l_returnValue, l_columnValue);
end loop;
-- Close the Cursor
dbms_sql.close_cursor(l_theCursor);
end SP_FETCH_RESULTS;
As the Queries paased to it always return CLOB Types i declared the OUT Variable as CLOB
And when i try to execute is using the below given PL/SQL Block
DECLARE
l_Query CLOB ;
l_retVal CLOB;
l_results CLOB;
BEGIN
l_Query:='SELECT extract(object_value,''/AC'').getStringVal() into l_results from CommonAssetCatalog';
SP_FETCH_RESULTS(l_Query,l_retVal);
dbms_output.put_line ('Results =');
END;
I am getting the Error.
ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at "SYS.DBMS_SYS_SQL", line 906
ORA-06512: at "SYS.DBMS_SQL", line 39
ORA-06512: at "WEBLOGIC.SP_FETCH_RESULTS", line 13
ORA-06512: at line 7
Could you guys pls give me some inputs on how to resolve this..
Thanks a lot
SateeshHi James,
I tried with out the Bind Variable and got the Same Error..
The Code which i tried earlier is
CREATE OR REPLACE PROCEDURE SP_FETCH_RESULTS(l_query in varchar2,
l_returnValue out clob )
is
l_output utl_file.file_type;
l_theCursor integer ;
l_columnValue clob;
l_status integer;
l_results clob;
begin
l_theCursor := dbms_sql.open_cursor;
-- Parse the Query
dbms_sql.parse( l_theCursor, l_query, dbms_sql.native );
--DBMS_SQL.BIND_VARIABLE(l_theCursor, ':x', l_query);
-- Define the coulmnValue Variables
dbms_sql.define_column( l_theCursor, 1, l_columnValue);
-- Execute the Query
l_status := dbms_sql.execute(l_theCursor);
-- Get the Results and prepare the return Value.
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
dbms_sql.column_value( l_theCursor, 1, l_columnValue );
DBMS_LOB.APPEND(l_returnValue, l_columnValue);
end loop;
-- Close the Cursor
dbms_sql.close_cursor(l_theCursor);
end SP_FETCH_RESULTS;
and the Procedure got Compiled Successfully and when i ran the PL/SQL Block which calls the Above Stored Proc i got the Error
DECLARE
ERROR at line 1:
ORA-00905: missing keyword
ORA-06512: at "SYS.DBMS_SYS_SQL", line 906
ORA-06512: at "SYS.DBMS_SQL", line 39
ORA-06512: at "WEBLOGIC.SP_FETCH_RESULTS", line 13
ORA-06512: at line 7
Pls let me know how can i resolve this..
Thanks
Sateesh -
Failing to execute Sybase Stored Proc on startup
This problem has been encountered while upgrading from weblogic 5.1 to 8.1: when
a connection is used in a connection pool with the attribute conn.setAutoCommit(true),
we get an error message:
<<Cannot set auto commit to "true" when in distributed transaction.>>.
When forcing setAutoCommit(false), then a new message appears about being unable
to chain stored procedures. Obviously the transaction syncronization the entitry
bean and the Sybase jConnect 5.5 jdbc driver is off. We had a similar problem
long ago when installing weblogic 5.1 and fixed it with a subtle change in the
weblogic.properties.
What should be changed in the configuration? Or is this a deeper issue with the
Jdbc driver or
Sybase configuration?
Particulars: weblogic 8.1 SP1 running on windows 2000 SP3; Sybase jConnect 5.5:
jconn2.jar
Show me the whole SQLException stacktrace (in both cases).
The issue is probably in the DBMS stored procedure itself,
not the driver or weblogic. An odd fact is that Sybase stored
procedures have a default execution mode, which the DBMS
enforces. If the procedure was created when the connection
was in the typical chained-off (autoCommit(true)) mode, the
procedure will only be allowed to run when the connection is in
that unchained autoCommit(true) mode. Alternately, if the
procedure was created during an autoCommit(false) session, then
the DBMS will only allow the procedure to run in that mode!
However, Sybase will allow any procedure's executre-mode to
be changed to allow it to run in any mode. The system stored
procedure sp_procxmode will set that:
sp_procxmode my_procedure_name, ANYMODE
(something like that. Please check the documents).
That should allow you to run without playing with the autoCommit mode,
which you shouldn't anyway.
Joe
John Redden wrote:
> This problem has been encountered while upgrading from weblogic 5.1 to 8.1: when
> a connection is used in a connection pool with the attribute conn.setAutoCommit(true),
>
> we get an error message:
>
> <<Cannot set auto commit to "true" when in distributed transaction.>>.
>
> When forcing setAutoCommit(false), then a new message appears about being unable
> to chain stored procedures. Obviously the transaction syncronization the entitry
> bean and the Sybase jConnect 5.5 jdbc driver is off. We had a similar problem
> long ago when installing weblogic 5.1 and fixed it with a subtle change in the
> weblogic.properties.
>
> What should be changed in the configuration? Or is this a deeper issue with the
> Jdbc driver or
> Sybase configuration?
>
> Particulars: weblogic 8.1 SP1 running on windows 2000 SP3; Sybase jConnect 5.5:
> jconn2.jar
-
Why can't I print the content of a row in the ResultSet twice?
An exception was thrown when I tried to print it twice like this:
while (rs.next()) {
System.out.println(rs.getString(1));
System.out.println(rs.getString(1));
}Why?An exception was thrown when I tried to print it
twice like this:
while (rs.next()) {
System.out.println(rs.getString(1));
System.out.println(rs.getString(1));
}Why?The real question is: why would you want to do that? ResultSets shouldn't be printed like that. MVC separation says that printing is View, and ResultSet is persistence. Better to iteration through the ResultSet once, loading the data into an object or data structure, close the ResultSet in a finally block, and then pass the object or data structure for rendering (be that printing or JSP or Swing or whatever your View is).
% -
Trying to find the number of rows in a ResultSet
I am trying to find the number of rows in a ResultSet, using the following code:
rs = st.executeQuery(query);
rs.last(); // to move the cursor to the last row
System.out.println(rs.getRow());
However, I am getting this error:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.last
Whats going wrong??praveen_potru wrote:
You might have not used scrollable result set..
Try like this:
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);rs = stmt.executeQuery(sqlString);
// Point to the last row in resultset.
rs.last();
// Get the row position which is also the number of rows in the ResultSet.
int rowcount = rs.getRow();
System.out.println("Total rows for the query: "+rowcount);
cheersAnd I hope the OP would read it because the thread is a year old. -
Getting the no. of rows returned from the resultset
Could somebody tell how can I get the count of rows from the resultset object.
Thanks a lot in advancehmmm 20,710 topics and 69,000 odd posts and no one has EVER asked this question before.. it's a miracle....
or maybe it has been asked and dealt with approx... 11,000 times.
here is a discussion from 1998 for example http://forum.java.sun.com/thread.jsp?forum=48&thread=83958 -
Stored Proc Migration question
In sql server I have what is basically a select statement (multiple records) that is returned from a stored proc and as I understand it Oracle doesn't allow you do this in the same fashion.
Instead a cursor has to be used (from what i understand?, although I am not 100% sure)
so my question is this; Use of cursors in MS SQL Sever / Sybase can be resource intensive and slow. - my understanding of cursors in SQL server\ sybase is that you should really use them unless you have to.
Is this the case in Oracle, or is it totally different?
should I be looking at a different way of reproducing the data - i.e. using a procedure to create that data into a table then using a view to return the records.
many thanksAny SQL statement that returns records is a cursor, whether in Oracle od SQL Server or Sybase. There may be a larger difference in SQL Server performance between explicit cursors (i.e. those formally declared) and implicit cursors (i.e. just select) than there is in Oracle, but they are all still cursors.
The only way to retunr a result set to a calling program from a stored proc in Oracle is to use a cursor. Cursors, in themselves, are not any more resource intensive than the underlying sql statement. What tends to be resource intensive in Oracle is the row by row processing that people usually do with th cursors they fetch.
In Oracle, you would generally do something like this to return a cursor to another program.
PROCEDURE p (p_id IN NUMBER, p_cur OUT SYS_REFCURSOR)
BEGIN
OPEN p_cur FOR SELECT * FROM t WHERE id = p_id;
END;Then call it like:
DECLARE
l_cur SYS_REFCURSOR;
variables or a record to receive the fields
BEGIN
p(1, l_cur);
LOOP
FETCH l_cur INTO variables or record
EXIT WHEN l_cur%NOTFOUND;
<processing>
END LOOP;
END;The exact syntax to declare the cursor and call the stored proc will depend on the language of the calling program.
You could also do P as a function returning a sys_refcursor.
HTH
John -
Crystal Report using Stored Proc in JSP problem
Hello,
I am running a simple report using a stored proc(oracle). It runs fine when I run the report through Crystal. But when I tried running it using JSP it gives me this exception -
com.crystaldecisions.report.web.viewer.CrystalRepo rtViewer
Error formatting page : Unexpected Query Engine error
Can some one pls advise why I am not able to run this report through JSP?
My other reports with simple sql runs fine in my JSP.
Here is my stored proc --
PACKAGE BODY MY_TEST
AS
PROCEDURE getrecordset
p_cursor OUT cursor_type
IS
BEGIN
OPEN p_cursor FOR
SELECT
FROM
DSR_CLASS_SET;
END;
END MY_TEST;Thanks for your comments.
If I run the same query, report runs fine. So I guess it should also able to run this stored proc.
Here is the detailed error ---
Category: com.crystaldecisions.reports.reportengineinterface
Message: failed to process getPage request
Location:
Thrown:
com.crystaldecisions.reports.reportengineinterface.EngineException: Error formatting page : Unexpected Query Engine error
at com.crystaldecisions.reports.reportengineinterface.Engine.getPage(Unknown Source)
at com.crystaldecisions.reports.reportengineinterface.JPEReportSource.getPage(Unknown Source)
at com.crystaldecisions.report.web.viewer.ReportAgent.a(Unknown Source)
at com.crystaldecisions.report.web.viewer.CrystalReportViewer.goto(Unknown Source)
at com.crystaldecisions.report.web.ServerControl.a(Unknown Source)
at com.crystaldecisions.report.web.ServerControl.processHttpRequest(Unknown Source)
at jsp_servlet._crystal.__test._jspService(__test.java:225)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:446)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Caused by: com.crystaldecisions.reports.formatter.formatter.c: Unexpected Query Engine error
at com.crystaldecisions.reports.formatter.formatter.objectformatter.bf.<init>(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.objectformatter.bf.a(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.d.j.<init>(Unknown Source)
at com.crystaldecisions.reports.formatter.formatter.d.j.if(Unknown Source)
... 19 more
Caused by: com.crystaldecisions.reports.dataengine.k: Unexpected Query Engine error
at com.crystaldecisions.reports.dataengine.ap.case(Unknown Source)
at com.crystaldecisions.reports.dataengine.ap.jO(Unknown Source)
at com.crystaldecisions.reports.dataengine.ap.aC(Unknown Source)
at com.crystaldecisions.reports.dataengine.ap.aD(Unknown Source)
at com.crystaldecisions.reports.dataengine.ap.case(Unknown Source)
at com.crystaldecisions.reports.dataengine.au.a(Unknown Source)
at com.crystaldecisions.reports.dataengine.a0.a(Unknown Source)
at com.crystaldecisions.reports.dataengine.a0.aa(Unknown Source)
at com.crystaldecisions.reports.dataengine.a0.<init>(Unknown Source)
at com.crystaldecisions.reports.dataengine.a0.<init>(Unknown Source)
at com.crystaldecisions.reports.dataengine.a0.a(Unknown Source)
... 23 more
Caused by: com.crystaldecisions.reports.reportdefinition.datainterface.d: Unexpected Query Engine error
at com.crystaldecisions.reports.reportdefinition.datainterface.b.a(Unknown Source)
... 34 more
Caused by: com.crystaldecisions.reports.queryengine.al: Unexpected Query Engine error
at com.crystaldecisions.reports.queryengine.driver.l.if(Unknown Source)
at com.crystaldecisions.reports.queryengine.ao.dZ(Unknown Source)
at com.crystaldecisions.reports.queryengine.ao.f(Unknown Source)
at com.crystaldecisions.reports.queryengine.ao.dK(Unknown Source)
at com.crystaldecisions.reports.queryengine.b0.dB(Unknown Source)
at com.crystaldecisions.reports.queryengine.bz.a6(Unknown Source)
... 35 more
Any guess why I get this? -
Error committing transaction in Stored Proc call - prev solns not working
Hi All,
Our process invokes a DB adapter to fetch the response from the table for our request via Stored Procedure call but facing the below issue. Its a synchronous process. Stored Procedure is present inside the Package and we are calling the Stored procedure using that Package.
What we did is created a DB datasource of XA type and tried to call the Stored Proc but it was giving a problem “ORA-24777: use of non-migratable database link not allowed” and hence according to this thread Using DB links in Stored proc call in DB adapter 11G SOA we have modified the datasource as non-XA type.
While we do that, we could see that Stored Proc is called and the response is present in the reply payload inside the flow trace. But the instance is getting faulted and the error is “Error committing transaction:; nested exception is: javax.transaction.xa.XAException: JDBC driver does not support XA, hence cannot be a participant in two-phase commit. To force this participation, set the GlobalTransactionsProtocol attribute to LoggingLastResource (recommended) or EmulateTwoPhaseCommit for the Data Source.”
We have tried the properties of global transaction support as one phase commit, emulate two phase commit and logging last resource but error remains the same.
Database from which we are getting the response is of version "Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production". Will the database link error arises even if we connect to Oracle Database?
Please could you advise me solutions to resolve this issue.
Thanks in advance.You are using Non-XA because it means (among all others) that the commit issue can be handle by the DB as well.
The Emulate Two Phase property imitating the XA transaction in that way, that it allows you to manage a local db transaction.
You can stay with XA connection, but then you will have to use "AUTONOMOUS_TRANSACTION pragma" in your procedure.
Enter the following link to find good explanation about all of your questions:
http://docs.oracle.com/cd/E15523_01/integration.1111/e10231/adptr_db.htm#BGBIHCIJ
Arik -
Should I do this with Java Code or Stored Procs ? (for best performance)
Hi All,
I need to decide where should I implement my business logic, in Java code or Stored procs.
Here is the requirement :
- One Order has 70 products (Order_Table )
- Can be duplicate products, so I have to do summarize / grouping by product
- For every product, I have to check, if it is entitled for a Bonus product, then I have to Insert one to Bonus_Table.
- This is done when/after the transaction is SAVED (COMMIT)
The question is, which one has better PERFORMANCE :
(1) Create a rowsetIterator on the Order details (70 products) and call a stored procedure to do the logic for every single product (so that the Insert to Bonus_Table done in stored proc). means the stored proc will be called 70 times.
OR
(2) After the transaction is COMMITted, call the stored procs ONCE to do the logic for all the products at once.
OR
(3) I do all the logic with Java Code within ADF
Given the requirement above, which approach is most efficient / best performance ?
Thank you very much,
xtantoProblem with this is that you ask 100 people and you probably get 100 different answers. ;o)
Many would say that you push as much business logic into the database with your data; others might say you only put data in your database and your business logic is kept on the application server.
In reality your would probably have a mix of both and your decision would probably be influenced by your own background ...
Can't be more precise than that.
Grant -
DB: Release 8.1.5.0.0
Server: DEC Alpha OSF1 V4.0F
Driver: thin, version?
We're using JDBC to access Oracle tables from classes loaded into the database with loadjava. I can execute a statement and get a ResultSet, but I haven't been able to find a way to get the number of rows in the ResultSet (since Oracle's implementation of JDBC doesn't include the getFetchSize method of ResultSet).
Is there another way to get the size of a ResultSet? If not, will Oracle be adding the getFetchSize method to their implementation soon?
Thanks.
null> > Try ResultSet rs = statment.executeQuery(...);
if(rs
== null){ //result set is empty}That is incorrect... it should have read:
ResultSet rs = statment.executeQuery(...);
if( ! rs.next() )
//result set is empty
you're right!! copy/paste from executeUpdate( ) api documentation about statements....
"a ResultSet object that contains the data produced by the given query; never null"
here's the catch though: that will advance your result set, which will throw off your cursor in a while loop (used to parse the results). requires you to reset the cursor before processing the result set. -
Stored proc returns zero result
Hello, please help me. I am quite new to oracle stored
procedures. I have a proc that returns data to cfm but it keeps
giving zero results. But if i don't use stored proc, the same query
gives me something. please help. my stored proc and cfm goes
something like below:
************************************ stored procedures
CREATE OR REPLACE PACKAGE PACK_REFCURSOR_NHM_TRANSACTION AS
TYPE TRANS_TableRows IS REF CURSOR;
PROCEDURE REFCUR_NHM_TRANSACTION (
IN_sTMPACC IN varchar2,
IN_sITEM_TYPES IN varchar2,
OUT_TRANS OUT TRANS_TableRows);
END PACK_REFCURSOR_NHM_TRANSACTION ;
CREATE OR REPLACE PACKAGE BODY PACK_REFCURSOR_NHM_TRANSACTION
AS
PROCEDURE REFCUR_NHM_TRANSACTION (
IN_sTMPACC IN varchar2,
IN_sITEM_TYPES varchar2,
OUT_TRANS OUT TRANS_TableRows)
IS
BEGIN
OPEN OUT_TRANS FOR
SELECT T.TRANSACTION_ID, T.TRANSACTION_TYPE,
T.TRANSACTION_DATE, T.TRANSACTION_TIME,
T.ITEM_CODE, 0 OE_DETAIL_ID,
T.QUANTITY, T.LIST_PRICE, T.DISCOUNT, T.SALE_PRICE,
T.GST_AMOUNT, 'I' INSURER_TYPE
FROM NHM_TRANSACTION T
WHERE DISPENSED_FLG = 'Y'
AND T.ACCOUNT_ID = IN_sTMPACC
AND T.TRANSACTION_TYPE IN ('01','02', '09')
AND NVL(T.STATUS,'F') != 'C'
AND T.BILLED_FLG = 'N'
AND T.ITEM_TYPE IN (IN_sITEM_TYPES)
AND T.BILL_ITEM_FLG = 'Y'
UNION ALL
SELECT T.OE_TRANSACTION_ID TRANSACTION_ID, TRANSACTION_TYPE,
T.TRANSACTION_DATE,
T.TRANSACTION_TIME, NVL(T.ITEM_CODE,T.PACKAGE_CODE)
ITEM_CODE, T.OE_DETAIL_ID,
T.QUANTITY, T.LIST_PRICE, T.DISCOUNT, T.SALE_PRICE,
T.GST_AMOUNT, 'S' INSURER_TYPE
FROM NHC_OE_TRANSACTION T, NHC_MASTER_ITEM M, NHM_PACKAGE P
WHERE T.ACCOUNT_ID = IN_sTMPACC
AND T.ITEM_CODE = M.ITEM_CODE(+)
AND T.PACKAGE_CODE = P.PACKAGE_CODE(+)
AND (DECODE(T.ITEM_CODE,NULL,P.BILL_OPTION,M.BILL_OPTION) in
('P','O','F'))
AND NVL(T.STATUS,'F') != 'C'
AND T.BILLED_FLG = 'N'
AND ((T.TRANSACTION_TYPE = '09' AND STATUS IN ('P','R'))
OR T.TRANSACTION_TYPE IN ('01','02','11','12', '10'))
AND T.BILL_ITEM_FLG = 'Y'
AND T.ITEM_TYPE IN (IN_sITEM_TYPES) ;
END REFCUR_NHM_TRANSACTION ;
END PACK_REFCURSOR_NHM_TRANSACTION ;
*************** the cfm code (note: i am using coldfusion
MX************
<cfstoredproc datasource="#application.datasource#"
procedure="NSCOCT.PACK_REFCURSOR_NHM_TRANSACTION.REFCUR_NHM_TRANSACTION">
<cfprocparam type="IN" cfsqltype="CF_SQL_VARCHAR"
value="#TMPACC#" dbvarname="IN_sTMPACC">
<cfprocparam type="IN" cfsqltype="CF_SQL_VARCHAR"
value="#QRYLOCITEM.ITEM_TYPE#" dbvarname="IN_sITEM_TYPES">
<cfprocresult name="getPrescItems">
</cfstoredproc>
***** i dumped getPrescItems and returns no data. it's
suppose to return something . Any help is much appreciated. Thank
you. *********just an update. i found out that it has something to do with
the condition "IN". the values there is supposed to be a list (e.g.
a,b,c,d,e,f,g). What I suspect is that when in stored proc, it
interprets in the query as "IN('a,b,c,d,e,f,g')" instead of
"IN('a','b','c','d','e','f','g')" which is what I actually want.
I have also tried the quotedvaluelist in cfm but still no
result, so i suspect again, using quotedvaluelist, that it
interprets in the proc as "IN(''a','b','c','d','e','f','g'')".
Can anybody help me whit this so i can have the proc
interpret my IN condition as "IN('a','b','c','d','e','f','g')"?
Thanks. -
Item Type Based on PL/SQL stored proc causing errors
I am getting the following error when I add this item type based on a pl/sql stored proc that generates html based on the stored proc... the stored proc returns find but the other porlets get Error Message in there headers and in the porlet content I get:
Error: The listener returned the following Message: 503 Service Unavailable....
I also get the same error if I click on a link that is generated from my stored proc for the entire page I get the error:
Error: The listener returned the following Message: 503 Service Unavailable
and get nothing else returned...Greetings
I suggest you take a look at the following page and have a look on how to create portlets. Since the PL/SQL PDK allows you to create your own portlets inside the Oracle Database there should be no problem for creating the content inside a portlet the way you want it.
http://www.oracle.com/technology/products/ias/portal/pdk.html
Best regards
Johan
Maybe you are looking for
-
How do I convert a PDF (made in Indesign) back into an editable InDesign format?
My hope is to edit just one line, and then we can send to print.Thanks for your help!
-
Export a pdf to a swf file with navigation buttons???
I have CS4 and I've tried to export a couple indesign files using the swf export feature, but it the navigation of the file is very weak and not very intuitive, and when you zoom in to any of the text the text goes fuzzy. I would like to just convert
-
Must turn iPod off and back on to play a song
Hello everyone, Almost everytime I go to use my iPod after it has been turned off for more than a couple hours I have the following problem: I can navigate through all menus, and select a song or video to play, but the song or video will not play. In
-
I have been unable to pair my jambox with my iPad 3
Trying to pair my iPad 3 with my jambox and just get the searching message. It says on Apple Store that they're compatable. Anyone know what I need to do or install to get this to work? Thanks in advance.
-
Saving as Disc Image hangs/freezes and must force quit to exit
Hi, I've always been able to Save as Disc Image in order to make multiple copies. Now, it runs fine all the way until it gets to "Burn - Current Operation: Writing" where it freezes indefinitely. The beachball turns so I eventually have to force-quit