Explicit Row Locking within PL/SQL package
I want to lock the row(s) of a table from pl/sql function.
I want to hold the lock until, I explictly release the lock.
(lock should not be released on commit/rollback)
How could I achive. Please explain wiht example.
Thanks.
I think the easietst way to proceed is to use "lock table"...
Thomas.
Similar Messages
-
How to find sql causing "enq: TX - row lock contention"
Hi,
In one of our database we keep finding "enq: TX - row lock contention" for 2-3 days. But, then it stopped. The time it happened it blocked other sessions for some long time and it got resolved automatically. Now from ADDM report we got sql queries which waited for this but, we can not find which query from which module was causing the issue. What I should look for that past information. Please help.
Database is 10gR2 on AIX.
Regards,
Gourabmoreajays wrote:
Try executing below query real time
alter session set nls_date_format='dd-mon-yyyy hh24:mi:ss';
SELECT vp.spid,c.inst_id,b.session_id sid,c.serial#,a.object_name,
a.owner object_owner,
Decode(b.locked_mode, 0, 'None',
1, 'Null (NULL)',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share (S)',
5, 'S/Row-X (SSX)',
6, 'Exclusive (X)',
b.locked_mode) locked_mode,
b.oracle_username,
c.program,
d.event,
c.status,
c.last_call_et,
c.sql_address,
e.sql_text, c.logon_time
FROM all_objects a,
gv$locked_object b,
gv$session c,
gv$session_wait d,
gv$sqlarea e,
gv$process vp
WHERE a.object_id = b.object_id
and b.session_id=c.sid
and c.sid=d.sid and c.paddr=vp.addr
and e.address=c.sql_address and lower(d.event) like '%enq%'
ORDER BY 1;
The OP asked for a way of find a historic blocker, not a current blocker.
This query - apart from being one that no-one should want to run on a production system - doesn't say anything about the past, and doesn't identify a blocker.
It reports the sessions that are being blocked, and EVERY table that is currently locked by each session whether or not the table is involved in the current statement.
You're using the gv$ (RAC) views but haven't put in any suitable join predicates on the instance (inst_id) columns; the OP is on 10g so you don't need to join to v$session_wait to pick up the wait information; and the join to v$sqlarea forces a "full tablescan" of the library cache (child cursor derived view) because you're joining on address rather than sql_id.
Regards
Jonathan Lewis -
DBMS_ALERT Unknown Within User-Defined PL/SQL Package
Greetings,
I am using Oracle 9i (9.2.0.4.0) database on SUN [sparc] Solaris 9.
From an anonymous PL/SQL block, I can invoke procedures in the DBMS_ALERT package, for example:
begin
DBMS_ALERT.SIGNAL('Avi','was here');
end;But if I put the above call to DBMS_ALERT.SIGNAL() in a stored procedure, or in a PL/SQL package, I get the following error:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
PL/SQL procedure successfully completed.
SQL> create procedure P_AVI
2 is
3 begin
4 DBMS_ALERT.SIGNAL('Avi','was here, again');
5 end;
6 /
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE P_AVI:
Hit <ENTER> to continue...
LINE/COL ERROR
4/3 PLS-00201: identifier 'DBMS_ALERT' must be declared
4/3 PL/SQL: Statement ignoredI have searched the OTN forum archives, and the MetaLink Web site, and the Oracle documentation, but I couldn't find anything of help.
I would like someone to explain what I need to do in order to be able to invoke DBMS_ALERT.SIGNAL() from within a user-defined (PL/SQL) package, or an alternative to DBMS_ALERT.SIGNAL().
Basically, I have a procedure that receives a list of parameters, and updates several database tables, based on the supplied parameters. If one (or more) of the parameters is invalid, the procedure does not raise an error, it merely sends an "alert" that notifies any interested parties, that a database table was updated with possibly invalid data.
Thanks (in advance),
Avi.I'm terribly sorry. I just realized that I had to grant EXECUTE permission specifically to the database user that was trying to call the DBMS_ALERT package procedure.
The following GRANT did the trick (as the SYS user):
grant execute on DBMS_ALERT to SCOTTNow the SCOTT user can invoke DBMS_ALERT procedures from within SCOTT's stored procedures and packages.
Please forgive me for this waste of bandwidth.
Cheers,
Avi. -
I'm running a test migration against a production SQL Server database. Unfortunately when the workbench accesses the SQL Server table it's locking rows. Is there anyway to tell workbench to access in read only/no row lock mode?
Hi,
I don't think only rows are locked but tables are.
It's completely normal that there're locks especially during data migration.
This is to respect the data integrity.
If during your migration, updates on your SQL server database has been made you could get incoherences without this locks.
Regards
Mireille MEGE -
Question:
There is a scenario that users want to send multiple rows returned by Execute SQL Task as Email content to send to someone. With Execute SQL Task, the Full result set is used when the query returns multiple rows, it must map to a variable of the Object data
type, then the return result is a rowset object, so we cannot directly send the result variable as Email content. Is there a way that we can extract the table row values that are stored in the Object variable as Email content to send to someone?
Answer:
To achieve this requirement, we can use a Foreach Loop container to extract the table row values that are stored in the Object variable into package variables, then use a Script Task to write the data stored in packages variables to a variable, and then set
the variable as MessageSource in the Send Mail Task.
Add four variables in the package as below:
Double-click the Execute SQL Task to open the Execute SQL Task Editor, then change the ResultSet property to “Full result set”. Assuming that the SQL Statement like below:
SELECT Category, CntRecords
FROM [table_name]
In the Result Set pane, add a result like below (please note that we must use 0 as the result set name when the result set type is Full result set):
Drag a Foreach Loop Container connects to the Execute SQL Task.
Double-click the Foreach Loop Container to open the Foreach Loop Editor, in the Collection tab, change the Enumerator to Foreach ADO Enumerator, then select User:result as ADO object source variable.
Click the Variable Mappings pane, add two Variables as below:
Drag a Script Task within the Foreach Loop Container.
The C# code that can be used only in SSIS 2008 and above in Script Task as below:
public void Main()
// TODO: Add your code here
Variables varCollection = null;
string message = string.Empty;
Dts.VariableDispenser.LockForWrite("User::Message");
Dts.VariableDispenser.LockForWrite("User::Category");
Dts.VariableDispenser.LockForWrite("User::CntRecords");
Dts.VariableDispenser.GetVariables(ref varCollection);
//Format the query result with tab delimiters
message = string.Format("{0}\t{1}\n",
varCollection["User::Category"].Value,
varCollection["User::CntRecords"].Value
varCollection["User::Message"].Value = varCollection["User::Message"].Value + message;
Dts.TaskResult = (int)ScriptResults.Success;
The VB code that can be used only in SSIS 2005 and above in Script Task as below, please note that in SSIS 2005, we should
change PrecompileScriptIntoBinaryCode property to False and Run64BitRuntime property to False
Public Sub Main()
' Add your code here
Dim varCollection As Variables = Nothing
Dim message As String = String.Empty
Dts.VariableDispenser.LockForWrite("User::Message")
Dts.VariableDispenser.LockForWrite("User::Category")
Dts.VariableDispenser.LockForWrite("User::CntRecords")
Dts.VariableDispenser.GetVariables(varCollection)
'Format the query result with tab delimiters
message = String.Format("{0}" & vbTab & "{1}" & vbLf, varCollection("User::Category").Value, varCollection("User::CntRecords").Value)
varCollection("User::Message").Value = DirectCast(varCollection("User::Message").Value,String) + message
Dts.TaskResult = ScriptResults.Success
End Sub
Drag Send Mail Task to Control Flow pane and connect it to Foreach Loop Container.
Double-click the Send Mail Task to specify the appropriate settings, then in the Expressions tab, use the Message variable as the MessageSource Property as below:
The final design surface like below:
References:
Result Sets in the Execute SQL Task
Applies to:
Integration Services 2005
Integration Services 2008
Integration Services 2008 R2
Integration Services 2012
Integration Services 2014
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.Thanks,
Is this a supported scenario, or does it use unsupported features?
For example, can we call exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
in a supported way?
Thanks! Josh -
Row lock contention problem on Inventory Management
Hi
My client is product based company and have e-Commerce (online Sale Order) application using Oracle database 10.2.0.5 & Web application deployed on WLS. Client have ~ 90 Warehouse country wide and ~ 200 Products (Items). Each product stock for each warehouse is maintained in Inventory Table (INV_BALANCE) which get updated for each order and their sale's products. We are using NO WAIT function to acquire lock on row to update stock balance. Last few months, client business is growing very fast and during Promotional Events (EXPO), they have sales of ~ 75K orders (~ 250K Items) within 2-3 days which start causing row lock contention problem on INV_BALANCE table. We are seeing lots of "Row Lock Wait" and "enq: TX - row lock contention" event which cause ORA-00060: Deadlock detected and we need to eventually clear blocking sessions or everything just choked.
select statistic_name,value from sys.v_$segment_statistics where object_name = 'INV_BALANCE'
STATISTIC_NAME VALUE
logical reads 12423072
buffer busy waits 3895
db block changes 3516768
physical reads 957
physical writes 12197
row lock waits 49909
space used -52921
Deadlock graph:
---------Blocker(s)-------- ---------Waiter(s)---------
Resource Name process session holds waits process session holds waits
TX-00880017-00002584 321 1675 X 110 1445 X
TX-00b60008-00000741 110 1445 X 337 2158 X
TX-0148000b-0000009e 337 2158 X 378 1525 X
TX-01d50015-0000006f 378 1525 X 363 1842 X
TX-02290012-00000070 363 1842 X 267 1798 X
TX-024a0026-0000006e 267 1798 X 364 2084 X
TX-020a0004-0000006f 364 2084 X 135 2113 X
TX-01dc001f-00000070 135 2113 X 129 1586 X
session 1675: DID 0001-0141-000001CA session 1445: DID 0001-006E-00000202
session 1445: DID 0001-006E-00000202 session 2158: DID 0001-0151-0000026B
session 2158: DID 0001-0151-0000026B session 1525: DID 0001-017A-00000167
session 1525: DID 0001-017A-00000167 session 1842: DID 0001-016B-000002B4
session 1842: DID 0001-016B-000002B4 session 1798: DID 0001-010B-000001F1
Rows waited on:
Session 1445: obj - rowid = 0001AE0E - AAAlK8AAHAAD7rMABY
(dictionary objn - 110094, file - 7, block - 1030860, slot - 88)
Session 2158: obj - rowid = 0001AE0E - AAAlK8AAHAAD7rMACD
(dictionary objn - 110094, file - 7, block - 1030860, slot - 131)
Session 1525: obj - rowid = 0001AE0E - AAAlK8AAHAAD7rOAB2
(dictionary objn - 110094, file - 7, block - 1030862, slot - 118)
Information on the OTHER waiting sessions:
Session 1445:
sid: 1445 ser: 37 audsid: 38316795 user: 69/<none>
program: JDBC Thin Client
application name: JDBC Thin Client, hash value=2546894660
Current SQL Statement:
SELECT ROWID, NVL(QTY_PEND,0)+NVL(:B3 ,0) FROM INV_BALANCE WHERE WHS_ID = :B2 AND STOCK_ID = :B1 FOR UPDATE OF QTY_PEND WAIT 10
Please help me on following
Q1: How can we reduce the "row lock Contention" on INV_BALANCE, all possible ways & best practices?
Q2: How can we change the design to not have "row lock Contention" at all?
Appreciate your help
Thanks
Amit Garg
www.otnblogs.comHi Amit!
I saw you are using FOR UPDATE in your query.
If you want reduce row locks, then you not must use FOR UPDATE.
As you know, FOR UPDATE is locking rows.
Regards
Mahir M. Quluzade -
26.4 Basing an entity Object on a PL/SQL Package API - Ref Cursor, no View
I am hoping that I could get some help in the details of a problem. I am trying to follow the directions in the Oracle Application Development Framework Developer's Guide for Forms/4GL Developers, Section 26.4 - Basing an Entity Object on a PL/SQL Package API.
There is example code in the downloadable AdvancedEntityExamples - EntityWrappingPL/SQLPackage
The question is, how will the implementation change if the entity is based entirely on PL/SQL - simply stated - no view is available, just ref cursors and insert,update,delete procedures.
In the example code, there are two procedures, lock_product and select_product. This is where things get more complicated. I can create a function to return a single record ref cursor, instead of the list of OUT variables defined in both functions (select_product and lock_product). It makes sense that I just return one cursor and get all of the columns from that instead of lots of OUT variables.
So what's stopping me you may ask... There is one difference between select_product and select_lock. Select_lock has a select that includes "FOR UPDATE NOWAIT". I don't have that as an option when creating my ref cursor. I am not sure what the impact of "FOR UPDATE NOWAIT" is? Can I ignore it?
In the problem I am working with, (getting data from Oracle Portal 10.1.4) I return the following:
function getRefCursor return ref_cursor is
v_tab wwsbr_all_items_object_type := wwsbr_all_items_object_type();
p_recordset wwsbr_types.cursor_type;
l_results wwsrc_api.items_result_array_type;
begin
wwctx_api.set_context(<username>,<password>);
l_results := wwsrc_api.item_search(.. parameters..);
<snip>
... Loop through the objects and populate v_tab
<snip>
open p_recordset for
select * from table(cast(v_tab as wwsbr_all_items_object_type));
return p_recordset;
end getRefCursor;
With this sample, it would be easy to return a single row by passing the masterid as a parameter.
So I am still left with, how should the implementation of callLockProcedureAndCheckForRowInconsistency() and callSelectProcedure() be changed in order to use a ref cursor instead of a view? The user guide was missing that extra section <bg>.
What would be REALLY helpful, is an example, say 26.4A that demonstrates creating an entity object from a ref cursor and procedures from PL/SQL only without a view.
Thank you, KenThe lock procedure is expected to obtain a row-level lock on the row, given its key.
Depending on the setting of jbo.locking.mode, the entity object's lock() method will be invoked either as soon as the first persistent attribute is successfully modified by the user (in the case of jbo.locking.mode=pessimistic), or it will be called during commit processing just before the row is updated in the database (with jbo.locking.mode=optimistic).
Usually 2-tier Swing applications use pessimistic mode, while web applications use optimistic mode.
The FOR UPDATE NOWAIT is the Oracle clause that can be appened to a SELECT statement to acquire a row-level lock on the selected rows. The NOWAIT modifier means that rather than hanging, waiting for a row locked by another user to free up, it will raise an exception if any of the rows being selected-and-locked are not available to lock.
If you're not able to work the FOR UPDATE NOWAIT into the syntax of the ref cursor, perhaps you can initially perform the lock using a different cursor inside the stored procedure, then return your ref cursor. -
Table locking in MS SQL Server
Hi
Can anyone help with a locking problem I have. I have a jsp accessing an MS SQL 7 table. The data access has exception handling and the connection and resultset are closed within the finally block, however the table accessed sometimes gets locked preventing any updates to the records. I am using web logics jdbc driver.
Any help would be appreciated.
DaveA quite wide issue.
Firstly, if you don't do locks, you may experince the locks other connections (by other programs) have caused.
If you do your connection with setTarnsactionIsolation( Connection.READ_UNCOMMITTED ), then you should not be influenced by other's locks. But this level is not to be recommended.
The default is Connection.READ_COMMITTED. In this level - and the higher levels as well - you are prevented from even reading a value which another connection has written, but not yet committed.
Much more locking influences, if you want to do an update.
Now, from the transaction logic only that row that is touched would have to be locked. But SQLServer has a kind of "self-deciding" locking behaviour. It starts with row locks, but if certain internal DBMS resources come low, it switches to using page locks and finally even table locks.
MS claims this as an advantage, my impression. If it is, decide on your own.
This is all described quite largely in the SQLServer docs.
We had some large discussions on this here, too. Search for "+lock +sqlserver" to find them. -
In SQL, there is a specified FOR UPDATE NOWAIT function a part of the SELECT statement for the row. Is there a NOWAIT option for the UPDATE statement?
IE. Oracle documents a SELECT from <table> where <condition> FOR UPDATE NOWAIT to lock a row, but is there a similar UPDATE <table> SET <change> where <condition> NOWAIT?Hi pl_sequel,
You could try using a user lock using the DBMS_LOCK package. The locks requested can have runtime specified names which means they can be tied more specifically to the action you are trying to perform rather than just a true/false gateway mechanism.
Regards
Andre -
OIM DB Row LOCK Exception on Quartz tables
I am facing db row lock error in Prod OIM due to which the Scheduler fails to kick off and an OIM Restart is required to release the lock and start the Scheduler again.
This Error is occuring at any time when none of the scheduler( Custom as well as House Keeping) are scheduled.The OIM Version is 9.0.3.1.
I have enabled Database logs in Debug mode but there are no logs corresponding to the table where lock occured.
This Error was encountered long back with OIM 9.0.1 and was reported as Bug 6491465, but was suspended because of no response from Customer.
The Error trace is as follows
ERROR,11 Sep 2009 16:57:05,497,[org.quartz.core.ErrorLogger],An error occured while scanning for the next trigger to fire.
org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Io exception: Connection reset [See nested exception: java.sql.SQLException: Io ex
ception: Connection reset]
at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.obtainLock(StdRowLockSemaphore.java:154)
at org.quartz.impl.jdbcjobstore.JobStoreCMT.acquireNextTrigger(JobStoreCMT.java:1376)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:231)
* Nested Exception (Underlying Cause) ---------------
java.sql.SQLException: Io exception: Connection reset
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:287)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:515)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:1029)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:535)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1126)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3001)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.obtainLock(StdRowLockSemaphore.java:137)
at org.quartz.impl.jdbcjobstore.JobStoreCMT.acquireNextTrigger(JobStoreCMT.java:1376)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:231)
Did anyone had ever encountered this error.Any Hints?I would check the network pieces as suggested in our internal emails. If the connection is dropping somewhere on your network, the lock would never be released.
-Kevin -
Can read-only users obtain row locks on non-temporary (i.e,. visible to other users) tables, for example through SELECT FOR UPDATE, even though they couldn't not ultimately modify said tables?
Yes.
Here is an example with Oracle XE 11G and HR schema:
Connecting as user having only CREATE SESSION and SELECT privilege on HR.JOBS table:
SQL> desc hr.jobs;
Name Null? Type
JOB_ID NOT NULL VARCHAR2(10)
JOB_TITLE NOT NULL VARCHAR2(35)
MIN_SALARY NUMBER(6)
MAX_SALARY NUMBER(6)
SQL> select * from session_roles;
no rows selected
SQL> select * from session_privs;
PRIVILEGE
CREATE SESSION
SQL> select owner, table_name, privilege from user_tab_privs;
OWNER TABLE_NAME
PRIVILEGE
HR JOBS
SELECT
SQL> select job_title from hr.jobs for update;
JOB_TITLE
President
Administration Vice President
Administration Assistant
Finance Manager
Accountant
Accounting Manager
Public Accountant
Sales Manager
Sales Representative
Purchasing Manager
Purchasing Clerk
JOB_TITLE
Stock Manager
Stock Clerk
Shipping Clerk
Programmer
Marketing Manager
Marketing Representative
Human Resources Representative
Public Relations Representative
19 rows selected.
SQL>Now connecting as HR following statement hangs:
SQL> connect hr/hr
Connected.
SQL> select * from jobs for update;Going back to first session:
SQL> update hr.jobs set min_salary=0;
update hr.jobs set min_salary=0
ERROR at line 1:
ORA-01031: insufficient privileges -
Using CASE WHEN in PL/SQL package
I am trying to convert the values in a selected column into 1 and 0 so that I can display all 1s in one column, all 0s in another. I am doing this in a PL/SQL package. However ORACLE compiler does not like the CASE construct.
Does anyone know how to group values in a column into several new columns. If CASE WHEN construct is not doable in PL/SQL, what alternatives are there? Thanks.
/******* My package starts here *******/
CREATE OR REPLACE PACKAGE TEST_NEED AS
PROCEDURE procTEST_NEED(STARTING_DATE IN VARCHAR2);
END CVRR_MON_NEED;
CREATE OR REPLACE PACKAGE BODY TEST_NEED
AS
PROCEDURE procTEST_NEED(STARTING_DATE IN VARCHAR2)
IS
TEST_START DATE := TO_DATE(STARTING_DATE,'MM/DD/YYYY');
CURSOR v_Cursor IS
SELECT A.D_CODE, A.M_CODE, TEST_START , C.C_NAME,C.P_ID,
SUM(CASE WHEN MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 > 40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 AND B.B_CODE IN '11.1','222.2','272.4') THEN 1 ELSE 0 END) QUALIFIED
FROM A, B, C, D
WHERE A.ID = B.B_ID
AND RTRIM(A.P_CODE) = C.P_CODE
AND A.P_ID = D.P_ID
AND A.P_ID < 99999999999999999999
AND A.E_DATETIME < SYSDATE
GROUP BY A.D_CODE, A.M_CODE, TEST_START , C.C_NAME,C.P_ID;
v_RecordHolder v_Cursor%ROWTYPE;
BEGIN
OPEN v_Cursor;
FETCH v_CursorINTO v_RecordHolder ;
WHILE v_Cursor%FOUND LOOP
look for records in another table with matching keys of the cursor
if found then update by incrementing the existing values in the matching records with values of the current currsor row
else insert the current cursor row
FETCH v_Cursor INTO v_RecordHolder ;
END LOOP;
END procTEST_NEED;
END TEST_NEED;I am trying to convert the values in a selected
column into 1 and 0 so that I can display all 1s in
one column, all 0s in another. I am doing this in a
PL/SQL package. However ORACLE compiler does not
like the CASE construct.
Does anyone know how to group values in a column into
several new columns. If CASE WHEN construct is not
doable in PL/SQL, what alternatives are there?
Thanks.
CURSOR v_Cursor IS
SELECT A.D_CODE, A.M_CODE, TEST_START ,
, C.C_NAME,C.P_ID,
SUM(CASE WHEN MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 >
40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 ANDB.B_CODE IN '11.1','222.2','272.4') THEN 1 ELSE 0
END) QUALIFIEDUse the Decode function. This has been around in oracle SQL for ages and works like a case construct.
You would do something like
select ...
sum( decode (MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 >
40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 AND
B.B_CODE IN ('11.1','222.2','272.4') 1,0 ) -
Issue in Calling PL/SQL packages using callable statement
Hi ,
I have the requirement of calling two pl/sql packages , After call of first package is successful , i need to pass the output of that first package as input to second package.
Since i have called both the packages in same method of AM, first package gets executed successfully but second package doesnt get the input values required from first package and results in error.
Looks like since commit is happening in the single session second package is passed with NULL values.
Need suggestion for proper way of calling pl/sql packages when second package is dependant on first one:
Code used inside AM Method:
if("PENDING_XXX".equals(regVORow.getRegStatus()))
regVORow.setRegStatus("VENDOR_CREATED");
getOADBTransaction().commit();
OracleCallableStatement cStmt = null;
OADBTransaction dbTxn = getOADBTransaction();
NUMBER vendor_id = new NUMBER(-1);
NUMBER vendor_site_id = new NUMBER(-1);
int vendor_id_value = -2000;
String vendor_number = null;
try
cStmt = (OracleCallableStatement)dbTxn.createCallableStatement("begin *XXB_POS_PVT.create_vendo*r( p_vendor_name => :1, p_supplier_reg_id => :2, p_vendor_id=>:3); end;", 1);
cStmt.setString(1, regVORow.getSupplierName());
cStmt.setNUMBER(2, new Number(Integer.parseInt(supplierId)));
cStmt.registerOutParameter(3, 4);
cStmt.execute();
vendor_id = cStmt.getNUMBER(3);
vendor_id_value = vendor_id.intValue();
catch(SQLException e)
throw new OAException(e.getMessage());
Number vendorId = new Number(vendor_id_value);
regVORow.setVendorId(vendorId);
if(vendorId != null)
vendor_number = getSupplierVendorNumber(vendorId);
getOADBTransaction().commit();
AsiPosSupplierOpCosVOImpl regOpCosVO = (AsiPosSupplierOpCosVOImpl)this.getAsiPosSupplierOpCosVO1();
AsiPosSupplierOpCosVORowImpl row = null;
int fetchedRowCount = regOpCosVO.getFetchedRowCount();
RowSetIterator createIter1 = regOpCosVO.createRowSetIterator("createIter1");
if(fetchedRowCount > 0)
createIter1.setRangeStart(0);
createIter1.setRangeSize(fetchedRowCount);
for(int i = 0; i < fetchedRowCount; i++)
row = (AsiPosSupplierOpCosVORowImpl)createIter1.getRowAtRangeIndex(i);
if(row.getApprovalStatus().equalsIgnoreCase("HEAD_APPROVED"))
try
oadbtransactionimpl.writeDiagnostics(this,"Creating Site - " + vendor_id_value+" "+row.getSupplierOpcoCode()+" "+supplierId,1);
cStmt = (OracleCallableStatement)dbTxn.createCallableStatement("begin *XXB_POS_PVT.create_vendor_sites*(p_supplier_reg_id => :1, p_vendor_id=>:2, p_opco_code=>:3, p_vendor_site_id=>:4); end;", 1);
cStmt.setNUMBER(1, new Number(Integer.parseInt(supplierId)));
cStmt.setNUMBER(2, new Number(vendor_id_value));
cStmt.setString(3,row.getSupplierOpcoCode());
cStmt.registerOutParameter(4, 4);
cStmt.execute();
vendor_site_id = cStmt.getNUMBER(4);
getOADBTransaction().commit();
catch(SQLException e)
throw new OAException(e.getMessage());
createIter1.closeRowSetIterator();Hi ,
There are some validation that can be performed from Entity level ( EO ) , you can go through them in Jdev guide .
It depends on the business requirement , not all validation can be performed from Entity level .
Let us know your business requirement , will try to clear your doubt .
--Keerthi -
How to release row lock by using jdbc
hi, currently we are using jdbc to create a connection and create a row lock , is there anyway to release the row lock? right now i am using resultset.close(), but this cause me problem since it release other resultset's row lock too. please help.
hi, from your post, i understood that u know how to do row locking..
How was it done ??
I'm currently looking for answer to do row locking in Microsoft Access...
These are the SQL stmt i've done without success..
SELECT * FROM BSPerson WITH UPDLOCK WHERE ID = 'P001';
SELECT * FROM BSPerson WHERE ID = 'P001' FOR UPDATE;
Both stmt having error........
Please help !
A miliion thanks.... -
Hi,
Every day from 23.00 to 01.00 the performance of the database becomes slow, when i traced i found the following "The SQL statement with SQL_ID "4pgt142s271gy" was blocked on row locks.", which i think is the reason for poor performance and also i found the query with this SQL_ID.
Dut to this my Application at this time Hangs.
What should be my next step,i can't change this query because till last week the database was going fine.
Please advice me ASAP.Hi,
Do these tables involve Workspace Manager? If so, I would need a better understanding of exactly which operations you are performing before commenting on any performance issues.
Otherwise, I would recommend to use the following forum for general database questions.
General Database Discussions
Regards,
Ben
Maybe you are looking for
-
How to Down load Data in Application server into the Internal Table
hi freinds, iam having a file in the application server. now i need to send the data in the file to the internal table. is there any Function Module? i need with out using the OPEN DATA SET and CLOSE DATA SET Keywords. is there any possible? Regard's
-
Creation of a custom TAB in SAP standard Transcation
Hi Experts, Request the ones who created a customized TAB in any standard trascation .Say in ME22N. We will have some tabs at Line item level. Now our requirement is to add one more tab. For that we need to know whether we have to create scree
-
How do I manually update a contact with their Facebook?
I signed on in settings into Facebook, I also have my Facebook app up to date. My contacts list correctly synced about 40% of my contacts with the correct Facebook account - with their profile picture etc. One contact is incorrect, I have no idea how
-
Portal repository upgrade problems
I upgraded a ORACLE 8.1.6.3.0 database to 8.1.7.2.0 and JVM but 9 classes remained invalid, removing and reinstalling jvm I lost all Portal30 JAVA stuffs. Who has found a clue to make it correct.
-
How many devices can I authorize for an account?
I have two machines authorized and I want to add a third, it will not let me, why?