How to use Parameterized Stored Procedure in OBIEE 10 g..?
Hi All,
In my rpd, to load the data in the Physical layer, I'm using a Stored Procedure (*SQL Server Stored Procedure*).
This stored procedure is using some parameters, so my intention is
1) Provide prompts for each parameter
2) Allow the user to select parameter value from the prompt
Can some one let me know if this is possible and if so how to do this.
Thanks in Advance
Mithun
Dear,
In report triggers you can write your procedure/functions or call it like
function AfterPForm return boolean is
begin
myprocedure(:mydate);
return (TRUE);
end;
Thanks
Jamil
Similar Messages
-
How to use a stored procedure as a datasource in Crystal Report for Eclipse
Hi All,
I've written a stored procedure in oracle 10g with few input parameters and one refcursor output parameter. I want to use this stored procedure as a data source for creating a report in "Crystal Report For Eclipse 3.6.0".
When I tried to add this stored procedure to the report using the connection explorer, I don't see any option to do this. But when I try to add any table, it shows options like "Add to the current report"....
Can anybody assist me how to use a stored procedure as a data source in "Crystal Report For Eclipse"?
Which driver should I use to connect to the oracle database? I tried using JDBC Driver for Oracle.
Thanks in advance.Did you solve your problem? How did you do?
-
How to use a stored procedure in oracle reports
How to use a stored procedure in oracle reports
Dear,
In report triggers you can write your procedure/functions or call it like
function AfterPForm return boolean is
begin
myprocedure(:mydate);
return (TRUE);
end;
Thanks
Jamil -
How to use the Stored Procedure to update my UDF
I want to use the Stored Procedure to update my UDF U_InstokCS when the warehouse "OnHand" was changed. The UDF is display the stock by cases. I copied the query as follewing. I couldn't see any thing in the UDF after I made some transactions. Can anybody tell me why? How to continue it?
if @transaction_type in ('A','U','D') and @Object_type='64'
begin
Update OITW
Set U_InstokCS = OnHand/(Select T0.NumInBuy from [DBO].[OITM] T0
Where T0.ItemCode = @list_of_cols_val_tab_del)
Where ItemCode = @list_of_cols_val_tab_del
end
Thanks.
Ying ZhangYing,
The use of any stored procedures against the SAP Business One database is not allowed per SAP Support. There is not an instance where you can use SP's. The ONLY SP that you are allowed to use is the SBO_SP_TransactionNotification SP that comes with SAP Business One itself. You can read about the use of this SP from this article...
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e991e2b9-0901-0010-0395-ef5268b00aaf
Eddy -
How to call Oracle Stored Procedure using EDQ
Can someone tell me how to use Oracle Stored Procedure call in EDQ, sample scripts/steps will be really helpful. Thanks!
It is also possible to do this using a custom processor in EDQ. The processor needs to do something very similar to the external task above (opens a DB connection, authenticates, runs a stored procedure).
If you need this, please talk us through the use case so we can determine if it is the best fit. In some ways, an external task is better as logically a stored procedure call is normally divorced from any process logic in EDQ.
Regards,
Mike -
Table Type Stored Procedure in OBIEE Physical table properties
Hi,
Any one has ever used the Stored Procedure in OBIEE Physical table properties??
I've a procedure & a table i want to plopulate the tabel using the Procedure from OBIEE physical layer.It would be nice if we know more details about 'Populating table'...
Using connection pool->connection pool scripts tab you may go for inserting/updating (Populating table) records into table.
It would be nice if you use dedicated connection pool for init blocks...
Ex: I want to insert user login time some xyz table my query would be like
insert into xyz values ('valueof(NQ_SESSION.USER)',sysdate)
without knowing your requirements its hard to tell anything apart from what is said.
If helps pls mark
Edited by: Srini VEERAVALLI on Jan 16, 2013 10:37 PM -
How to implement Stored procedure in OBIEE
Hi experts
How to implement Stored Procedure in OBIEE..
My Input is Date..
Thanks in advance
Regards
FrndsDouble post :
Re: How to get the previous monthend data and currentdate data in OBIEE report
You don't need a stored procedure.
If you want the amount only for one date, you can use the filter option in the formula :
FILTER("Sales Facts"."Amount Sold" USING (Time.Day = '31 jan'))You can calculate the last day with the timestampdiff function
31Jan = 1 Feb - 1 dayIf you want the amount of the month see my post here :
Re: How to get the previous monthend data and currentdate data in OBIEE report -
Need an Example for How to call a Stored Procedure using DBAdapter
Hi
I am trying to invoke a stored procedure in Oracle Database using DB Adapter. I have successfully invoked and when i try to run it i got the following error.
oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Client received SOAP Fault from server : Exception occured when binding was invoked.
Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'ExecuteScript' failed due to:
Stored procedure invocation error.
Error while trying to prepare and execute the RESONANCEDEMO.SP_QUERY API.
An error occurred while preparing and executing the RESONANCEDEMO.SP_QUERY API. Cause: java.sql.SQLSyntaxErrorException: ORA-00917: missing comma
ORA-06512: at "RESONANCEDEMO.SP_QUERY", line 7
ORA-06512: at line 1
Check to ensure that the API is defined in the database and that the parameters match the signature of the API.
This exception is considered not retriable, likely due to a modelling mistake.
To classify it as retriable instead add property nonRetriableErrorCodes with value "-917" to your deployment descriptor (i.e. weblogic-ra.xml).
To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff.
All properties are integers.
I am trying to have a Out Parameter in my Procedure. Please provide me an example on how to invoke a Stored Procedure using Out Paramter using DB Adapter.Hi,
It looks more like an Oracle error and not within the DbAdapter.
Try to test first your procedure from PL/SQL or other developer you are using.
Arik -
How to create a stored procedure and use it in Crystal reports
Hi All,
Can anyone explain me how to create a stored procedure and use that stored procedure in Crystal reports. As I have few doubts in this process, It would be great if you can explain me with a small stored proc example.
Thanks in advance.If you are using MSSQL SERVER then try creating a stored procedure like this
create proc Name
select * from Table
by executing this in sql query analyzer will create a stored procedure that returns all the data from Table
here is the syntax to create SP
Syntax
CREATE PROC [ EDURE ] procedure_name [ ; number ]
[ { @parameter data_type }
[ VARYING ] [ = default ] [ OUTPUT ]
] [ ,...n ]
[ WITH
{ RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ]
[ FOR REPLICATION ]
AS sql_statement [ ...n ]
Now Create new report and create new connection to your database and select stored procedure and add it to the report that shows all the columns and you can place the required fields in the report and refresh the report.
Regards,
Raghavendra
Edited by: Raghavendra Gadhamsetty on Jun 11, 2009 1:45 AM -
How to call a stored procedure using its package name in Oracle
hi
we're doing a JDBC scenario where we call a stored procedure(a.prc) using its package name(b)The stored procedure has In /Out/IN-OUT parameter.
i have got 2 queries:
1- How to call the stored procedure using it's package.
2- How to capture the In/Out parameter in the response.hi Prateek
thanks for the reply.
However when i tried mapping it to Package.procedure, communication channel throws the error saying that Package.proceudre needs to be declared.
As i said , the procedure has IN-OUT parameter too.In oracle we need to write a block if we want to read the IN-OUT parameter.
How to get the IN-OUT parameter in XI? -
I am using a Data Flow and an OLE DB Source to read my staged 3rd party external data. I need to do various Lookups to try and determine if I can find the external person in our database...by SSN...By Name and DOB...etc...
Now I need to do some more data verification based on the Lookup that is successful. Can I do those data edits against our SQL server application database by utilizing an OLE DB Command? Using a Stored Procedure or can I sue straight SQL to perform my edit
against every staging row by using a parameter driven query? I'm thinking a Stored Procedure is the way to go here since I have multiple edits against the database. Can I pass back the result of those edits via a variable and then continue my SSIS Data Flow
by analyzing the result of my Stored Procedure? And how would I do that.
I am new to the SSIS game here so please be kind and as explicit as possible. If you know of any good web sites that walk through how to perform SQL server database edits against external data in SSIS or even a YouTube, please let me know.
Thanks!Thanks for that...but can I do multiple edits in my Stored Procedure Vaibhav and pass back something that I can then utilize in my SSIS? For example...
One and Only one Member Span...so I'd be doing a SELECT COUNT(*) based on my match criteria or handle the count accordingly in my Stored Procedure and passing something back via the OLE DB Command and handling it appropriately in SSIS
Are there "Diabetes" claims...again probably by analyzing a SELECT COUNT(*)
Am I expecting too much from the SSIS...should I be doing all of this in a Stored Procedure? I was hoping to use the SSIS GUI for everything but maybe that's just not possible. Rather use the Stored Procedure to analyze my stged data, edit accordingly, do
data stores accordingly...especially the data anomalies...and then use the SSIS to control navigation
Your thoughts........
Could you maybe clarify the difference between an OLE DB Command on the Data Flow and the Execute SQL Task on the Control Flow...
You can get return values from oledb comand if you want to pipeline.
see this link for more details
http://josef-richberg.squarespace.com/journal/2011/6/30/ssis-oledb-command-and-procedure-output-params.html
The procedure should have an output parameter defined for that
I belive if you've flexibility of using stored procedure you may be better off doing this in execute sql task in control flow. Calling sp in data flow will cause it to execute sp once for each row in dataset whereas in controlflow it will go for set based
processing
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Check If Tables are being used in Stored Procedures & How many times !!
Dear All,
I want to make a script which can give me an answer, that If there is any table , then Whether It's using in any stored procedure or not ? If yes, then what the occurrence in procedures - means if table is "ABC" & Its being used in stored procedure
"XYZ" then i want to know that its using 1 time, 2 time or more in particular procedure ..
Pls Helpjust in-case if you want to get the Cross DB dependency
i have extent Visakh16 code
please use sql_modules to get the full definition of the DB Objects
you can replace stg_table with your decided table, also use dbname.schemaname.tablename if you want to get Cross DB dependency
just came up with this from
link
create table #temp (
dbname sysname,
name sysname,
Occurance int
exec sp_MSforeachdb '
use ?
DECLARE @TableName varchar(100)
SET @TableName = ''stg_table''
insert into #temp
SELECT db_name() ,name,(LEN(definition) - LEN(REPLACE(definition,'' '' + @TableName + '' '','''')))/LEN('' '' + @TableName + '' '') AS Occurance
FROM sys.sql_modules m
INNER JOIN sys.objects o
ON o.object_id = m.object_id
AND o.type = ''p''
WHERE m.definition LIKE ''% '' + @TableName + '' %'''
select *
from #temp
where dbname not in ('master','model','msdb','tempdb')
order by 1,2
Thanks
Saravana Kumar C -
How to execute MYSQL stored procedure using java
Hello friend
I am very new to MYSQL stored procedure how to call external stored procedure , from where i got good tutorials about MYSQL stored procedure and JAVAIf you need help with MYSQL or stored procedures this is not the place. If you need help with JDBC:
http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html -
Need help with BC4J/Struts application using a Stored Procedure
Hi,
I am doing a proof of concept for a new project using JDeveloper, Struts and BC4J. We want to reuse our Business logic that is currently residing in Oracle Stored Procedures. I previously created a BC4J Entity Object based on a stored procedure Using Oracle Stored Procedures but this stored procedure is a bit different in that it returns a ref cursor as one of the paramters. http://radio.weblogs.com/0118231/stories/2003/03/03/gettingAViewObjectsResultRowsFromARefCursor.html
I tried the above method, but I am having some trouble with it. I keep getting the error ORA-01008: not all variables are bound when I test it using the AppModule tester.
Here is the store procedure definition:
CREATE OR REPLACE PACKAGE pprs_test_wrappers IS
TYPE sn_srch_results IS REF CURSOR;
PROCEDURE sn_srch_main_test
(serial_num_in IN OUT VARCHAR2
,serial_coll_cd_in IN OUT NUMBER
,max_rows_allowed IN OUT NUMBER
,total_rows_selected IN OUT NUMBER
,message_cd_out IN OUT VARCHAR2
,query_results OUT sn_srch_results
END pprs_test_wrappers;
And here is my code:
package pprs;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import oracle.jbo.JboException;
import oracle.jbo.domain.Number;
import oracle.jbo.server.DBTransaction;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.server.ViewRowImpl;
import oracle.jbo.server.ViewRowSetImpl;
import oracle.jdbc.driver.OracleCallableStatement;
import oracle.jdbc.driver.OracleTypes;
// --- File generated by Oracle Business Components for Java.
public class LienCheckImpl extends ViewObjectImpl
* This is the PLSQL block that we will execute to retrieve the REF CURSOR
private static final String SQL =
"begin ? := pprs_test_wrappers.sn_srch_main_test(?, ?, ?, ?, ?, ?);end;";
public LienCheckImpl() {}
* Overridden framework method.
* Executed when the framework needs to issue the database query for
* the query collection based on this view object. One view object
* can produce many related result sets, each potentially the result
* of different bind variable values. If the rowset in query is involved
* in a framework-coordinated master/detail viewlink, then the params array
* will contain one or more framework-supplied bind parameters. If there
* are any user-supplied bind parameter values, they will PRECEED the
* framework-supplied bind variable values in the params array, and the
* number of user parameters will be indicated by the value of the
* numUserParams argument.
protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
* If there are where-clause params (for example due to a view link)
* they will be in the 'params' array.
* We assume that if some parameter is present, that it is a Deptno
* value to pass as an argument to the stored procedure.
* NOTE: Due to Bug#2828248 I have to cast to BigDecimal for now,
* ---- but this parameter value should be oracle.jbo.domain.Number type.
String serialNumIn = null;
BigDecimal serialCollCdIn = null;
BigDecimal maxRowsAllowed = null;
BigDecimal totalRowsSelected = null;
String messageCdOut = null;
if (params != null) {
serialNumIn = (String)params[0];
serialCollCdIn = (BigDecimal)params[1];
maxRowsAllowed = (BigDecimal)params[2];
totalRowsSelected = (BigDecimal)params[3];
messageCdOut = (String)params[4];
storeNewResultSet(qc,retrieveRefCursor(qc,serialNumIn,
serialCollCdIn,
maxRowsAllowed,
totalRowsSelected,
messageCdOut));
super.executeQueryForCollection(qc, params, numUserParams);
* Overridden framework method.
* Wipe out all traces of a built-in query for this VO
protected void create() {
getViewDef().setQuery(null);
getViewDef().setSelectClause(null);
setQuery(null);
* Overridden framework method.
* The role of this method is to "fetch", populate, and return a single row
* from the datasource by calling createNewRowForCollection() and populating
* its attributes using populateAttributeForRow().
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
* We ignore the JDBC ResultSet passed by the framework (null anyway) and
* use the resultset that we've stored in the query-collection-private
* user data storage
rs = getResultSet(qc);
* Create a new row to populate
ViewRowImpl r = createNewRowForCollection(qc);
try {
* Populate new row by attribute slot number for current row in Result Set
populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
populateAttributeForRow(r,1, nullOrNewNumber(rs.getBigDecimal(2)));
populateAttributeForRow(r,2, rs.getString(3));
populateAttributeForRow(r,3, rs.getString(4));
populateAttributeForRow(r,4, rs.getString(5));
catch (SQLException s) {
throw new JboException(s);
return r;
* Overridden framework method.
* Return true if the datasource has at least one more record to fetch.
protected boolean hasNextForCollection(Object qc) {
ResultSet rs = getResultSet(qc);
boolean nextOne = false;
try {
nextOne = rs.next();
* When were at the end of the result set, mark the query collection
* as "FetchComplete".
if (!nextOne) {
setFetchCompleteForCollection(qc, true);
* Close the result set, we're done with it
rs.close();
catch (SQLException s) {
throw new JboException(s);
return nextOne;
* Overridden framework method.
* The framework gives us a chance to clean up any resources related
* to the datasource when a query collection is done being used.
protected void releaseUserDataForCollection(Object qc, Object rs) {
* Ignore the ResultSet passed in since we've created our own.
* Fetch the ResultSet from the User-Data context instead
ResultSet userDataRS = getResultSet(qc);
if (userDataRS != null) {
try {
userDataRS.close();
catch (SQLException s) {
/* Ignore */
super.releaseUserDataForCollection(qc, rs);
* Return a JDBC ResultSet representing the REF CURSOR return
* value from our stored package function.
private ResultSet retrieveRefCursor(Object qc,
String serialNum,
BigDecimal serialColCd,
BigDecimal maxRows,
BigDecimal totalRows,
String messageCd ) {
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
* Register the first bind parameter as our return value of type CURSOR
st.registerOutParameter(1,OracleTypes.CURSOR);
* Set the value of the 2nd bind variable to pass id as argument
if (serialNum == null) st.setNull(2,Types.CHAR);
else st.setString(2,serialNum);
if (serialColCd == null) st.setNull(3,Types.NUMERIC);
else st.setBigDecimal(3,serialColCd);
if (maxRows == null) st.setNull(4,Types.NUMERIC);
else st.setBigDecimal(4,maxRows);
if (totalRows == null) st.setNull(5,Types.NUMERIC);
else st.setBigDecimal(5,totalRows);
if (messageCd == null) st.setNull(6,Types.CHAR);
else st.setString(6,messageCd);
st.execute();
ResultSet rs = ((OracleCallableStatement)st).getCursor(1);
* Make this result set use the fetch size from our View Object settings
rs.setFetchSize(getFetchSize());
return rs ;
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Store a new result set in the query-collection-private user-data context
private void storeNewResultSet(Object qc, ResultSet rs) {
ResultSet existingRs = getResultSet(qc);
// If this query collection is getting reused, close out any previous rowset
if (existingRs != null) {
try {existingRs.close();} catch (SQLException s) {}
setUserDataForCollection(qc,rs);
hasNextForCollection(qc); // Prime the pump with the first row.
* Retrieve the result set wrapper from the query-collection user-data
private ResultSet getResultSet(Object qc) {
return (ResultSet)getUserDataForCollection(qc);
* Return either null or a new oracle.jbo.domain.Number
private static oracle.jbo.domain.Number nullOrNewNumber(BigDecimal b) {
try {
return b != null ? new oracle.jbo.domain.Number(b) : null;
catch (SQLException s) { }
return null;
I created the view object in expert mode so there is no entity object. Can someone help? I don't have much time left to finish this.
Also, could I have done this from the Entity object instead of the view object by registering the ref cursor OUT parameter in handleStoredProcInsert()?
Thanks
NatalieI was able to get the input parameter by putting the following in my struts actions class
vo.setWhereClauseParam(0,request.getParameter("row0_SerialNum"));
The full code is:
package mypackage2;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import oracle.jbo.html.BC4JContext;
import oracle.jbo.ViewObject;
import oracle.jbo.html.struts11.BC4JUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LienCheckView1QueryAction extends Action
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
BC4JContext context = BC4JContext.getContext(request);
// Retrieve the view object instance to work with by name
ViewObject vo = context.getApplicationModule().findViewObject("LienCheckView1");
vo.setRangeSize(3);
vo.setIterMode(ViewObject.ITER_MODE_LAST_PAGE_PARTIAL);
// Do any additional VO setup here (e.g. setting bind parameter values)
vo.setWhereClauseParam(0,request.getParameter("row0_SerialNum"));
// default value for serialCollCd 1 is for Motor Vehicles
vo.setWhereClauseParam(1,new oracle.jbo.domain.Number(1));
// Default value for maxRows_allowed
vo.setWhereClauseParam(2,new oracle.jbo.domain.Number(20));
return BC4JUtils.getForwardFromContext(context, mapping);
This doesn't always work properly though. The first time I press the query button, the SerialNum parameter is still null, however if I re-execute the query by pressing the query button again. It will work, and return the rows. I always have to query twice. Also the SerialNum attribute is set to a String in my view object, it is a varchar column in the database, but some serial number I enter give a "Error Message: oracle.jbo.domain.Number ". This happens even though the underlying BC4J is returning values for the query. I also get a "500 Internal Server Error java.lang.ClassCastException: java.lang.String on my View object's code at line 65 which is
if (params.length>1) serialCollCdIn = (BigDecimal)params[1];
This is an input paramter to the oracle stored procedure that defaults to a Number value of 1.
Any idea what the problem is? Here is the full code for my view object:
package mypackage1;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import oracle.jbo.JboException;
import oracle.jbo.domain.Number;
import oracle.jbo.server.DBTransaction;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.server.ViewRowImpl;
import oracle.jbo.server.ViewRowSetImpl;
import oracle.jdbc.driver.OracleCallableStatement;
import oracle.jdbc.driver.OracleTypes;
// --- File generated by Oracle Business Components for Java.
public class LienCheckViewImpl extends ViewObjectImpl
* This is the PLSQL block that we will execute to retrieve the REF CURSOR
private static final String SQL =
"begin pprs_test_wrappers.sn_srch_main_test(?, ?, ?, ?, ?, ?);end;";
private BigDecimal totalRows = null;
private String messageCd = null;
private BigDecimal serialColCd = null;
private BigDecimal maxRows = null;
public LienCheckViewImpl() {}
* Overridden framework method.
* Executed when the framework needs to issue the database query for
* the query collection based on this view object. One view object
* can produce many related result sets, each potentially the result
* of different bind variable values. If the rowset in query is involved
* in a framework-coordinated master/detail viewlink, then the params array
* will contain one or more framework-supplied bind parameters. If there
* are any user-supplied bind parameter values, they will *PRECEED* the
* framework-supplied bind variable values in the params array, and the
* number of user parameters will be indicated by the value of the
* numUserParams argument.
protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
* If there are where-clause params (for example due to a view link)
* they will be in the 'params' array.
* We assume that if some parameter is present, that it is a Deptno
* value to pass as an argument to the stored procedure.
* NOTE: Due to Bug#2828248 I have to cast to BigDecimal for now,
* ---- but this parameter value should be oracle.jbo.domain.Number type.
String serialNumIn = null;
BigDecimal serialCollCdIn = null;
BigDecimal maxRowsAllowed = null;
BigDecimal totalRowsSelected = null;
String messageCdOut = null;
if (params != null) {
if (params.length>0) serialNumIn = (String)params[0];
if (params.length>1) serialCollCdIn = (BigDecimal)params[1];
if (params.length>2) maxRowsAllowed = (BigDecimal)params[2];
storeNewResultSet(qc,retrieveRefCursor(qc,serialNumIn,
serialCollCdIn,
maxRowsAllowed));
super.executeQueryForCollection(qc, params, numUserParams);
* Overridden framework method.
* Wipe out all traces of a built-in query for this VO
protected void create() {
getViewDef().setQuery(null);
getViewDef().setSelectClause(null);
setQuery(null);
* Overridden framework method.
* The role of this method is to "fetch", populate, and return a single row
* from the datasource by calling createNewRowForCollection() and populating
* its attributes using populateAttributeForRow().
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
* We ignore the JDBC ResultSet passed by the framework (null anyway) and
* use the resultset that we've stored in the query-collection-private
* user data storage
rs = getResultSet(qc);
* Create a new row to populate
ViewRowImpl r = createNewRowForCollection(qc);
try {
* Populate new row by attribute slot number for current row in Result Set
//AddedByRegisNum
populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
System.out.println("AddedByRegisNum :" + rs.getBigDecimal(1));
// OrigRegisNum
populateAttributeForRow(r,1, nullOrNewNumber(rs.getBigDecimal(2)));
System.out.println("OrigRegisNum :" + rs.getBigDecimal(2));
// SerialNum
populateAttributeForRow(r,2, rs.getString(3));
System.out.println("SerialNum :" + rs.getString(3));
// SerialNumDesc
populateAttributeForRow(r,3, rs.getString(4));
System.out.println("SerialNumDesc :" + rs.getString(4));
// FlagExactMatch
populateAttributeForRow(r,4, rs.getString(5));
System.out.println("FlagExactMatch :" + rs.getString(5));
// MessageCd
populateAttributeForRow(r,5, messageCd);
// TotalRows
populateAttributeForRow(r,6, totalRows);
catch (SQLException s) {
throw new JboException(s);
return r;
* Overridden framework method.
* Return true if the datasource has at least one more record to fetch.
protected boolean hasNextForCollection(Object qc) {
ResultSet rs = getResultSet(qc);
boolean nextOne = false;
try {
nextOne = rs.next();
* When were at the end of the result set, mark the query collection
* as "FetchComplete".
if (!nextOne) {
setFetchCompleteForCollection(qc, true);
* Close the result set, we're done with it
rs.close();
catch (SQLException s) {
throw new JboException(s);
return nextOne;
* Overridden framework method.
* The framework gives us a chance to clean up any resources related
* to the datasource when a query collection is done being used.
protected void releaseUserDataForCollection(Object qc, Object rs) {
* Ignore the ResultSet passed in since we've created our own.
* Fetch the ResultSet from the User-Data context instead
ResultSet userDataRS = getResultSet(qc);
if (userDataRS != null) {
try {
userDataRS.close();
catch (SQLException s) {
/* Ignore */
super.releaseUserDataForCollection(qc, rs);
* Overridden framework method
* Return the number of rows that would be returned by executing
* the query implied by the datasource. This gives the developer a
* chance to perform a fast count of the rows that would be retrieved
* if all rows were fetched from the database. In the default implementation
* the framework will perform a SELECT COUNT(*) FROM (...) wrapper query
* to let the database return the count. This count might only be an estimate
* depending on how resource-intensive it would be to actually count the rows.
public long getQueryHitCount(ViewRowSetImpl viewRowSet) {
Object[] params = viewRowSet.getParameters(true);
String serialNumIn = (String)params[0];
BigDecimal serialCollCdIn = (BigDecimal)params[1];
BigDecimal maxRowsAllowed = (BigDecimal)params[2];
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
* Register the fourth bind parameter as our return value of type NUMERIC
st.registerOutParameter(4,Types.NUMERIC);
* Set the value of the 3 bind variables to pass as arguments
if (serialNumIn == null) st.setNull(1, Types.CHAR);
else st.setString(1,serialNumIn);
if (serialCollCdIn == null) st.setNull(2,Types.NUMERIC);
else st.setBigDecimal(2,serialCollCdIn);
if (maxRowsAllowed == null) st.setNull(3, Types.NUMERIC);
else st.setBigDecimal(3, maxRowsAllowed);
st.execute();
System.out.println("returning value of :" + st.getLong(4));
return st.getLong(4);
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Return a JDBC ResultSet representing the REF CURSOR return
* value from our stored package function.
private ResultSet retrieveRefCursor(Object qc,
String serialNum,
BigDecimal serialColCd,
BigDecimal maxRows) {
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
* Set the value of the bind variables
System.out.println("SerialNumIn :" + serialNum);
if (serialNum == null) st.setNull(1,Types.CHAR);
else st.setString(1,serialNum);
if (serialColCd == null) st.setNull(2,Types.NUMERIC);
else st.setBigDecimal(2,serialColCd);
if (maxRows == null) st.setNull(3,Types.NUMERIC);
else st.setBigDecimal(3,maxRows);
st.registerOutParameter(1, Types.CHAR); // serialNum
st.registerOutParameter(2, Types.NUMERIC); // serialColCd
st.registerOutParameter(3, Types.NUMERIC); // maxRows
st.registerOutParameter(4, Types.NUMERIC); // totalRows
st.registerOutParameter(5, Types.CHAR); // messageCd
* Register the 6th bind parameter as our return value of type CURSOR
st.registerOutParameter(6,OracleTypes.CURSOR);
st.execute();
ResultSet rs = ((OracleCallableStatement)st).getCursor(6);
serialColCd = st.getBigDecimal(2);
System.out.println("SerialColCd= " + serialColCd);
maxRows = st.getBigDecimal(3);
System.out.println("maxRows= " + maxRows);
totalRows = st.getBigDecimal(4);
System.out.println("totalRows= " + totalRows);
messageCd = st.getString(5);
System.out.println("messageCd= " + messageCd);
* Make this result set use the fetch size from our View Object settings
rs.setFetchSize(getFetchSize());
return rs ;
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Store a new result set in the query-collection-private user-data context
private void storeNewResultSet(Object qc, ResultSet rs) {
ResultSet existingRs = getResultSet(qc);
// If this query collection is getting reused, close out any previous rowset
if (existingRs != null) {
try {existingRs.close();} catch (SQLException s) {}
setUserDataForCollection(qc,rs);
hasNextForCollection(qc); // Prime the pump with the first row.
* Retrieve the result set wrapper from the query-collection user-data
private ResultSet getResultSet(Object qc) {
return (ResultSet)getUserDataForCollection(qc);
* Return either null or a new oracle.jbo.domain.Number
private static oracle.jbo.domain.Number nullOrNewNumber(BigDecimal b) {
try {
return b != null ? new oracle.jbo.domain.Number(b) : null;
catch (SQLException s) { }
return null;
Natalie -
Looking for some help with using Oracle stored procedures in vb2010
First off thank you to whoever lends me a hand with my problem. A little background first I am in a software development class and we are currently building our program using VB (I have no experience in this), and Oracle(currently in a Oracle class so I know how to use Oracle itself just not with VB).
I am using vb2010 express edition if that helps. Currently I have a stored procedure that takes a 4char "ID" that returns a position (ie, salesperson,manager ect). I want to use the position returned to determine what vb form is displayed (this is acting as a login as you dont want a salesperson accessing the accountants page for payroll ect).
Here is the code I have currently on the login page of my VB form
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Public Class Login
Dim conn As New OracleConnection
Private Sub empID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles empID.Click
End Sub
Private Sub LoginBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginBtn.Click
conn.ConnectionString = "User ID = Auto" & _
";Password = ********" & _
";Data Source = XE"
conn.Open()
Dim sq1 As String = "Return_Position" 'name of procedure
Dim cmd As New OracleCommand(sq1, conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New OracleParameter("I_EmpID", OracleDbType.Char, 4)).Value = Emp_ID.Text
Dim dataReader As OracleDataReader = cmd.ExecuteReader
dataReader.Read()
Dim position As New ListBox
position.Items.Add(dataReader.GetString(0)) 'were I am getting an error, I also tried using the dataReader.getstring(0) to store its value in a string but its a no go
If position.FindStringExact("MANAGER") = "MANAGER" Then
Me.Hide()
Dim CallMenu As New Menu()
CallMenu.ShowDialog()
End If
LoginBtn.Enabled = False
End Sub
I have read the oracle.net developer guide for using oracle in vb2010 and have successfully gotten through the document however they never use a stored procedure, since the teacher wants this program to user a layered architecture I cannot directly store sql queries like the document does, thus the reason I want to use stored procedures.
This is getting frustrating getting stuck with this having no background in VB, I could easily do this in c++ using file i/o even through it would be a pain in the rear....Hello,
I am calling Oracle 11g stored procedures from VB.Net 2010. Here is a code sample (based on your code) you should be able to successfully implement in your application.
Please note that you may have to modify your stored procedure to include an OUT parameter (the employee position) if it doesn't have it yet.
Private Sub LoginBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginBtn.Click
Dim sProcedureName As String = "Return_Position" 'name of stored procedure
Dim ORConn as OracleConnection, sConn as String
Dim sPosition as String, sDataSource as String, sSchema as String, sPWD as String
Dim cmd As OracleCommand
'please provide below sDataSource, sSchema and sPWD in order to connect to your Oracle DB
sConn = "Data Source=" & sDataSource & ";User Id=" & sSchema & ";Password=" & sPWD & ";"
ORConn = New OracleConnection(sConn)
ORConn.Open()
cmd = New OracleCommand(sProcedureName, ORConn)
With cmd
.CommandType = Data.CommandType.StoredProcedure
'input parameter in your stored procedure is EmpId
.Parameters.Add("EmpID", OracleDbType.Varchar2).Value = Emp_ID.Text
.Parameters.Item("EmpID").Direction = ParameterDirection.Input
'output parameter in your stored procedure is Emp_Position
.Parameters.Add("Emp_Position", OracleDbType.Varchar2).Direction = ParameterDirection.Output
.Parameters.Item("Emp_Position").Size = 50 'max number of characters for employee position
Try
.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Exit sub
End Try
End With
sPosition = cmd.Parameters.Item("Emp_Position").Value.ToString
'close Oracle command
If Not Cmd Is Nothing Then Cmd.Dispose()
Cmd = Nothing
'close Oracle connection
If Not ORConn Is Nothing Then
If not ORConn.State = 0 Then
ORConn.Close()
End If
ORConn.Dispose()
End If
ORConn = Nothing
If UCase(sPosition) = "MANAGER" Then
Me.Hide()
Dim CallMenu As New Menu()
CallMenu.ShowDialog()
End If
LoginBtn.Enabled = False
End Sub
If you need further assistance with the code, please let me know.
Regards,
M. R.
Maybe you are looking for
-
Using Boot Camp on External Drive
Can I use Boot Camp to install Windows on an external drive, instead of partitioning the main internal one? I have an eSATA drive so I know Windows Vista will work on the external drive.
-
FB and FB Messanger appls - unable to log in!!
Dear All, pls advise what to do...? I always used FB apps on my I phone FB and FB messanger but recently started having problem with getting the messages and the bar was appearing with "unable to connect" I logged out of both of them and now can't lo
-
Lion... Seems to be slowing my iMac Down? Tips and Tricks?
Hey everyone, this is my first post so go easy on me I installed lion as soon as it came out. I'm really impressed so far, loving the new features (except my inverted mouse, that had to be changed pretty sharpish). My only problem is, is that it seem
-
Updated IPMP - do I need to reboot?
Hello we have a live server currently running IPMP across two NIC's. I have updated the /etc/hostname<nic> file and I want to now get the IP's associated with the primary NIC. Do I have to reboot the server to 'activate' the new IP's? or is there an
-
Dear all, Can anyone help me with this: I have a text document in Buzzword that produces errors when trying to export it: I can export it to pdf without any problems but When I try to export it to DOC, RTF, ODF etc., the resulting files cannot be ope