JDBC Receiver, Stored Procedure that Deletes
Hi,
I have a stored procedure that deletes fields in a table based on a lot of different criteria.
I can't use DELETE or SQL_QUERY ie Statement3 and 6 in http://help.sap.com/saphelp_nw04s/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm . I can only use this Stored Procedure.
This is my message type.
<MT_HEADER>
<Statement>
<ClearTable>
<action>.......attribute...set to EXECUTE
<table> .......maps to Stored Procedure
<isInput> ......attribute... set to TRUE
<type> ........attribute...set to STRING
However, I'm getting this error
ERROR: Invalid XML document format for stored procedure: 'type="<SQL-type>"' attribute is missing for element 'table' (Setting a SQL-type (e.g. INTEGER, CHAR, DATE etc.) is mandatory !)
Any ideas?
Damien,
If you look in the link you have procided, the datatype for Stored Procedure every element needs to have a TYPE attribute asscoiated with it and you need to give the corresponding Datatype of that element,
<i>The attribute type=<SQL-Datatype> , which describes the valid SQL data type, is mandatory for all parameter types (IN, OUT, INOUT).
The following SQL data types are supported:
INTEGER, BIT, TINYINT, SMALLINT, BIGINT, FLOAT, REAL, DOUBLE, NUMERIC, DECIMAL, CHAR, VARCHAR, STRING, LONGVARCHAR, DATE, TIME, TIMESTAMP, BINARY, VARBINARY, LONGVARBINARY, BLOB (input and output),CLOB (input and output), CURSOR (output; only in conjunction with the Oracle JDBC driver).
</i>
Regards
Bhavesh
Similar Messages
-
JDBC Receiver Stored Procedure
I want to trigger a receiver stored procedure.
According to SAP Help the following should be the structure.
<StatementName5>
<storedProcedureName action=u201D EXECUTEu201D>
<table>realStoredProcedureeName</table>
<EmployeeID [isInput=u201Dtrueu201D] [isOutput=true] type=SQLDatatype>val1</param1>
<EmployeeName [isInput=u201Dtrueu201D] [isOutput=true] type=SQLDatatype>val1</param1>
</storedProcedureName >
</StatementName5>
My requirement is that i need to pass details about multiple employees to the stored procedure.
Can anybody help me out in changing the above structure?
Warm Regards,
RahulNo need to change...
<StatementName5> (this node should be 0..unbounded)
<storedProcedureName action=u201D EXECUTEu201D>
<table>realStoredProcedureeName</table>
<EmployeeID isInput=u201Dtrueu201D isOutput=true type=SQLDatatype>val1</param1>
<EmployeeName isInput=u201Dtrueu201D isOutput=true type=SQLDatatype>val1</param1>
</storedProcedureName >
</StatementName5>
For each employee replicate this structure in the mapping -
Synch JDBC Receiver - stored procedure
Hi All ,
Can you please let me know whether we can go for a Synch JDBC receiver which needs to excute a stored procedure at the target DB system ? If Yes , Please let me know the procedure .
Thank you.
Regards,
Midhuhi midhu,
Yes you can use stored procedure in receiver JDBC,Set action field to execute and for table field map to Stored procedure name.
Please refer
/people/luis.melgar/blog/2008/05/13/synchronous-soap-to-jdbc--end-to-end-walkthrough
/people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
/people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
Regds,
Srinivas -
Jdbc receiver stored procedure call
This is my stored procedure in sybase
create procedure fn_acf2
@proj_name char(4),
@ver char(1),
@function_code char(4),
@ident_number char(9),
@agent_id char(6)
as
declare @msg char(30)
declare @return_code int
declare @str_return char(5)
begin
if @ver != "1"
begin
print "Invalid version number for 'FNA2'"
return(-1)
end
execute @return_code = SGW003...fn_acf2_security @proj_name, @ver, @function_code, @ident_number, @agent_id
if @@error != 0
begin
select convert(char(5),@return_code)
end
else
return (@return_code)
end
go
MY REQUEST structure looks like
MT_Sybase_Request
statement (element of MT_Sybase_Request)
fn_acf2 (element of statement)
action (attribute of fn_acf2) ( have hard coded as EXECUTE)
proj_name(element of fn_acf2)
type (attribute of proj_name) hard coded as char
isInput (attribute of proj_name) hard coded as 1
ver(element of fn_acf2)
type (attribute of ver) hard coded as char
isInput (attribute of ver) hard coded as 1
funtion_code(element of fn_acf2)
type (attribute of function_code) hard coded as char
isInput (attribute of function_code) hard coded as 1
ident_number(element of fn_acf2)
type (attribute of ident_number) hard coded as char
isInput (attribute of ident_number) hard coded as 1
agent_id(element of fn_acf2)
type (attribute of agent_id) hard coded as char
isInput (attribute of agent_id) hard coded as 1
Should i put element name under statement as fn_acf2 or fn_acf2_security
Is the above structure correct?
I have followed these blogs
JDBC Stored Procedures
SYNCHRONOUS SOAP TO JDBC - END TO END WALKTHROUGHall elements are under fn_acf2
but i want you guys look my Stored procedure
execute @return_code = SGW003...fn_acf2_security @proj_name, @ver, @function_code, @ident_number, @agent_id
in the above stmt,
iam confused why it fn_acf2_security was used instead of an_acf2 ( fn_acf2 is my Stored procedure name)
what does execute @return_code mean ( actually return_code is my response structure element)
my response wil have only elemnt which is return_code. -
How to wrap a stored procedure that outputs PL/SQL records for JDBC?
Hello everybody,
Is there an example for wrapping a stored procedure that outputs PL/SQL records and/or PL/SQL tables of records, so that it can be called from JDBC?
Since this is not possible with the Oracle JDBC driver, Oracle recommends "To wrap a stored procedure that uses PL/SQL tables, break the data into components or perhaps use Oracle collection types." (http://download-west.oracle.com/docs/cd/B12037_01/java.101/b10979/ref.htm#sthref2123)
Many thanks for any help,
Cheers, ChristophHi Christoph,
Have you tried using JPublisher, or -more easily- JDeveloper (Go to your database connection in the "Connections" pane, open the "Packages" node, right click to "Generate Java...").
These approaches (at minimum, use of jpub) will generate required PL/SQL wrapper code, including SQL Type declarations. Once these are installed in the database, you can invoke the wrapper procedures directly from Java.
-- Ekkehard -
Hi guys, I'm trying to create a Stored procedure that will automatically add all 3 After triggers when executed on any given database, can someone please explain and give an example on how do I go about doing this ? I'd also like it to raise any errors
that may come across, thanks in advance.Lets start with the question why do you need the triggers at all. Since SQL Server 2005 we can use an OUTPUT clause.
This code can be re-written in SQL Server 2005 using the OUTPUT clause like below:
create table itest ( i int identity not null primary key, j int not null unique )
create table #new ( i int not null, j int not null)
insert into itest (j)
output inserted.i, inserted.j into #new
select o.object_id from sys.objects as o
select * from #new
drop table #new, itest;
go
Now from this example, you can see the integration of OUTPUT clause with existing DML syntax.
Another common scenario is auditing of data in a table using triggers. In this case, the trigger uses information from the inserted and updated tables to add rows into the audit tables. The example below shows code that uses OUTPUT clause in UPDATE and DELETE
statements to insert rows into an audit table.
create table t ( i int not null );
create table t_audit ( old_i int not null, new_i int null );
insert into t (i) values( 1 );
insert into t (i) values( 2 );
update t
set i = i + 1
output deleted.i, inserted.i into t_audit
where i = 1;
delete from t
output deleted.i, NULL into t_audit
where i = 2;
select * from t;
select * from t_audit;
drop table t, t_audit;
go
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
JDBC callableStatement stored procedure call cancellation?
up vote0down votefavorite
I have a very complex oracle stored procedure that searches and retrieves some data. The procedure returns an output parameter - an oracle cursor. I execute the procedure by JDBC:
CallableStatement stmt = conn.prepareCall("{call myprocedure(?,?,?,?}");
The problem is, the queries can sometimes take quite long (few minutes) and i would like user to be able to cancel the query anytime by clicking button. I have reference to stmt object, but unfortunatelly calling stmt.cancel() (from other thread) has NO EFFECT.
On the other hand when i change the CallableStatement sql to some query like:
CallableStatement stmt = conn.prepareCall("select * from all_objects");
i get "java.sql.SQLTimeoutException: ORA-01013: user requested cancel of current operation" after calling stmt.cancel() - so thats the right reaction.
Does that mean than i cannot cancel stored procedure call via jdbc, but only simple select statements? Does anyone else had and resolved similar problem?
I guess i could cancel the query by oracle kill session, but i use connection pooling (jboss) and i have plenty of sessions for the same user existing.
Database Product Version is Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production JDBC Driver Version is 11.2.0.4.0
any help will be appreciated.This property didnt help, still no reaction after statement.cancel().
I could not cancel the statment from the db size , so i decided to spawn new java thread and run the statement in that thread, and when user clicks cancel button i just cancel the thread, some snipper of code below:
AtomicBoolean userCanceled - this must be AtomicBoolean or volatile variable, so other threads would see the change of variable after clicking button
try{
MyCallableQuery callable = new MyCallableQuery(rs,stmt,this,rsh,outParameter);
FutureTask<T> queryTask = new FutureTask<T>(callable);
ExecutorService executor = Executors.newFixedThreadPool(1);
executor.execute(queryTask);
while (!queryTask.isDone()){ //stil processing statement
Thread.sleep(100);
if (userCanceled)){ //user decided to cancel
futureTask1.cancel(true);
executor.shutdown();
throw new SQLException("User decided to cancel procedure call");
result = futureTask1.get();
//here the code after the resultset has been processed without cancelation
catch (SQLException e}{
//here the code when user decided to cancel like clearing the datatable
and my callable class is like:
public class MyCallable<T> extends ProcRunner implements Callable<T> {
private ResultSet rs;
private CallableStatement stmt;
private ProcRunner procRunner;
private ResultSetHandler<T> rsh;
private Integer outParameter;
public MyCallable(ResultSet rs,CallableStatement stmt,ProcRunner procRunner,ResultSetHandler<T> rsh,Integer outParameter){
this.rs = rs;
this.stmt = stmt;
this.procRunner = procRunner;
this.rsh = rsh;
this.outParameter = outParameter;
@Override
public T call() throws Exception {
T result = null;
stmt.executeUpdate();
rs = (ResultSet) stmt.getObject(outParameter);
rs = this.wrap(rs);
result = rsh.handle(rs);
return result; -
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 -
How Do I Call PL/SQL Stored Procedure That Returns String Array??
I Have Problem Calling An Oracle(8i) Stored Procedure That Returns Array Type (Multi Rows)
(As Good As String Array Type..)
In This Fourm, I Can't Find Out Example Source.
(Question is Exist.. But No Answer..)
I Want An Example,, Because I'm A Beginner...
(I Wonder...)
If It Is Impossible, Please Told Me.. "Impossible"
Then, I'll Give Up to Resolve This Way.....
Please Help Me !!!
Thanks in advance,// Try the following, I appologize that I have not compiled and run this ... but it is headed in the right direction
import java.sql.*;
class RunStoredProc
public static void main(String args[])
throws SQLException
try
Class.forName("oracle.jdbc.driver.OracleDriver");
catch(Exception ex)
ex.printStackTrace();
java.util.Properties props = new java.util.Properties();
props.put("user", "********"); // you need to replace stars with db userid
props.put("password", "********"); // you need to replace stars with userid db password
// below replace machine.domain.com and DBNAME, and port address if different than 1521
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@machine.domain.com:1521:DBNAME", props);
// replace "Your Stored Procedure" with your stored procedure
CallableStatement stmt = conn.prepareCall("Your Stored Procedure");
ResultSet rset = stmt.execute();
while(rset.next())
System.out.println(rset.getString(1)); -
Stored Procedure that creates a trigger on new tables
I am trying to create a stored procedure that creates a trigger on new tables whenever the table is created. The procedure should receive the new project table's name, and then create a dml trigger on that procedure. When the procedure
is run, I get an error "Incorrect syntax near keyword 'TRIGGER.'" This is how my Stored Procedure looks in SQL Management Studio. Any suggestions?
USE [RIDB_DynamicDesign]
GO
/****** Object: StoredProcedure [dbo].[sp_CreateTriggerMarkLatest] Script Date: 11/08/2014 16:43:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_CreateTriggerMarkLatest] @ProjectTable nvarchar(128), @ItExists int OUTPUT
AS
DECLARE @SQL nvarchar(4000)
DECLARE @MarkLatest nvarchar(30)
DECLARE @LatTrue bit
DECLARE @LatFalse bit
SET @LatTrue = 'True'
SET @LatFalse = 'False'
SET @SQL = 'CREATE TRIGGER tr_MarkLatest ON ' + @ProjectTable + ' AFTER INSERT
AS
UPDATE ' + @ProjectTable + ' SET Latest = @LatFalse
UPDATE ' + @ProjectTable + ' SET Latest = @LatTrue WHERE
ID IN (SELECT ID FROM ' + @ProjectTable + ' p WHERE
NOT EXISTS (SELECT 1 FROM ' + @ProjectTable + ' WHERE
Name = p.Name AND Vers = p.Vers
AND Date > p.Date))'
EXEC sp_executesql @SQL, N'@ProjectTable nvarchar(128), @LatTrue bit, @LatFalse bit',
@ProjectTable, @LatTrue, @LatFalse
GinaFirst you have to debug the dynamic SQL string with a PRINT statement. I see some problems:
CREATE PROCEDURE [dbo].[uspCreateTriggerMarkLatest] @ProjectTable nvarchar(128), @ItExists int OUTPUT
AS BEGIN
DECLARE @SQL nvarchar(4000)
DECLARE @MarkLatest nvarchar(30)
DECLARE @LatTrue bit
DECLARE @LatFalse bit
SET @LatTrue = 'True'
SET @LatFalse = 'False'
SET @SQL = 'CREATE TRIGGER tr_MarkLatest ON ' + @ProjectTable + ' AFTER INSERT
AS
UPDATE ' + @ProjectTable + ' SET Latest = @LatFalse
UPDATE ' + @ProjectTable + ' SET Latest = @LatTrue WHERE
ID IN (SELECT ID FROM ' + @ProjectTable + ' p WHERE
NOT EXISTS (SELECT 1 FROM ' + @ProjectTable + ' WHERE
Name = p.Name AND Vers = p.Vers
AND Date > p.Date))'
PRINT @SQL;
-- EXEC sp_executesql @SQL, N'@ProjectTable nvarchar(128), @LatTrue bit, @LatFalse bit', @ProjectTable, @LatTrue, @LatFalse
END
GO
DECLARE @ItExists int, @ProjectTable nvarchar(128) = N'TestTrigger';
EXEC [dbo].[uspCreateTriggerMarkLatest] @ProjectTable, @ItExists OUTPUT
CREATE TRIGGER tr_MarkLatest ON TestTrigger AFTER INSERT
AS
UPDATE TestTrigger SET Latest = @LatFalse
UPDATE TestTrigger SET Latest = @LatTrue WHERE
ID IN (SELECT ID FROM TestTrigger p WHERE
NOT EXISTS (SELECT 1 FROM TestTrigger WHERE
Name = p.Name AND Vers = p.Vers
AND Date > p.Date))
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
Issue with a stored procedure that uses a sys refcursor to output dataset..
Hi All:
I create a stored procedure that uses an in out sys ref cursor:
create or replace procedure FIRE_SALES_100_CALLS_REPORT
( p_cursor in out sys_refcursor)
IS
BEGIN
--Insert into the temp table the records for the rep sales
EXECUTE IMMEDIATE '
INSERT INTO TMP_SALES_CNT_BY_USER
TOTALPRODUCTSSOLD,
NUMBEROFCALLS,
SALESPER100CALLS,
SERVICEORDERNUM,
PRODUCT,
LOGIN,
FST_NAME,
LAST_NAME,
NAME,
POSITIONHELD,
CURRENTPARPARTYID,
QUERY_DATE,
CREATED_BY
SELECT e.TotalProductsSold,
e.NumberOfCalls,
((e.TotalProductsSold/e.NumberOfCalls)*100) AS SalesPer100Calls,
e.ServiceOrderNum,
e.Product,
e.login,
e.fst_name,
e.last_name,
e.name,
e.PositionHeld,
e.CurrentParPartyID,
e.query_date,
e.created_by
FROM (
SELECT COUNT(o.order_num) over ( partition by u.login
order by u.login) AS TotalProductsSold,
SUM(NVL(x.n_inbound,1) + NVL(x.n_outbound,1)) over (partition by u.login
order by u.login) AS NumberOfCalls,
o.order_num AS ServiceOrderNum,
pi.name as Product,
u.login,
c.fst_name,
c.last_name,
postn.name,
c.pr_held_postn_id as PositionHeld,
p.par_party_id as CurrentParPartyID,
NVL(x.query_date,NVL(o.last_upd, null)) AS query_date,
o.created_by
FROM firestg.SEB_S_order o
INNER join firestg.seb_s_order_item oi ON o.row_id = oi.order_id
INNER join firestg.seb_s_prod_int pi ON oi.prod_id = pi.row_id
INNER join firestg.SEB_s_contact c on c.Row_Id = o.created_by
INNER join firestg.SEB_s_user u on u.row_id = o.created_By
INNER join firestg.SEB_s_party p on p.row_id = c.pr_held_postn_id
INNER join firestg.SEB_s_postn postn on postn.row_id = c.pr_held_postn_id
LEFT OUTER JOIN (
SELECT taw.QUERY_DATE,
vaw.n_inbound,
vaw.n_outbound,
oaw.object_name, oaw.object_id
FROM GEN_T_AGENT_WEEK taw
INNER JOIN GEN_V_AGENT_WEEK vaw ON taw.time_key = vaw.time_key
INNER JOIN GEN_O_AGENT_WEEK oaw ON oaw.object_id = vaw.object_id) x
ON u.cti_acd_userid = x.object_name
WHERE NVL(x.query_date,NVL(o.last_upd, null)) BETWEEN (TRUNC (next_day (sysdate, ''SUN''))-14)
AND (TRUNC (next_day (sysdate, ''SUN''))-8)
AND o.status_cd IN (''Complete''))e';
--Lookup the first level to see if there is a higher level person
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET (ParPartyID_1ST, LOGIN_1ST,FST_NAME_1ST,LST_NAME_1ST,TITLE_1ST) =
(SELECT pa.par_party_id,
U.Login,
C.FST_NAME,
C.Last_Name,
p.name
FROM firestg.seb_s_postn p
inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
WHERE p.row_id = a.currentparpartyid)
WHERE CurrentParPartyID IS NOT NULL';
--Lookup the second level to see if there is a higher level person
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET (ParPartyID_2ND, LOGIN_2ND,FST_NAME_2ND,LST_NAME_2ND,TITLE_2ND) =
(SELECT pa.par_party_id,
U.Login,
C.FST_NAME,
C.Last_Name,
p.name
FROM firestg.seb_s_postn p
inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
WHERE p.row_id = a.ParPartyID_1ST)
WHERE a.ParPartyID_1ST IS NOT NULL';
--Lookup the third level to see if there is a higher level person
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET (ParPartyID_3RD, LOGIN_3RD,FST_NAME_3RD,LST_NAME_3RD,TITLE_3RD) =
(SELECT pa.par_party_id,
U.Login,
C.FST_NAME,
C.Last_Name,
p.name
FROM firestg.seb_s_postn p
inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
WHERE p.row_id = a.ParPartyID_2ND)
WHERE a.ParPartyID_2ND IS NOT NULL';
--Lookup the fourth level to see if there is a higher level person
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET (ParPartyID_4TH, LOGIN_4TH,FST_NAME_4TH,LST_NAME_4TH,TITLE_4TH) =
(SELECT pa.par_party_id,
U.Login,
C.FST_NAME,
C.Last_Name,
p.name
FROM firestg.seb_s_postn p
inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
WHERE p.row_id = a.ParPartyID_3RD)
WHERE a.ParPartyID_3RD IS NOT NULL';
--Lookup the fifth level to see if there is a higher level person
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET (ParPartyID_5TH, LOGIN_5TH,FST_NAME_5TH,LST_NAME_5TH,TITLE_5TH) =
(SELECT pa.par_party_id,
U.Login,
C.FST_NAME,
C.Last_Name,
p.name
FROM firestg.seb_s_postn p
inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
WHERE p.row_id = a.ParPartyID_4TH)
WHERE a.ParPartyID_4TH IS NOT NULL';
-- If there was no 1st place then the rep is a VP
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET a.vp = a.last_name || '', '' || a.fst_name,
a.vp_login = a.login
WHERE a.login_1st IS NULL';
--If there is no second place then the rep has a VP and is a Director
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET a.vp = a.lst_name_1st || '', '' || a.fst_name_1st,
a.vp_login = a.login_1st,
a.director = a.last_name || '', '' || a.fst_name,
a.director_login = a.login
WHERE a.login_1st IS NOT NULL
AND a.login_2ND IS NULL';
--IF there is no third place then the rep has a VP, Director & is a Manager
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET a.vp = a.lst_name_2ND || '', '' || a.fst_name_2ND,
a.vp_login = a.login_2ND,
a.director = a.lst_name_1st || '', '' || a.fst_name_1st,
a.director_login = a.login_1st,
a.manager = a.last_name || '', '' || a.fst_name,
a.manager_login = a.login
WHERE a.login_1st IS NOT NULL
AND a.login_2ND IS NOT NULL
AND a.login_3rd IS NULL';
--If there is no fourth place then the rep has a VP, Dir, Manager, and is a Supervisor
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET a.vp = a.lst_name_3RD || '', '' || a.fst_name_3RD,
a.vp_login = a.login_3RD,
a.director = a.lst_name_2ND || '', '' || a.fst_name_2ND,
a.director_login = a.login_2ND,
a.manager = a.lst_name_1st || '', '' || a.fst_name_1st,
a.manager_login = a.login_1st,
a.supervisor = a.last_name || '', '' || a.fst_name,
a.supervisor_login = a.login
WHERE a.login_1st IS NOT NULL
AND a.login_2ND IS NOT NULL
AND a.login_3rd IS NOT NULL
AND a.login_4th IS NULL';
--If there is no fifth plance then the rep has a VP, Dir, Mgr, Supervisor, and is a Team Lead
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET a.vp = a.lst_name_4TH || '', '' || a.fst_name_4TH,
a.vp_login = a.login_4TH,
a.director = a.lst_name_3RD || '', '' || a.fst_name_3RD,
a.director_login = a.login_3RD,
a.manager = a.lst_name_2ND || '', '' || a.fst_name_2ND,
a.manager_login = a.login_2ND,
a.supervisor = a.lst_name_1st || '', '' || a.fst_name_1st,
a.supervisor_login = a.login_1st,
a.teamlead = a.last_name || '', '' || a.fst_name,
a.teamlead_login = a.login
WHERE a.login_1st IS NOT NULL
AND a.login_2ND IS NOT NULL
AND a.login_3rd IS NOT NULL
AND a.login_4th IS NOT NULL
AND a.login_5th IS NULL';
--If there is a fifth place then the rep has a VP, Dir, Mgr, Supervisor, Team Lead and is a rep
EXECUTE IMMEDIATE '
UPDATE TMP_SALES_CNT_BY_USER a
SET a.vp = a.lst_name_5TH || '', '' || a.fst_name_5TH,
a.vp_login = a.login_5TH,
a.director = a.lst_name_4TH || '', '' || a.fst_name_4TH,
a.director_login = a.login_4TH,
a.manager = a.lst_name_3RD || '', '' || a.fst_name_3RD,
a.manager_login = a.login_3RD,
a.supervisor = a.lst_name_2ND || '', '' || a.fst_name_2ND,
a.supervisor_login = a.login_2ND,
a.teamlead = a.lst_name_1st || '', '' || a.fst_name_1st,
a.teamlead_login = a.login_1st
WHERE a.login_1st IS NOT NULL
AND a.login_2ND IS NOT NULL
AND a.login_3rd IS NOT NULL
AND a.login_4th IS NOT NULL
AND a.login_5th IS NOT NULL';
open p_cursor for
SELECT tsc.vp,
tsc.director,
tsc.manager,
tsc.supervisor,
tsc.teamlead,
(tsc.last_name || ', ' || tsc.fst_name) AS Rep,
tsc.product,
tsc.totalproductssold,
tsc.numberofcalls,
tsc.salesper100calls
FROM TMP_SALES_CNT_BY_USER tsc;
END FIRE_SALES_100_CALLS_REPORT;
The table I use is a Global temp table.
This runs just fine in oracle but when I try to build a data foundation in Business Objects I get the error that says you cannot insert/update/delete in a READ ONLY Transaction.
I really need some advice on what to do since I really dont have access to a scheduled script and table that would store my data ahead of time.Well, AFAIK, BO is a reporting tool, so it si read-only by nature. I do not know if it possible to "tell" BO table is GTT and it is OK to write to it. You need to post this in BO forum.
SY. -
Using XI - RFC table and an Oracle stored procedure that returns a cursor.
I need to create an interface using XI between an RFC table and an Oracle stored procedure that returns a cursor. We are on oarcle 9.2 and SP12.
My stored procedure looks something like this:
CREATE OR REPLACE
PROCEDURE testproc_xi2 (p_recordset1 OUT SYS_REFCURSOR,
in_quoteid IN varchar2 )
AS
BEGIN
OPEN p_recordset1 FOR
SELECT q.quote_id,
q.modified_by,
q.quote_status,
q.total_cost
FROM quote q
WHERE q.quote_id = in_quoteid
AND q.total_cost > 0 ;
END testproc_xi2 ;
My RFC has table and one import parameter .
I wanted to know how to create the data type for the ref cursor? and also for the table type in the RFC?
CAN XI handle multi rows coming from a Stored procedure? Are there any other alternative methods if this is not supported?Any pointers to this would be helpful.
I have called a Oracle SP from an RFC before, but that interface had one input parameter going to the stored procedure from the RFC and about 6 o/p parameters coming from the Stored procedure. This works fine.
Thanks for the help.
MalaMala,
i dont think there is anything called an rfc table...RFC stands for remote function call. That in essence would imply you need a rfc to jdbc connection.
yes XI can handle multiple rows cooming from the the stored procedure if you have them mapped appropriately.
Now as to how to create the data type within xi , you need to know what fields are going to be returned and whether they are nested and then just create them as you would for an xml
for ex
<Details>
<FirstName>
<LastName>
</Details>
that in xi would be smthing like
Details type of data occurence
FirstName type of data occurence
LastName type of data occurence.
Hope that helps.
If it does dont forget the points..:-) -
How to create a stored procedure that accepts an array of args from Java?
I am to be creating a stored procedure that accepts an array of arguments from Java. How to create this? thanks
SamNot a PL/SQL question really, but a Java one. The client call is done via ThinJDBC/OCI to PL/SQL, This call must be valid and match the parameters and data types of the PL/SQL procedure.
E.g. Let's say I define the following array (collection) structure in Oracle:
SQL> create or replace type TStrings as table of varchar2(4000);
Then I use this as dynamic array input for a PL/SQL proc:
create or replace procedure foo( string_array IN TStrings )...
The client making the call to PL/SQL needs to ensure that it passes a proper TStrings array structure.. The Oracle Call Interface (OCI) supports this on the client side - allowing the client to construct an OCI variable that can be passed as a TStrings data type to SQL. Unsure just what JDBC supports in this regard.
An alternative method, and a bit of a dirty hack, is to construct the array dynamically - but as this does not use bind variables, it is not a great idea.
E.g. the client does the call as follows: begin
foo( TStrings( 'Tom', 'Dick', 'Harry' ) );
end;Where the TStrings constructor is created by the client by stringing together variables to create a dynamic SQL statement. A bind var call would look like this instead (and scale much better on the Oracle server side):begin
foo( :MYSTRINGS );
end;I'm pretty sure these concepts are covered in the Oracle Java Developer manuals... -
Help! Need oracle help with constructing stored procedure that return resultsets
Suns tutorial path for returning resultsets from stored procedures indicates that the following should work...
CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
ResultSet rs = cs.executeQuery();
Thats if you build your stored procedure something like this ...
String createProcedure = "create procedure SHOW_SUPPLIERS " + "as " + "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from SUPPLIERS, COFFEES " + "where SUPPLIERS.SUP_ID = COFFEES.SUP_ID " + "order by SUP_NAME";
We are using oracle 8.1.6. However I've been told that with oracle procedures when you return a result set from a called procedure you return a p_cursor variable. Somthing like this
(p_cursor in out SHOW_SUPPLIERS.SHOCurTyp)
is
begin
open p_cursor for
select * from suppliers
In which case the above mentioned sun code doesn't work.
We want to use jdbc to call a stored procedure that returns a resultset that does not require us to import any proprietary oracle objects...
Is there another way to write these stored procedures, rather than using this cursor construct? Are we missing something in the way we invoke them?Suns tutorial path for returning resultsets from stored procedures indicates that the following should work...
CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
ResultSet rs = cs.executeQuery();
Thats if you build your stored procedure something like this ...
String createProcedure = "create procedure SHOW_SUPPLIERS " + "as " + "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from SUPPLIERS, COFFEES " + "where SUPPLIERS.SUP_ID = COFFEES.SUP_ID " + "order by SUP_NAME";
We are using oracle 8.1.6. However I've been told that with oracle procedures when you return a result set from a called procedure you return a p_cursor variable. Somthing like this
(p_cursor in out SHOW_SUPPLIERS.SHOCurTyp)
is
begin
open p_cursor for
select * from suppliers
In which case the above mentioned sun code doesn't work.
We want to use jdbc to call a stored procedure that returns a resultset that does not require us to import any proprietary oracle objects...
Is there another way to write these stored procedures, rather than using this cursor construct? Are we missing something in the way we invoke them? -
Can I create a Stored Procedure That access data from tables of another servers?
I'm developing a procedure and within it I'm trying to access another server and make a select into a table that belongs to this another server. When I compile this procedure I have this error message: " PLS-00904: insufficient privilege to access object BC.CADPAP", where BC.CADPAP is the problematic table.
How can I use more than one connection into an Oracle Stored Procedure?
How I can access tables of a server from a Stored Procedure since the moment I'm already connected with another server?
Can I create a Stored Procedure That access data from tables of another servers?You need to have a Database Link between two servers. Then you could do execute that statement without any problem. Try to create a database link with the help of
CREATE DATABASE LINK command. Refer Document for further details
Maybe you are looking for
-
MDT 2012 Deployment by USB Flash Drive Problems
To test MDT, I'm trying to deploy Windows 7 Enterprise trial to a new ASUS x44H laptop via USB key and not use the network for anything until it needs to join the domain. I have copied the media files (about 4 gigs of data including Windows 7 -64bit
-
Iphoto has images placed over my photos
Images have been placed over where my photos were, how can I recover my photos?
-
Replacing assets for updated assets
I just finished a project, including the DVD, but upon delivery my client noticed one tiny glitch that I hadn't. I went back through FCP and corrected it, re-exported it in Compressor, and have imported the new video and audio files into DVDSP. My qu
-
JDBC Receiver: updates only header table how to update detail
Hi here the scenario idoc having one header and one details segments, header data goes to one sql table detail date to another sql table. i created the sql structure in two ways one table name insert table header table action
-
Is there a Go To function in Numbers?
I really like the function in AppleWorks' to be able to link to other parts of a document. I don't see anything like this in Numbers unless I am missing it. Can anyone prove me wrong?