Stored Procedure Object Result
Hi everyone! this is my question, i'm new in this world of BPEL, i dont know so much of databases.
I have a process with a partner Link to a Database Stored Procedure, this stored procedure should return a dataset/recordset/rowset, i dont know what kind of object it will return, it should be like a cimple query resultset! then i have an invoke activity with the input and the output variables, this output variable (the procedure result) i need to show it in a jsp page of workflow creation, i created the workflow and it create the jsp for interaction with user, i will modify the jsp to show the result of the procedure, how can i do that? what kind of object is the output varible and how can i to loop with it to show the table result?
thnx in advance all of you!
Best regards
Your procedure could perhaps return a pl/sql table type.
The DB adapter wizard will create the schema's for it.
You can then after you have these schema's create a workflow task and use the output schema element that represents the table as a parameter for your workflow task.
The jsp will then automatically be generated for this structure.
HTH, Marc
Similar Messages
-
Calling stored procedure returning result set
Hi all,
i know this issue is discussed quite often. I did not find an answer in the forums, not in the manual and even not in the examples for stored procedure.
So i try it here once more :)
Description:
GET_SKS:
The GET_SKS procedure is used to generate a number of surrogate keys. It has one input parameter NUM_SKS_IN that specifies the number of keys to generate. The generated keys are returned as a result set.
So i tried:
CallableStatemant sproc_stmt = lsession.connection().prepareCall("{ call Get_SKS(?,?)}");
sproc_stmt.setInt(2,1);
sproc_stmt.registerOutParameter(1,OracleTypes.CURSOR);
sproc_stmt.execute();
ResultSet sproc_result = (ResultSet) sproc_stmt.getObject(1);
I got the exception:
java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'GET_SKS'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Thanks for help! This is really getting frustrating...
Regards,
akHi there,
i could speak to our one of our admins. This is what he gave me:
CREATE OR REPLACE PROCEDURE "TCSDBOWNER"."GET_SKS"
(num_sks_in IN INTEGER,
sk_out OUT SYS_INFO.SYS_INFO_SK%TYPE)
AS
/*+
|| Procedure - GET_SKS - Oracle
||
|| Description:
|| This procedure is used to get one or more primary keys for tables with
|| surrogate keys as the primary key. This number is unique across all
|| tables and installations for a given client.
||
|| Parameters:
|| num_sks_in - INTEGER: number of surrogate keys to return
|| sk_out - sk_subtype: first key in the sequence of requested keys
||
|| History:
|| 08/30/01,dcs: Created
CURSOR request_cur IS
select DBMS_LOCK.REQUEST(170333184) from dual;
CURSOR release_cur IS
select DBMS_LOCK.RELEASE(170333184) from dual;
CURSOR dual_sk_cur IS
select SEQ_SK.NEXTVAL SK
from DUAL;
v_base_offset SYS_INFO.BASE_OFFSET%TYPE;
v_sk SYS_INFO.SYS_INFO_SK%TYPE;
v_sqlstring VARCHAR2(1000);
v_cursor_handle INTEGER;
v_return INTEGER;
BEGIN
IF num_sks_in < 1 THEN
TCS_EXC.RAISE_ERROR(TCS_EXC.num_sks_in_lt_1);
END IF;
OPEN request_cur;
FETCH request_cur INTO v_return;
CLOSE request_cur;
IF v_return <> 0 AND v_return <> 4 THEN
TCS_EXC.RAISE_ERROR(TCS_EXC.sk_gen_lock_failed);
END IF;
v_cursor_handle := DBMS_SQL.OPEN_CURSOR;
v_sqlstring := 'ALTER SEQUENCE SEQ_SK INCREMENT BY '|| TO_CHAR(num_sks_in);
DBMS_SQL.PARSE(v_cursor_handle, v_sqlstring, DBMS_SQL.V7);
v_return := DBMS_SQL.EXECUTE(v_cursor_handle);
DBMS_SQL.CLOSE_CURSOR(v_cursor_handle);
GET_BASE_OFFSET(v_base_offset);
OPEN dual_sk_cur;
FETCH dual_sk_cur INTO v_sk;
CLOSE dual_sk_cur;
sk_out := (v_base_offset * 10000000000) + v_sk - num_sks_in + 1;
v_cursor_handle := DBMS_SQL.OPEN_CURSOR;
v_sqlstring := 'ALTER SEQUENCE SEQ_SK INCREMENT BY 1';
DBMS_SQL.PARSE(v_cursor_handle, v_sqlstring, DBMS_SQL.V7);
v_return := DBMS_SQL.EXECUTE(v_cursor_handle);
DBMS_SQL.CLOSE_CURSOR(v_cursor_handle);
OPEN release_cur;
FETCH release_cur INTO v_return;
CLOSE release_cur;
IF v_return <> 0 THEN
TCS_EXC.RAISE_ERROR(TCS_EXC.sk_gen_lock_failed);
END IF;
END GET_SKS; Ok, i tried with that but even not succeded yet. Can anybody help me to code that into a java call?
Regards,
ak -
Is it possible to make stored procedure which results with only one row?
Greetings community,
I’m making the app in .NET, and I don’t really have the problem to get the result, but through watching videos I’ve realized that using LINQ isn’t always the best way of doing things, because it requires pulling too much data through the
network to do some LINQ over it. There’s also the issue of security, so I was advised to use stored procedures and functions on SQL server to accomplish what I need without disturbing client machines too much.
I’m absolute beginner in TSQL, so I need your help. I need to extract last order of particular customer and I wonder if that could be accomplished. To make things simple, let’s imagine that my orders table has only these three columns:
OrderID (int, primary key, identity incremented), CustomerID (int), and DateOfOrder(datetime). I need a procedure that would take CustomerID as parameter, and return one single row which represent the last order of that customer.
I would also be very grateful to see the extended procedure that would take LastCount additional parameter and return several rows which would represent last several orders of that customer.
Last thing, if it’s not too much already, I would very appreciate some link to educational videos about SQL server for beginners. There were great videos on msdev.com, but this web address doesn’t exist anymore.There are many tutorials on MSDN with Linq including SQL Server Express. A good start is this here:
http://msdn.microsoft.com/en-us/library/bb399349(v=vs.110).aspx
-Jens
Jens K. Suessmeyer http://blogs.msdn.com/Jenss -
Customize the stored procedure migrating of MWB
Hi, All,
Is there anybody know how much customize we can have for using
the MWB when migrate stored procedure? For sample I have a SQL
Server 6.5 strored procedure like following:
/******************* SQL Server 6.5 sp *************/
CREATE PROCEDURE sp_SelectUsers
AS
select
tbl_Sp_users.ID, UserName, Password, ExpiresOn,
PwdChangedDate, tbl_Sp_UserGrps.name
from
tbl_Sp_users, tbl_Sp_UserGrps
where
GroupID = tbl_Sp_UserGrps.id
order by username
/******************* end ***************************/
After I migrate it to Oracle 8 with MWB, I got following object,
one Pkg and one Procedure in Oracle db, like following:
/****************** Oracle Pkg **********************/
CREATE OR REPLACE PROCEDURE sp_SelectUsers(
RC1 IN OUT sp_SelectUsersPkg.RCT1)
AS
StoO_selcnt INTEGER;
StoO_error INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
StoO_sqlstatus INTEGER;
BEGIN
OPEN RC1 FOR
SELECT tbl_Sp_users.ID, UserName, Password,
ExpiresOn, PwdChangedDate, tbl_Sp_UserGrps.name FROM
tbl_Sp_users, tbl_Sp_UserGrps
WHERE GroupID = tbl_Sp_UserGrps.id
ORDER BY username ;
END sp_SelectUsers;
/******************* Oracle Procedure ****************/
PROCEDURE sp_SelectUsers(
RC1 IN OUT sp_SelectUsersPkg.RCT1)
AS
StoO_selcnt INTEGER;
StoO_error INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
StoO_sqlstatus INTEGER;
BEGIN
OPEN RC1 FOR
SELECT tbl_Sp_users.ID, UserName, Password,
ExpiresOn, PwdChangedDate, tbl_Sp_UserGrps.name FROM
tbl_Sp_users, tbl_Sp_UserGrps
WHERE GroupID = tbl_Sp_UserGrps.id
ORDER BY username ;
END sp_SelectUsers;
/******************* end *****************************/
As our client use RDO as access method, there is no way we can
use this migrated SP in RDO and return resultset. We need
convert this SP to following to be able to use RDO to get
resultset back in client:
/******************* need convert to *********************/
create or replace package sp_selectUsersPkg
as
cursor c1
is select tbl_Sp_users.ID, UserName, Password,ExpiresOn,
PwdChangedDate, tbl_Sp_UserGrps.name
from tbl_Sp_users, tbl_Sp_UserGrps
where GroupID = tbl_Sp_UserGrps.id
order by username;
type UsersCur
is ref cursor return c1%ROWTYPE;
procedure sp_selectUsers(UserCursor in out UsersCur );
END;
create or replace package body sp_selectUsersPkg
as
procedure sp_selectUsers(UserCursor in out UsersCur )
is
begin
open UserCursor for
select tbl_Sp_users.ID, UserName,
password, ExpiresOn,
PwdChangedDate, tbl_Sp_UserGrps.name
from tbl_Sp_users, tbl_Sp_UserGrps
where GroupID = tbl_Sp_UserGrps.id
order by username;
end;
end;
/******************* end *********************************/
Is there any idea how we can do this? I hope we don't need do
this manually.
Thank you very much for any help!
Jing
nullI have done a rough example of using VB6, RDO and ODBC
drivers, which may be of help to some workbench users:
Calling Oracle 8.1.5 stored procedures with ref cursors using RDO
and Visual
Basic.
Ver 0.1 [email protected]
Summary
Versions Used
Table
Code
With Explicit Ref Cursor Argument
Without Explicit Ref Cursor Argument
Actions
Summary
This gives a comparison of the connectivity between Visual Basic
and Oracle,
with both the intersolve and oracle drivers. The Oracle odbc
still has
significant
shortcomings in comparison to the intersolve/Merant driver.
Versions Used
Visiual Basic 6.0, Oracle odbc driver 8.1.5.3.0, Oracle Database
8.1.5.0.0 on
NT, intersolve/Merant 3.5 32 bit Oracle driver.
Table
html table replaced by rough results in ascii form
test case with named result set cursor variable:
sSQL = "{CALL reftest.GetEmpData(?)}"
oracle 8.1.5.3
could not find item indicated by text, known vb6.0 bug?, thinks
reftest is user
intersolve
could not find item indicated by text, known vb6.0 bug?, thinks
reftest is user
sSQL = "begin reftest.GetEmpData(?); end;"
oracle 8.1.5.3
run time error 40002 driver not capable
intersolve
ok
sSQL = "{CALL GetEmpData(?)}"
oracle 8.1.5.3
run time error 40002 driver not capable
intersolve
could not find item indicated by text,?(similar to bug above?)
at qd.rdoParameters(0).Type = rdTypeVARCHAR
sSQL = "begin GetEmpData(?); end;"
oracle 8.1.5.3
run time error 40002 driver not capable
intersolve
ok
procedure with result set last argument wanting to be simulated
as not
argument result set
strsql = "{CALL BYROYALTYPkg.byroyalty()}"
oracle 8.1.5.3
ok
intersolve
ok
strsql = "begin BYROYALTYPkg.byroyalty(); end;"
oracle 8.1.5.3
wrong number of arguments in byroyalty
intersolve
ok
strsql = "{CALL byroyalty() }"
oracle 8.1.5.3
wrong number of arguments
intersolve
ok
strsql = "begin byroyalty(); end;"
oracle 8.1.5.3
wrong number of arguments
intersolve
ok
Code
With Explicit Ref Cursor Argument
Oracle Stored Procedures and Packages
(on scott/tiger account)
create or replace package reftest as
cursor c1 is select ename from emp;
type empCur is ref cursor return c1%ROWTYPE;
procedure GetEmpData(EmpCursor in out empCur );
END;
create or replace package body reftest as
procedure GetEmpData(EmpCursor in out empCur) is
begin
open EmpCursor for select ename from emp;
end;
end;
create or replace procedure GetEmpData(EmpCursor in out
reftest.empCur)
is
begin
open EmpCursor for select ename from emp;
end;
VB code
Private Sub Command1_Click()
Dim cn As New rdoConnection
Dim qd As rdoQuery
Dim rs As rdoResultset
Dim cl As rdoColumn
Static Number As Integer
Number = 0
cn.Connect = "uid=scott; pwd=tiger; DSN=Oracle;"
'enable the MS Cursor library
cn.CursorDriver = rdUseOdbc
'Make the connection
cn.EstablishConnection rdDriverPrompt
sSQL = "BEGIN GetEmpData(?); END;"
Set qd = cn.CreateQuery("", sSQL)
qd.rdoParameters(0).Type = rdTypeVARCHAR
'Dynamic or Keyset is meaningless here
Set rs = qd.OpenResultset(rdOpenStatic)
'all the output is routed to the debug window
Debug.Print ".....Starting Result Sets....."
Do
Debug.Print
Debug.Print
Do Until rs.EOF
For Each cl In rs.rdoColumns
If IsNull(cl.Value) Then
Debug.Print " "; cl.Name; "NULL"; 'Error
trap for
null fields
Else
Debug.Print " "; cl.Name; " ";
cl.Value;
End If
Next
Debug.Print
rs.MoveNext
Loop
Loop While rs.MoreResults
cn.Close
End Sub
Without Explicit Ref Cursor Argument
Oracle Stored Procedures and Packages
(requires table:
SQL> desc MTG_VERSION
Name
Null?
Type
VERSION
NUMBER
create or replace PACKAGE BYROYALTYPkg AS
TYPE RT1 IS RECORD (
val MTG_VERSION.VERSION%TYPE
TYPE RCT1 IS REF CURSOR RETURN RT1;
PROCEDURE byroyalty(
RC1 IN OUT BYROYALTYPkg.RCT1);
END;
create or replace PACKAGE BODY BYROYALTYPkg AS
PROCEDURE byroyalty(
RC1 IN OUT BYROYALTYPkg.RCT1)
AS
StoO_selcnt INTEGER;
StoO_error INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
StoO_sqlstatus INTEGER;
BEGIN
OPEN RC1 FOR
SELECT VERSION FROM MTG_VERSION;
END byroyalty;
END;
create or replace PROCEDURE byroyalty(
RC1 IN OUT BYROYALTYPkg.RCT1)
AS
StoO_selcnt INTEGER;
StoO_error INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
StoO_sqlstatus INTEGER;
BEGIN
OPEN RC1 FOR
SELECT VERSION FROM MTG_VERSION;
END byroyalty;
VB code
Dim env1 As rdoEnvironment
Dim conn1 As rdoConnection
Dim strsql As String
Dim ps As rdoPreparedStatement
Dim rs As rdoResultset
Private Sub Command1_Click()
strsql = "begin byroyalty(); end;"
'in oracle odbc driver uses refcusor argument to
get result set
Set ps = conn1.CreatePreparedStatement("PsTest",
strsql)
Set rs = ps.OpenResultset(rdOpenStatic)
Text1 = rs!Version
rs.Close
End Sub
Private Sub Form_Load()
rdoEngine.rdoDefaultCursorDriver = rdUseOdbc
Set env1 = rdoEngine.rdoCreateEnvironment(" ", " ", " ")
strsql = "ODBC;DSN=tot4;UID=test;PWD=test;"
Set conn1 = env1.OpenConnection(" ", rdDriverPrompt, False,
strsql)
conn1.QueryTimeout = 3600
End Sub
Actions
Encourage odbc to allow result sets , via the odbc processed
extra
argument, outside of packages.
Document the current situation, and keep users informed of
developments.
Turloch
Oracle Migration Workbench Team
Turloch O'Tierney (guest) wrote:
: Jing,
: Note that there is an example in the FAQ where the intersolve
: driver was used so no change was required in the client code.
The
: intersolve driver optionally converts the extra argument into a
: result set. With the Oracle ODBC driver the argument needs to
be
: explicitly handled.
: Is there a problem with RDO and the 8.0.5 ODBC driver handling
: package references?
: Turloch
: Turloch O'Tierney
: Oracle,
: Migration and Technology Group.
: FAQ entry reproduced:
: How are result sets/dynasets returned to the calling program?
: The Oracle Migration Workbench parser adds an extra
argument
: of type REF CURSOR for result
: sets/dynasets. This type is understood and can be
: manipulated by both PL/SQL and Oracle JDBC. Oracle8
: release 8.0.5 ODBC drivers support REF CURSORs which means
: that the additional argument must be
: explicitly handled by the application, and the client
: application code must be changed. However, some
: third-party vendors such as Intersolv supply ODBC drivers
: for Oracle that support REF CURSORs and can, in
: addition, implicitly make use of REF CURSORs for using
: result sets/dynasets. Therefore, no change is
: required in the client application code. This is
illustrated
: in the following examples of an MS SQL Server
: stored procedure and its equivalent Oracle package and
: stored procedure as generated by the Oracle
: Migration Workbench parser.
: MS SQL Server Stored Procedure
: CREATE PROCEDURE byroyalty
: AS
: select au_id from titleauthor
: GO
: Oracle8i Package and Stored Procedure
: PACKAGE BYROYALTYPkg AS
: TYPE RT1 IS RECORD (
: au_id titleauthor.au_id%TYPE
: TYPE RCT1 IS REF CURSOR RETURN RT1;
: END;
: PROCEDURE byroyalty(
: RC1 IN OUT byroyaltyPkg.RCT1)
: AS
: StoO_selcnt INTEGER;
: StoO_error INTEGER;
: StoO_rowcnt INTEGER;
: StoO_errmsg VARCHAR2(255);
: StoO_sqlstatus INTEGER;
: BEGIN
: OPEN RC1 FOR
: SELECT au_id FROM titleauthor;
: END byroyalty;
: The following example illustrates the typical ODBC code
used
: by Intersolv to call the above MS SQL Server
: stored procedure. This code also works for the above
: Oracle8i package and stored procedure. Note that error
: handling must be added in a real application:
: SQLPrepare(...,'{call byroyalty()}',...)
: SQLExecute()
: SQLBindCol()
: SQLFetch()
: Comments:
: SQLPrepare(...,'{call byroyalty()}',...) is the ODBC SQL
: syntax used to execute stored procedures.
: SQLExecute()executes the stored procedure.
: SQLBindCol()assigns storage for result column 1 in the
: result set (au_id).
: SQLFetch() fetches the first record from the result set
: generated by the stored procedure.
: The following examples illustrate how to call the above MS
: SQL Server stored procedure with result
: sets/dynasets in Visual Basic using DAO and RDO on top of
: ODBC. This code works for Oracle8i packages
: and stored procedures if you use an Intersolv ODBC driver
to
: understand Oracle REF CURSORs.
: DAO
: Private Sub Command2_Click()
: Dim sSql As String
: sSql = "{call byroyalty()}"
: 'In Oracle ODBC driver use refcusor argument to get
: result set
: Set rCustomers = dbsServer.OpenRecordset(sSql,
: dbOpenDynamic)
: Text4 = rCustomers.Fields(0)
: theend:
: End Sub
: Please note, this example assumes that a DAO connection
has
: been set up already.
: RDO
: Private Sub Command1_Click()
: StrSql = "{call byroyalty}"
: 'in oracle odbc driver uses refcusor argument to get
: result set
: Set Ps = connx1.CreatePreparedStatement("PsTest",
: StrSql)
: Set Rs = Ps.OpenResultSet(rdOpenStatic)
: Text3 = Rs!au_id
: Rs.Close
: End Sub
: Please note, this example assumes that an RDO connection
has
: been set up already.
: Jing Zhang (guest) wrote:
: : Hi, All,
: : Is there anybody know how much customize we can have for
using
: : the MWB when migrate stored procedure? For sample I have a
SQL
: : Server 6.5 strored procedure like following:
: : /******************* SQL Server 6.5 sp *************/
: : CREATE PROCEDURE sp_SelectUsers
: : AS
: : select
: : tbl_Sp_users.ID, UserName, Password, ExpiresOn,
: : PwdChangedDate, tbl_Sp_UserGrps.name
: : from
: : tbl_Sp_users, tbl_Sp_UserGrps
: : where
: : GroupID = tbl_Sp_UserGrps.id
: : order by username
: : /******************* end ***************************/
: : After I migrate it to Oracle 8 with MWB, I got following
: object,
: : one Pkg and one Procedure in Oracle db, like following:
: : /****************** Oracle Pkg **********************/
: : CREATE OR REPLACE PROCEDURE sp_SelectUsers(
: : RC1 IN OUT sp_SelectUsersPkg.RCT1)
: : AS
: : StoO_selcnt INTEGER;
: : StoO_error INTEGER;
: : StoO_rowcnt INTEGER;
: : StoO_errmsg VARCHAR2(255);
: : StoO_sqlstatus INTEGER;
: : BEGIN
: : OPEN RC1 FOR
: : SELECT tbl_Sp_users.ID, UserName, Password,
: : ExpiresOn, PwdChangedDate, tbl_Sp_UserGrps.name FROM
: : tbl_Sp_users, tbl_Sp_UserGrps
: : WHERE GroupID = tbl_Sp_UserGrps.id
: : ORDER BY username ;
: : END sp_SelectUsers;
: : /******************* Oracle Procedure ****************/
: : PROCEDURE sp_SelectUsers(
: : RC1 IN OUT sp_SelectUsersPkg.RCT1)
: : AS
: : StoO_selcnt INTEGER;
: : StoO_error INTEGER;
: : StoO_rowcnt INTEGER;
: : StoO_errmsg VARCHAR2(255);
: : StoO_sqlstatus INTEGER;
: : BEGIN
: : OPEN RC1 FOR
: : SELECT tbl_Sp_users.ID, UserName, Password,
: : ExpiresOn, PwdChangedDate, tbl_Sp_UserGrps.name FROM
: : tbl_Sp_users, tbl_Sp_UserGrps
: : WHERE GroupID = tbl_Sp_UserGrps.id
: : ORDER BY username ;
: : END sp_SelectUsers;
: : /******************* end *****************************/
: : As our client use RDO as access method, there is no way we
can
: : use this migrated SP in RDO and return resultset. We need
: : convert this SP to following to be able to use RDO to get
: : resultset back in client:
: : /******************* need convert to *********************/
: : create or replace package sp_selectUsersPkg
: : as
: : cursor c1
: : is select tbl_Sp_users.ID, UserName, Password,ExpiresOn,
: : PwdChangedDate, tbl_Sp_UserGrps.name
: : from tbl_Sp_users, tbl_Sp_UserGrps
: : where GroupID = tbl_Sp_UserGrps.id
: : order by username;
: : type UsersCur
: : is ref cursor return c1%ROWTYPE;
: : procedure sp_selectUsers(UserCursor in out UsersCur );
: : END;
: : create or replace package body sp_selectUsersPkg
: : as
: : procedure sp_selectUsers(UserCursor in out UsersCur )
: : is
: : begin
: : open UserCursor for
: : select tbl_Sp_users.ID, UserName,
: : password, ExpiresOn,
: : PwdChangedDate, tbl_Sp_UserGrps.name
: : from tbl_Sp_users, tbl_Sp_UserGrps
: : where GroupID = tbl_Sp_UserGrps.id
: : order by username;
: : end;
: : end;
: : /******************* end *********************************/
: : Is there any idea how we can do this? I hope we don't need do
: : this manually.
: : Thank you very much for any help!
: : Jing
Oracle Technology Network
http://technet.oracle.com
null -
Using OracleCommand to execute a Stored Procedure
I have a problem calling a stored procedure that results in the error: ORA-00936: missing expression. This is in an application running as a service.
I have searched through Google and I have not found a solution.
I have a variable that instantiates a new OracleCommand called sqlCmd.
Then, I set properties on it:
sqlCmd.CommandText = "sp_myProc"
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Connection = DBConnection 'OracleConnection object
Next, I add the parameters:
sqlCmd.Parameters.Add("RETURN_VALUE", OracleDbType.Int32)
sqlCmd.Parameters("RETURN_VALUE").Direction = ParameterDirection.ReturnValue
sqlCmd.Parameters.Add("TypeId", OracleDbType.Byte).Value = TranslateTypes(Type)
sqlCmd.Parameters.Add("Status", OracleDbType.Byte).Value = Status
sqlCmd.Parameters.Add("Name", OracleDbType.Varchar2).Value = Name
Finally, I set the connection string and open the connection and execute the statement:
retVal = sqlCmd.ExecuteNonQuery()
This results in the ORA-00936: missing expression error.
What am I doing incorrectly?Did you set BindByName = true on the command object? I really don't understand why this isn't the default.
Eric -
How to use Stored Procedures in JSF Components
Please tell me how to map the result of a strored procedure stored in a database to a component in JSF page
Create a method in a managed bean, e.g. getMyStoredProcResult(), and refer to this method in a binding, e.g. #{theBean.myStoredProcResult}.
In the method, you can do whatever's necessary to obtain the stored procedure's result. -
Error Stored Procedure Upgrading database from SBO 2007A PL42 to SBO 8.8
Hi,
When executing the SBO 8.8 PL00 upgrade procedure for databases for an "old" database 2007A PL 42, upgrtade stops whith an error concerning a missing stored procedure "_TmSp_CorrectWrongDocLineNumberInOINMForIPF which is not found".
The error details says that it occurs on "Stock Updates" step (just after Checks for Payment) and log file gives the following message here after.
Does anybody have an idea how to upgrade the 2007A database ?
Thanks
Error message in log :
Upgrade Error Technical Failed to call Stored Procedure TmSpCorrectWrongDocLineNumberInOINMForIPF
Edited by: Michel Diepart on Oct 24, 2009 10:55 PMHi Paul,
Thanks for your prompt response on a saturday and so late in the evening
Concerning the Stored Procedure, I would like to delete it but ... it doesn't exist and that's the problem...
No such procedure in my database (programmability / Stored procedurefolder in SQL).
When searching on the forum about this stored procedure, no result.
Does this stored procedure have a link with something regarding adjustment in stock ?
"Stock updates" : what table is it in SAP B1 ? If necessary I could save the table, create a sql query to re-create it after delete and try to restart the upgrade procedure but I don't know what is the related table...
I will also try with another 2007A PL 42 database to see if it works.
Do you know if anybody has already try to upgrade a 2007 PL42 dabase to SBO 8.8 ?
Best regards -
How to use stored procedure with many return results and variable with perl
Hi everybody,
i´m writtting now a Perl programm, wich use a oracle stored procedure with more than 1 result and 1 variable(I have to return 2 variable fpr each result). I don´t now how I can get it.I already search the web but I didn´t find.
My example:
PROCEDURE get_projects_and_sub_projects (
v_project_id IN INTEGER,
v_project_c_id OUT INTEGER,
v_project_id_find OUT VARCHAR2
IS
BEGIN
SELECT c_id, proj_id
INTO
v_project_c_id,
v_project_id_find
FROM t_projet
WHERE t_projet .ksa_pro_art_kbz = 'KU'
AND t_projet.proj_id LIKE v_project_id || '%';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_project_c_id := NULL;
v_project_id_find := NULL;
WHEN OTHERS
THEN
kmessages.error (NULL,
'get_projects_and_sub_projects',
'Project-Name: ' || v_project_id,
'Errornumber: '
|| SQLCODE
|| ' Error: '
|| SQLERRM,
TRUE,
TRUE
raise_application_error (-20001,
'Error '
|| SQLCODE
|| ' get_projects_and_sub_projects: '
|| SQLERRM,
TRUE
END get_projects_and_sub_projects;
in Perl Program:
sub get_projects_unterprojects_name($$){
my ($db_handle, $proj_name_id) = @_; #$db_handle ist the DB Connection return value
my $db_proj_c_id;
my $db_proj_name;
eval{ my $csr = $db_handle->prepare(q{
BEGIN
pro_doc_ber.get_projects_and_sub_projects(:proj_name_id, :db_proj_c_id, :db_proj_name);
END;
# parameter value
$csr->bind_param(":proj_name_id", $proj_name_id);
# return values
$csr->bind_param_inout(":db_proj_c_id", \$db_proj_c_id, 11);
$csr->bind_param_inout(":db_proj_name", \$db_proj_name, 20);
$csr->execute(); };
But this didn´t work. Could somebody give me some idea?
Thank you
FelxSome additional info would probably be helpful.
What is your programming enviironment? Java?
In any case I suspect that you will need to use the OCI to deal with specific Oracle types such as user defined object types -- thats not standard ANSI SQL.
In Java I believe you need to use OPAQUE, there are some examples out there. I'm mostly a PL/SQL developer with some Java expereince so others here are more qualifed to answer your question more directly. -
Newbie question on how to return java objects from java stored procedures
Hi,
As you may guess, i'm new to this.
I have a stored procedure that does some calculations and creates a list of java objects as the result of the query.
How would I return the list from the database to the client application?
Would I have to create an Oracle type that maps to the java object?
Please help.
JagHi Jag,
Your question is very vague (to me). Perhaps you could post what you have done so far? Have you tried looking through the Sample Code page of the Technet Web site, or tried searching the Ask tom Web site, or MetaLink?
Good Luck,
Avi. -
Invoking stored procedure that returns array(oracle object type) as output
Hi,
We have stored procedures which returns arrays(oracle type) as an output, can anyone shed some light on how to map those arrays using JPA annotations? I tried using jdbcTypeName but i was getting wrong type or argument error, your help is very much appreciated. Below is the code snippet.
JPA Class:
import java.io.Serializable;
import java.sql.Array;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.eclipse.persistence.annotations.Direction;
import org.eclipse.persistence.annotations.NamedStoredProcedureQuery;
import org.eclipse.persistence.annotations.StoredProcedureParameter;
* The persistent class for the MessagePublish database table.
@Entity
@NamedStoredProcedureQuery(name="GetTeamMembersDetails",
procedureName="team_emp_maintenance_pkg.get_user_team_roles",
resultClass=TeamMembersDetails.class,
returnsResultSet=true,
parameters={
@StoredProcedureParameter(queryParameter="userId",name="I_USER_ID",direction=Direction.IN,type=Long.class),
@StoredProcedureParameter(queryParameter="employeeId",name="I_EMPLOYEEID",direction=Direction.IN,type=Long.class),
@StoredProcedureParameter(queryParameter="TEAMMEMBERSDETAILSOT",name="O_TEAM_ROLES",direction=Direction.OUT,jdbcTypeName="OBJ_TEAM_ROLES"),
@StoredProcedureParameter(queryParameter="debugMode",name="I_DEBUGMODE",direction=Direction.IN,type=Long.class)
public class TeamMembersDetails implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private long userId;
private List<TeamMembersDetailsOT> teamMembersDetailsOT;
public void setTeamMembersDetailsOT(List<TeamMembersDetailsOT> teamMembersDetailsOT) {
this.teamMembersDetailsOT = teamMembersDetailsOT;
public List<TeamMembersDetailsOT> getTeamMembersDetailsOT() {
return teamMembersDetailsOT;
Procedure
PROCEDURE get_user_team_roles (
i_user_id IN ue_user.user_id%TYPE
, o_team_roles OUT OBJ_TEAM_ROLES_ARRAY
, i_debugmode IN NUMBER :=0)
AS
OBJ_TEAM_ROLES_ARRAY contains create or replace TYPE OBJ_TEAM_ROLES_ARRAY AS TABLE OF OBJ_TEAM_ROLES;
TeamMembersDetailsOT contains the same attributes defined in the OBJ_TEAM_ROLES.A few things.
You are not using a JDBC Array type in your procedure, you are using a PLSQL TABLE type. An Array type would be a VARRAY in Oracle. EclipseLink supports both VARRAY and TABLE types, but TABLE types are more complex as Oracle JDBC does not support them, they must be wrapped in a corresponding VARRAY type. I assume your OBJ_TEAM_ROLES is also not an OBJECT TYPE but a PLSQL RECORD type, this has the same issue.
Your procedure does not return a result set, so "returnsResultSet=true" should be "returnsResultSet=false".
In general I would recommend you change your stored procedure to just return a select from a table using an OUT CURSOR, that is the easiest way to return data from an Oracle stored procedure.
If you must use the PLSQL types, then you will need to create wrapper VARRAY and OBJECT TYPEs. In EclipseLink you must use a PLSQLStoredProcedureCall to access these using the code API, there is not annotation support. Or you could create your own wrapper stored procedure that converts the PLSQL types to OBJECT TYPEs, and call the wrapper stored procedure.
To map to Oracle VARRAY and OBJECT TYPEs the JDBC Array and Struct types are used, these are supported using EclipseLink ObjectRelationalDataTypeDescriptor and mappings. These must be defined through the code API, as there is currently no annotation support.
I could not find any good examples or doc on this, your best source of example is the EclipseLink test cases in SVN,
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/plsql/
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/customsqlstoredprocedures/
James : http://www.eclipselink.org -
I have a stored procedure that dynamically creates a pivot query. The procedure works and returns the correct data. Now I have a requirement to show this data in reporting system that can only pull from a table or view. Since you can not
create a dynamic query in a view I tried to do a select from using openquery.
Example 'Select * from OpenQuery([MyServername], 'Exec Instance.Schema.StoredProcedure')
I get the error back "the linked server indicates the object has no columns". I assume this is because of the first select statement that is stuffing the variable with column names.
CODE FROM PROCEDURE
Alter PROCEDURE [dbo].[Procedure1]
AS
BEGIN
SET NOCOUNT ON
Declare @cols nvarchar(2000),
@Tcols nvarchar(2000),
@Sql nvarchar (max)
select @cols = stuff ((
Select distinct '], ['+ModelName + ' ' + CombustorName
from CombustorFuel cf
join Model m on cf.modelid = m.modelid
join Combustors cb on cf.CombustorID = cb.CombustorID
where cf.CombustorID > 0
for XML Path('')
),1,2,'')+']'
Set @Tcols = replace(@Cols, ']', '] int')
--Print @Tcols
--Print @Cols
Set @Sql = 'Select GasLiquid, FuelType, '+ @Cols +'
from
Select GasLiquid, FuelType, ModelName+ '' '' +CombustorName ModelCombustor, CombFuelStatus+''- ''+CombFuelNote CombFuelStatusNote
from Frames f
join Family fa on f.Frameid = fa.frameid
join Model m on fa.FamilyID = m.FamilyID
join CombustorFuel cf on m.Modelid = cf.modelid
Join Combustors c on cf.CombustorId = c.CombustorID
join FuelTypes ft on cf.FuelTypeID = ft.FuelTypeID
where cf.CombustorFuelID > 0
and CombustorName <> ''''
) up
Pivot
(max(CombFuelStatusNote) for ModelCombustor in ('+ @Cols +')) as pvt
order by FuelType'
exec (@Sql)Then again, a good reporting tool should be able to do dynamic pivot on its own, because dynamic pivoting is a presentation feature.
SSRS Supports dynamic columns: Displaying Dynamic Columns in SSRS Report
SQL Reporting Services with Dynamic Column Reports
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014
Displaying and reading are two very different things.
#1) SSRS Needs a fixed field list on the input side to know what what to make available in the designer.
#2) SSRS cant read "exec (@Sql)" out of a proc, even if there is a fixed number of columns (at
least it can't use it to auto build the field list from the proc)
I use dynamic SQL in my report procs on a fairly regular basis and I've found it easiest to simply dump
the results of my dynamic sql into a temp table at the end of the procs and then select from the temp table.
Basically, Erland is correct. Stop trying to pivot in the query and let SSRS (or whatever reporting software you're using) handle it with a Martix.
Jason Long -
Stored Procedure in Universe - Multi-result set
I have been trying to get more information on stored procedures as a source for universes. Business Objects designer 3.1 documentation says the following
Stored procedures with multi-result set
Example: A stored procedure that returns more than one result set. At design
time, several tables are created in the universe structure based on the same
stored procedure.
Does this mean?
1. These result sets are shown as multiple tables in designer?
2. if so, can these result sets be used as regular tables in designer to build joins and contexts.
I searched the forum for relevant threads before posting but could not find any. I tried posting this thread earlier - internet connection timed out. Please forgive me if this is a duplicate post.
ThanksDROP TABLE #DescendantsMS SQL Server - right?
Then don't drop the table.
From the MS docs for "create table"
Local temporary tables are visible only in the current session;
A local temporary table created in a stored procedure is dropped automatically when the stored procedure completes. The table can be referenced by any nested stored procedures executed by the stored procedure that created the table. The table cannot be referenced by the process which called the stored procedure that created the table. -
I need return the result of a query on a stored procedure
I need return the result of a query on a stored procedure, I mean when I execute a stored procedure it returns a result set as a select query.
Best regards...If you want some pl/sql code that can be used in a query as it were a table you may be interested in table functions:
SQL> create or replace type
2 t_emp is object (
3 name varchar2(30),
4 hire_date date,
5 salary number);
6 /
Tipo creato.
SQL> create or replace type
2 t_emptab is table of t_emp;
3 /
Tipo creato.
SQL> create or replace function tab_fun(p_dept in number)
2 return t_emptab is
3 e t_emptab;
4 begin
5 select t_emp(ename,hiredate,sal)
6 bulk collect into e
7 from emp
8 where deptno=p_dept;
9
10 return dip;
11 end;
12 /
Funzione creata.
SQL> select *
2 from table(tab_fun(20));
NAME HIRE_DATE SALARY
SMITH 17-DIC-80 800
JONES 02-APR-81 2975
SCOTT 09-DIC-82 3000
ADAMS 12-GEN-83 1100
FORD 03-DIC-81 3000A procedure cannot be used in a select statement.
Max
http://oracleitalia.wordpress.com -
Unable to create object from stored procedure
Hi,
we are trying to use a stored procedure to do data preparation.
When we add the stored procedure to a universe, the procedure is executed succesfully and a table with one column, called "1" is created. When we try to create an object from this column, Designer does not allow us to do so.
We already tried to alias the column name in the stored procedure but we still get an unusable column called "1" back.
BO version used is XI R3.0. The stored procedure is written in Cobol on DB2 mainframe.
Does somebody know what we do wrong ?Problem solved.
First we aliased the result columns in the stored procedure, that got rid of the "1".
Then we still could not create an object based on the column in the result set.
Apparently this issue occurs when the length of the column of the result set is too long.
We decreased the length and now we can create the object -
Unable to create object from stored procedure universe
Dear All Experts,
I am facing a problem on unable to create object dimensions on a Stored procedure universe. Fyi, I have successfully insert a stored procedure ('SP_Sales') with input parameter (@date) into universe (Universe_1). But I unable create any object based on the the stored procedured ('SP_Sales') due to it show nothing from the Edit Select Statement of 'Object1', empty for Tables nd columns windows.
Thefore, i unable to drag data in WEBI when i select univese as "Universe_1", it will not sure any object. Please advise.
I am using XI4.0, MSSQL2008.Hi ,
You wont be able to edit the object definitions.
u2022 Designer generates one table per selected stored procedure (or many
tables if multiple result sets) and one object per column returned by a
stored procedure.
u2022 The result set structure is determined when you describe the function.
Please refer chapter 7(Page 451) of below document for more details.
[Universe Designer Guide|http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_designer_en.pdf]
Hope this helps.
Bilahari M
Maybe you are looking for
-
I have re- installed Firefox on 3 occasions recently; mainly in the hope of resolving problem with constant crashes. Yesterday, 22 August, I installed Firefox again to be met with the sqlite.dll3 problem. Ihave uninstaaled and re-installed (from the
-
Illustrator hangs when saving .ai files with linked or embedded images
Hi, Currently I have a huge problem with Adobe Illustrator. When I place an image file inside an Illustrator document, the program freezes for about 45 seconds when saving. In the beginning I though it was just because my image file was too big, but
-
I have an issue with a form I'm developing in Designer, it is being saved as a dynamic pdf. However, when you load the form in Acrobat Pro or Reader and click on the form outside of any fields (like on the background) the form fields become un-fillab
-
Error when installing NetWeaver Developer Studio 7
Hi, I am having problems installing the NetWeaver Developer Studio 7.0.0. which comes bundled with the SAP NetWeaver 7.0 - Trial Version on Linux. To initiate installation, i double-clicked on the IDE70Setup file located in the client/IDE folder. I f
-
How can I move my photos from Photoshop Elements 8 to a new computer also running Elements 8?
How can I move my photos from Photoshop Elements 8 to a new computer also running Elements 8?