Importing ODI Procedure in Insert/Insert-Update mode
Can we import an ODI procedure from one project to another in INSERT or INSERT-UPDATE mode?
We are getting xml import error while doing this. But when we do the import in DUPLICATION mode, it successfully does so.
The issue is that we have an ODI procedure in INT environment which is been used by several other packages. We changed the code of it in our DEV environment and when we tried to import it in INT environment through INSERT-UPDATE mode so that the the changes gets effected, we got error.
This is quite obvious that the folder/sub-folder IDs are different in both environment and this is causing trouble.
So, is there any other way, we can reflect the change in the INT environment with minimum effort? I mean, we don't want to import it in DUPLICATION mode....if we do so, we will have to re-map that procedure in all the packages and regenerate them.
You can use variable to replace the value at runtime in the query but you need to either pass the variable value at startup or you can refresh variable value. But I dont think you can directly retrieve any topology setting as the variable value to be substituted in the query.
Similar Messages
-
[Urgent]How to import odi procedure from 11g to 10g.
Hi All,
I am trying to import odi code(interface/procedure) from 11g to 10g but gettting xml error.
Please reply as soon as possible.
ThanksForward compatibility for importing odi artifacts is not supported.
-
Hello,
In my form I have a component list. He calls another form. Calling this form is in insert mode or update mode. How can I do this?
In the insert mode is showing the error:
ORA-01403: no data found Error Unable to fetch row.
How can I do that if the record does not exist, it change to insert mode?
Thank you all.
MarceloIf you built the form using the create form wizard, you should not need to tell it whether you are expecting to insert or update - we do that for you.
If you built your own, you will need to add a condition to your fetch so that it only fires if you primary key column was passed in (that is what typically signifies an update). You will need the same on the processing to identify whether to run your insert or update procedure (ditto for your buttons, you don't want to display Delete when a user is inserting).
Even if you did build your own, you might want to create a form using a wizard and inspect what gets created for you so that you can see how it works and then replicate on your page.
-- Sharon -
Not Properly Insert and Update in ODI interfaces
Dear Brothers,
The records are not inserting and updating even the CDC captured in the journal in one of my package. But, stopped and execute again then there is inserts and updates. I am not able to understand where the problem is. Can u suggest regarding the issue.Dear Bro,
I am capturing CDC using consistent set. I am using (LKM SQL to DB2 UDB). While executing the package, the records are locked and extend window, but there is no inserts and updates into the database. It is throwing error as row index out of range while running the query. The query is running in Source Stage for ex. RTO_STAGE.JV$NUMGEN. query is triggering but records are not properly inserted and updated in the target.
First time i saw in the CDC table, there was some 10 records available while executing no insert and update. Then, i stopped it and execute it again at that time i checked in the CDC table ie., the same table, but there was only 2 records available in CDC the old records were disappeared.
I dont know the exact issue? My colleague is telling may be SNP tables not refreshing. Kindly suggest any solution. -
Can we use both INSERT and UPDATE at the same time in JDBC Receiver
Hi All,
I would like to know is it possible to use both INSERT and UPDATE at the same time in one interface because I have a requirement in which I have to perform both the task.
user send the file which contains both new and old record and I need to save those in MS SQL database.
If the record exist then use UPDATE otherwise use INSERT.
I looked on sdn but didn't find any blog which perform both the things at the same time.
Interface Requirement
FILE -
> PI -
> JDBC(INSERT & UPDATE)
I am thinking to use JDBC Lookup but not sure if it good to use for bulk record.
Can somebody please suggest me something or send me the link of any blog or anything to solve this problem.
Thanks,Hi ,
If I have understood properly the scenario properly,you are not performing insert and update together. As you posted
"If the record exist then use UPDATE otherwise use INSERT."
Thus you are performing either an insert or an update which depends on outcome of a search if the records already exist in database or not. Obviously to search the tables you need " select * from ... where ...." query. If your query returns some results you proceed with update since this means there are some old records already in database. If your query returns no rows you proceed with "insert into tablename....." since there are no old records present in database.
Now perhaps the best method to do the searching, taking a decision to insert or update, and finally insert or update operation is to be done by a stored procedure in MS SQL database. A stored procedure is a subroutine available to applications accessing a relational database system. Here the application is PI server. If you need further help on how to write and call stored procedure in MS SQL you can look into these links
http://www.daniweb.com/web-development/databases/ms-sql/threads/146829
http://www.sqlteam.com/article/stored-procedures-parameters-inserts-and-updates
[ This part you can ignore, Since its not sure that you will face this situation
Still you might face some problems while your scenario runs. Lets consider this scenario, after the stored procedure searches the database it found no rows. Thus you proceed with an insert operation. If your database table is being accessed by multiple applications (or users) other than yours then it is very well possible that after the search operation completed with a null result, an insert/update operation has been performed by some other application with the same primary key. Now when you are trying to insert another row with same primary key you get an error message like "duplicate entry not possible for same primary key value". Thus you need to be careful in this respect. MS SQL has a feature called "exclusive locks ". Look into these links for more details on the subject
http://msdn.microsoft.com/en-us/library/aa213039(v=sql.80).aspx
http://www.mssqlcity.com/Articles/Adm/SQL70Locks.htm
http://www.faqs.org/docs/ppbook/r27479.htm
http://msdn.microsoft.com/en-US/library/ms187373.aspx
http://msdn.microsoft.com/en-US/library/ms173763.aspx
http://msdn.microsoft.com/en-us/library/e7z8d5hf(v=vs.80).aspx
http://mssqlserver.wordpress.com/2006/11/08/locks-in-sql/
http://www.mollerus.net/tom/blog/2008/03/using_mssqls_nolock_for_faster_queries.html
There must be other methods to avoid this problem. But the point is you need to be sure that all access to database for insert/update operations are isolated.
regards
Anupam -
Hi All,
I want to write a stored procedure to insert or update the value into the customer table. If the record exist, I need to insert. If it does not exist, I need to update. Could you tell me how do we do it.
My Current stored procedure is :
CREATE OR REPLACE PROCEDURE customer_update
(p_cust_id IN VARCHAR2,
p_cust_name IN VARCHAR2)
AS
BEGIN
INSERT INTO CUSTOMER (cust_id, cust_NAME, update_dm)
VALUES (p_cust_id, p_cust_name, sysdate);
COMMIT;
END customer_update;I think we need to be careful about using EXCEPTION to handle normal (expected) processing. Also, if the row is more likely to exist than not exist, it might be better to try the UPDATE first, and only go for INSERT if SQL%ROWCOUNT = 0;
There's been a few of these sort of questions posted recently, and I find them worrying, becuase it suggests poorly designed systems. The user ought to know whether they are inserting a new record or amending an existing one. The MERGE functionality is useful for data migration/upload scenarios, but I think using it in a business situation is, in the words of Kent Beck, a "code smell".
Cheers, APC -
Calling of Stored Procedure in After Insert Trigger
Can I call a Stored Procedure in After Insert Trigger ?
Please send a sample code (good example) of After Insert Trigger.
Thanks.Kishore,
I have two table WLCS_ORDER, WLCS_ORDER_LINE
WLCS_ORDER - It holds order header information like
ORDER_ID
CUSTOMER_ID
TRANSACTION_ID
STATUS
ORDER_DATE
SHIPPING_METHOD
SHIPPING_AMOUNT
SHIPPING_CURRENCY
PRICE_AMOUNT
PRICE_CURRENCY
SHIPPING_GEOCODE
SHIPPING_STREET1
SHIPPING_STREET2
SHIPPING_CITY
SHIPPING_STATE
SHIPPING_COUNTRY
SHIPPING_POBOX
SHIPPING_COUNTY
SHIPPING_POSTAL_CODE
SHIPPING_POSTAL_CODE_TYPE
SPECIAL_INSTRUCTIONS
SPLITTING_PREFERENCE
ORDER_SUBTOTAL
WLCS_ORDER_LINE - It holds all order lines information like
ORDER_LINE_ID
QUANTITY
PRODUCT_ID
TAX_AMOUNT
TAX_CURRENCY
SHIPPING_AMOUNT
SHIPPING_CURRENCY
UNIT_PRICE_AMOUNT
UNIT_PRICE_CURRENCY
MSRP_AMOUNT
MSRP_CURRENCY
DESCRIPTION
ORDER_ID
TOTAL_LINE_AMOUNT
Relation between WLCS_ORDER, WLCS_ORDER_LINE is one to many.
For each WLCS_ORDER row, one or more order lines will insert into WLCS_ORDER_LINE table.
For each new row in WLCS_ORDER table, I have to update the following columns in both the tables with my maths.
WLCS_ORDER
shipping_amount
price_amount
order_subtotal
WLCS_ORDER_LINE
shipping_amount
I thought I can do this in after insert trigger, But if it is not possible, Please give the best way to fulfill this requirement.
I appreciate your help.
Have a great day.
Srinivas -
After insert or update calculate column
question about a table.
I have a table called table1
AFTER data is inserted or updated into the table1
I want to run an update on the same table (table1) with a case statement
update table1
set column2 = case
WHEN column1 = 'abc' THEN 'testl'
WHEN column1 = 'def' THEN 'test2'
ELSE 'test3'
END;
commit;
END;
i cant use a trigger because i get error since the insert would be on same table.
What else can i use for this update ? I cant use a stored procedure that runs daily or something like that because the column2 in the table needs to be populated immediately after an insert or update
thanks for any ideasSQL> CREATE TABLE TABLE1
2 (
3 COLUMN1 VARCHAR2(10),
4 COLUMN2 VARCHAR2(10)
5 );
Table created.
SQL> CREATE OR REPLACE TRIGGER TRG_TABLE1
2 BEFORE INSERT OR UPDATE OF COLUMN1 ON TABLE1
3 FOR EACH ROW
4 BEGIN
5
6 IF :NEW.COLUMN1 = 'abc' THEN
7 :NEW.COLUMN2 := 'test1';
8 ELSIF :NEW.COLUMN1 = 'def' THEN
9 :NEW.COLUMN2 := 'test2';
10 ELSE
11 :NEW.COLUMN2 := 'test3';
12 END IF;
13
14 END;
15 /
Trigger created.
SQL> INSERT INTO TABLE1(COLUMN1) VALUES('abc');
1 row created.
SQL> SELECT * FROM TABLE1;
COLUMN1 COLUMN2
abc test1
SQL> UPDATE TABLE1 SET COLUMN1 = 'def';
1 row updated.
SQL> SELECT * FROM TABLE1;
COLUMN1 COLUMN2
def test2
SQL>
{code} -
SQL merge and after insert or update on ... for each row fires too often?
Hello,
there is a base table, which has a companion history table
- lets say USER_DATA & USER_DATA_HIST.
For each update on USER_DATA there has to be recorded the old condition of the USER_DATA record into the USER_DATA_HIST (insert new record)
- to have the history of changes to USER_DATA.
The first approach was to do the insert for the row trigger:
trigger user_data_tr_aiu after insert or update on user_data for each rowBut the performance was bad, because for a bulk update to USER_DATA, there have been individual inserts per records.
So i tried a trick:
Instead of doing the real insert into USER_DATA_HIST, i collect the USER_DATA_HIST data into a pl/sql collection first.
And later i do a bulk insert for the collection in the USER_DATA_HIST table with stmt trigger:
trigger user_data_tr_ra after insert or update on user_dataBut sometimes i recognize, that the list of entries saved in the pl/sql collection are more than my USER_DATA records being updated.
(BTW, for the update i use SQL merge, because it's driven by another table.)
As there is a uniq tracking_id in USER_DATA record, i could identify, that there are duplicates.
If i sort for the tracking_id and remove duplicate i get exactly the #no of records updated by the SQL merge.
So how comes, that there are duplicates?
I can try to make a sample 'sqlplus' program, but it will take some time.
But maybe somebody knows already about some issues here(?!)
- many thanks!
best regards,
FrankHello
Not sure really. Although it shouldn't take long to do a test case - it only took me 10 mins....
SQL>
SQL> create table USER_DATA
2 ( id number,
3 col1 varchar2(100)
4 )
5 /
Table created.
SQL>
SQL> CREATE TABLE USER_DATA_HIST
2 ( id number,
3 col1 varchar2(100),
4 tmsp timestamp
5 )
6 /
Table created.
SQL>
SQL> CREATE OR REPLACE PACKAGE pkg_audit_user_data
2 IS
3
4 PROCEDURE p_Init;
5
6 PROCEDURE p_Log
7 ( air_UserData IN user_data%ROWTYPE
8 );
9
10 PROCEDURE p_Write;
11 END;
12 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY pkg_audit_user_data
2 IS
3
4 TYPE tt_UserData IS TABLE OF user_data_hist%ROWTYPE INDEX BY BINARY_INTEGER;
5
6 pt_UserData tt_UserData;
7
8 PROCEDURE p_Init
9 IS
10
11 BEGIN
12
13
14 IF pt_UserData.COUNT > 0 THEN
15
16 pt_UserData.DELETE;
17
18 END IF;
19
20 END;
21
22 PROCEDURE p_Log
23 ( air_UserData IN user_data%ROWTYPE
24 )
25 IS
26 ln_Idx BINARY_INTEGER;
27
28 BEGIN
29
30 ln_Idx := pt_UserData.COUNT + 1;
31
32 pt_UserData(ln_Idx).id := air_UserData.id;
33 pt_UserData(ln_Idx).col1 := air_UserData.col1;
34 pt_UserData(ln_Idx).tmsp := SYSTIMESTAMP;
35
36 END;
37
38 PROCEDURE p_Write
39 IS
40
41 BEGIN
42
43 FORALL li_Idx IN INDICES OF pt_UserData
44 INSERT
45 INTO
46 user_data_hist
47 VALUES
48 pt_UserData(li_Idx);
49
50 END;
51 END;
52 /
Package body created.
SQL>
SQL> CREATE OR REPLACE TRIGGER preu_s_user_data BEFORE UPDATE ON user_data
2 DECLARE
3
4 BEGIN
5
6 pkg_audit_user_data.p_Init;
7
8 END;
9 /
Trigger created.
SQL> CREATE OR REPLACE TRIGGER preu_r_user_data BEFORE UPDATE ON user_data
2 FOR EACH ROW
3 DECLARE
4
5 lc_Row user_data%ROWTYPE;
6
7 BEGIN
8
9 lc_Row.id := :NEW.id;
10 lc_Row.col1 := :NEW.col1;
11
12 pkg_audit_user_data.p_Log
13 ( lc_Row
14 );
15
16 END;
17 /
Trigger created.
SQL> CREATE OR REPLACE TRIGGER postu_s_user_data AFTER UPDATE ON user_data
2 DECLARE
3
4 BEGIN
5
6 pkg_audit_user_data.p_Write;
7
8 END;
9 /
Trigger created.
SQL>
SQL>
SQL> insert
2 into
3 user_data
4 select
5 rownum,
6 dbms_random.string('u',20)
7 from
8 dual
9 connect by
10 level <=10
11 /
10 rows created.
SQL> select * from user_data
2 /
ID COL1
1 GVZHKXSSJZHUSLLIDQTO
2 QVNXLTGJXFUDUHGYKANI
3 GTVHDCJAXLJFVTFSPFQI
4 CNVEGOTDLZQJJPVUXWYJ
5 FPOTZAWKMWHNOJMMIOKP
6 BZKHAFATQDBUVFBCOSPT
7 LAQAIDVREFJZWIQFUPMP
8 DXFICIPCBCFTPAPKDGZF
9 KKSMMRAQUORRPUBNJFCK
10 GBLTFZJAOPKFZFCQPGYW
10 rows selected.
SQL> select * from user_data_hist
2 /
no rows selected
SQL>
SQL> MERGE
2 INTO
3 user_data a
4 USING
5 ( SELECT
6 rownum + 8 id,
7 dbms_random.string('u',20) col1
8 FROM
9 dual
10 CONNECT BY
11 level <= 10
12 ) b
13 ON (a.id = b.id)
14 WHEN MATCHED THEN
15 UPDATE SET a.col1 = b.col1
16 WHEN NOT MATCHED THEN
17 INSERT(a.id,a.col1)
18 VALUES (b.id,b.col1)
19 /
10 rows merged.
SQL> select * from user_data_hist
2 /
ID COL1 TMSP
9 XGURXHHZGSUKILYQKBNB 05-AUG-11 10.04.15.577989
10 HLVUTUIFBAKGMXBDJTSL 05-AUG-11 10.04.15.578090
SQL> select * from v$version
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - ProductionHTH
David -
Before and After insert or update rowcount
Hi
I have several extract objects procs which are calling various build objects procs which in turn are inserting or updating the tables...now when i run these objects sometimes i get no errors and everything seems to be running perfectly but the tables do not get updated ? now what i am trying to achieve here is get some kind of summary where i can see the before and after rowcount..for that i have created a table of every extract object proc and another table with the coressponding tables being updated by tht proc...can anyone pls tell me how should i look into these procs and how do i get the rowcount for a particular table before and after the procedure was run ?
Thanks a lot in advanceHi,
On which version of RDBMS are you working , because if you're on 10g then just enable auditing or even FGA on the tables were you want to see the changes,
Then query the DBA-AUDIT (not sure of the name anymore) view.
If not then create a audit package yourself.
something like
create or replace package pck$audit as
procedure prc$check_tablecount(p_tablename IN VARCHAR2, p_status IN VARCHAR2);
end;
create or replace package body pck$audit as
procedure prc$check_tablecount(p_tablename IN VARCHAR2,p_status IN VARCHAR2) IS
sqlstr VARCHAR2(100);
v_count NUMBER;
begin
sqlstr := 'SELECT COUNT(*) FROM '||p_tablename;
EXECUTE IMMEDIATE sqlstr into v_count; --could by 'using v_count' check syntax for this
INSERT INTO audit_table(table_name,total_count,status,time_stamp)
VALUES(p_tablename,v_count,p_status,SYSTIMESTAMP);
COMMIT;
end;
end;
you can elaborate on this creating additional procedure checking differences in total_count on same table at same time.
Now call this procedure before starting your insert-delete- on your table make sure you put the parameters correct eg p_status => 'begin procedure'
and call it again after your commit in your procedure.
Hope this helps you out
Erwin -
Oracle forms 10g,multiple insert and update problem
Hi,
I have tabular form(4 records displayed) with one datablock(based on a view).
After querying the form could not update all the records but only first record value can select from LOV.
I called a procedure in in-insert and on-update
The query is lik this
PACKAGE BODY MAPPING IS
PROCEDURE INSERT_ROW(EVENT_NAME IN VARCHAR2)
IS
BEGIN
IF (EVENT_NAME = 'ON-INSERT') THEN
INSERT INTO XX_REC_MAPPING
(BRANCH_CODE,COLLECTION_ID,PAY_MODE_ID,RECEIPT_METHOD,CREATED_BY,
CREATION_DATE,LAST_UPDATED_BY,LAST_UPDATE_DATE,LAST_UPDATE_LOGIN)
VALUES
( :XX_REC_MAPPING.OFFICE_CODE,
:XX_REC_MAPPING.COLLECTION_ID,
:XX_REC_MAPPING.PAY_MODE_ID,
:XX_REC_MAPPING.RECEIPT_METHOD,
:XX_REC_MAPPING.CREATED_BY,
:XX_REC_MAPPING.CREATION_DATE,
:XX_REC_MAPPING.LAST_UPDATED_BY,
:XX_REC_MAPPING.LAST_UPDATE_DATE,
:XX_REC_MAPPING.LAST_UPDATE_LOGIN);
ELSIF (EVENT_NAME = 'ON-UPDATE') THEN
UPDATE XX_REC_MAPPING
SET BRANCH_CODE=:XX_REC_MAPPING.OFFICE_CODE,
COLLECTION_ID=:XX_REC_MAPPING.COLLECTION_ID,
PAY_MODE_ID=:XX_REC_MAPPING.PAY_MODE_ID,
RECEIPT_METHOD=:XX_REC_MAPPING.RECEIPT_METHOD,
LAST_UPDATED_BY=:XX_REC_MAPPING.LAST_UPDATED_BY,
LAST_UPDATE_DATE=:XX_REC_MAPPING.LAST_UPDATE_DATE,
LAST_UPDATE_LOGIN=:XX_REC_MAPPING.LAST_UPDATE_LOGIN
WHERE ROWID=:XX_REC_MAPPING.ROW_ID;
END IF;
END INSERT_ROW;
END MAPPING;
Whether the table gets looked or sholud i use some other trigger or loops ?
someone suggest me how to edit this query for multiple update.
Thanks
sat33I called a procedure in in-insert and on-updateWhy are you writing this code in the first place? If you have a block based on an updatable view, just let Forms do the inserts and updates.
If it's not an updatable view, use instead of triggers on the view.
See this current thread too:
INSTEAD of Trigger View for an Oracle EBS New form development -
Inserting and Updating records in ORACLE using WebDynpro Java
Hi All
I got connected to oracle backend (using my previous thread), but now i want to insert and update the records
i have created views for insert and update,
Thanks in advance
SushmaHi shusma..
chk this link..
<b><u>Creating Connection</u></b>
package com.sap.xirig;
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
public class DBLookup {
String Conn_Status = "Not Connected";
String Language_Desc = "Empty";
String Language_Cd = "Empty";
Connection conn;
Context ctx;
DataSource ds;
//Constructor for the DBLookup object
public DBLookup {
try {
ctx = new InitialContext();
if (ctx == null) {
throw new Exception("Boom - No Context");
// If JDBC 2.0 connection is used please create the DataSource object as below
// ds = (DataSource) ctx.lookup("jdbc/ORACLEDATASOURCE");
// If JDBC 1.0 connection is used please create the DataSource object as below
// ds = (DataSource) ctx.lookup("jdbc/notx/ORACLEDATASOURCE");
if (ds == null) {
throw new Exception("Boom - No dataSource");
catch (Exception e) {
e.printStackTrace();
public String getLanguageDesc(String v_str) {
Statement stmt = null;
ResultSet rst = null;
try {
if (ds != null) {
conn = ds.getConnection();
Conn_Status = "Could not get connection to
datasource";
if (conn != null) {
Conn_Status = "Got Connection " +
conn.toString();
stmt = conn.createStatement();
rst = stmt.executeQuery("SELECT
LANGUAGE_DESC FROM LANGUAGETRANSLATION WHERE LANGUAGE_CD='" + v_str +
if (rst.next()) {
Language_Desc = rst.getString(1);
conn.close();
catch (Exception e) {
e.printStackTrace();
finally {
if (rst != null) {
try {
rst.close();
catch (Exception e) {
e.printStackTrace();
if (stmt != null) {
try {
stmt.close();
catch (Exception e) {
e.printStackTrace();
if (conn != null) {
try {
conn.close();
catch (Exception e) {
e.printStackTrace();
return Language_Desc;
http://e-docs.bea.com/wls/docs81/oracle/API_joci.html
Hope this will help u..
URs GS -
Hi All;
I want to find out all inserts and updates of a spesific table. For instance a package l,ke that
CREATE OR REPLACE PACKAGE BODY param_test IS
PROCEDURE ins_test IS
BEGIN
insert INTO parameter_value VALUES (2);
INSERT INTO parameter_value VALUES (9);
INSERT INTO
parameter_value VALUES (4);
insert INTO parameter_value VALUES (54);
END ins_test;
END param_test;I am querying user_source view. My query is below.
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as SYS
SQL> SELECT us1.NAME, us1.line, us1.text
2 FROM user_source us1,
3 (SELECT us2.line, us2.NAME, us2.text
4 FROM user_source us2
5 WHERE regexp_like(upper(us2.text), '[[:space:]]*PARAMETER_VALUE[[:space:]]*')) us3
6 WHERE us3.line - 1 = us1.line
7 AND us1.NAME = us3.NAME
8 AND regexp_like(upper(us1.text), '[[:space:]]*(INSERT[[:space:]]*INTO|UPDATE)[[:space:]]*')
9 /
NAME LINE TEXT
PARAM_TEST 9 insert INTO parameter_value VALUES (2);
PARAM_TEST 12 INSERT INTO
SQL> My question is "Are tehre any solutions to overcome this situation?"
Kindly Regards...You might be better off combining into your attack the use of user_dependencies. This will tell you what objects e.g., code is dependent on your table and then you can search the source of those modules for inserts and updates into the table. Even then you'll never be sure, especially if dynamic SQL is used as the statement may be pieced together from various bits if strings, as then user_dependencies won't contain the reference.
-
Stored proecedure tutorial for insert, delete, update,select
I want to integrate the stored procedure in my project
i am using jsp,
any one suggest me, stored proecedure tutorial for insert, delete, update,select
thanx.Whether you are using JSP or not should not affect your decision (though I would recommend checking out the MVC pattern, and recommend against doing data access code from your JSP's).
You simply need one tutorial on how to invoke a stored procedure. The stored procedure you write can have INSERT, SELECT, UPDATE, DELETE, whatever. You simply have to master the concepts involved in java.sql.CallableStatement. (And then you can get more fancy with vendor-specific extensions).
However, I am a bit confused. You want a tutorial on stored procedures, but then you indicate very normal DML statements like INSERT, UPDATE and DELETE. All of these (queries, DML and stored procedures) fall under the general umberella of JDBC. So, it is always a good place to start with a plain ole JDBC tutorial.
java.sun.com/docs/books/tutorial/jdbc/index.html
www.onjava.com/pub/a/onjava/2003/08/13/stored_procedures.html
- Saish -
ORA-01456 : may not perform insert/delete/update operation
When I use following stored procedure with crystal reports, following error occurs.
ORA-01456 : may not perform insert/delete/update operation inside a READ ONLY transaction
Kindly help me on this, please.
My stored procedure is as under:-
create or replace
PROCEDURE PROC_FIFO
(CV IN OUT TB_DATA.CV_TYPE,FDATE1 DATE, FDATE2 DATE,
MSHOLD_CODE IN NUMBER,SHARE_ACCNO IN VARCHAR)
IS
--DECLARE VARIABLES
V_QTY NUMBER(10):=0;
V_RATE NUMBER(10,2):=0;
V_AMOUNT NUMBER(12,2):=0;
V_DATE DATE:=NULL;
--DECLARE CURSORS
CURSOR P1 IS
SELECT *
FROM FIFO
WHERE SHARE_TYPE IN ('P','B','R')
ORDER BY VOUCHER_DATE,
CASE WHEN SHARE_TYPE='P' THEN 1
ELSE
CASE WHEN SHARE_TYPE='R' THEN 2
ELSE
CASE WHEN SHARE_TYPE='B' THEN 3
END
END
END,
TRANS_NO;
RECP P1%ROWTYPE;
CURSOR S1 IS
SELECT * FROM FIFO
WHERE SHARE_TYPE='S'
AND TRANS_COST IS NULL
ORDER BY VOUCHER_DATE,TRANS_NO;
RECS S1%ROWTYPE;
--BEGIN QUERIES
BEGIN
DELETE FROM FIFO;
--OPENING BALANCES
INSERT INTO FIFO
VOUCHER_NO,VOUCHER_TYPE,VOUCHER_DATE,TRANS_QTY,TRANS_AMT,TRANS_RATE,
SHOLD_CODE,SHARE_TYPE,ACC_NO,SHARE_CODE,TRANS_NO)
SELECT TO_CHAR(FDATE1,'YYYYMM')||'001' VOUCHER_NO,'OP' VOUCHER_TYPE,
FDATE1-1 VOUCHER_DATE,
SUM(
CASE WHEN
--((SHARE_TYPE ='S' AND DTAG='Y')
SHARE_TYPE IN ('P','B','R','S') THEN
TRANS_QTY
ELSE
0
END
) TRANS_QTY,
SUM(TRANS_AMT),
NVL(CASE WHEN SUM(TRANS_AMT)<>0
AND
SUM
CASE WHEN SHARE_TYPE IN ('P','B','R','S') THEN
TRANS_QTY
ELSE
0
END
)<>0 THEN
SUM(TRANS_AMT)/
SUM
CASE WHEN SHARE_TYPE IN ('P','B','R','S') THEN
TRANS_QTY
ELSE
0
END
) END,0) TRANS_RATE,
MSHOLD_CODE SHOLD_CODE,'P' SHARE_TYPE,SHARE_ACCNO ACC_NO,
SHARE_CODE,0 TRANS_NO
FROM TRANS
WHERE ACC_NO=SHARE_ACCNO
AND SHOLD_CODE= MSHOLD_CODE
AND VOUCHER_DATE<FDATE1
--AND
--(SHARE_TYPE='S' AND DTAG='Y')
--OR SHARE_TYPE IN ('P','R','B'))
group by TO_CHAR(FDATE1,'YYYYMM')||'001', MSHOLD_CODE,SHARE_ACCNO, SHARE_CODE;
COMMIT;
--TRANSACTIONS BETWEEND DATES
INSERT INTO FIFO
TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
VOUCHER_DATE,TRANS_QTY,
TRANS_RATE,TRANS_AMT,SHOLD_CODE,SHARE_CODE,ACC_NO,
DTAG,TRANS_COST,SHARE_TYPE
SELECT TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
VOUCHER_DATE,TRANS_QTY,
CASE WHEN SHARE_TYPE='S' THEN
NVL(TRANS_RATE-COMM_PER_SHARE,0)
ELSE
NVL(TRANS_RATE+COMM_PER_SHARE,0)
END
,TRANS_AMT,SHOLD_CODE,SHARE_CODE,ACC_NO,
DTAG,NULL TRANS_COST,SHARE_TYPE
FROM TRANS
WHERE ACC_NO=SHARE_ACCNO
AND SHOLD_CODE= MSHOLD_CODE
AND VOUCHER_DATE BETWEEN FDATE1 AND FDATE2
AND
((SHARE_TYPE='S' AND DTAG='Y')
OR SHARE_TYPE IN ('P','R','B'));
COMMIT;
--PURCHASE CURSOR
IF P1%ISOPEN THEN
CLOSE P1;
END IF;
OPEN P1;
LOOP
FETCH P1 INTO RECP;
V_QTY:=RECP.TRANS_QTY;
V_RATE:=RECP.TRANS_RATE;
V_DATE:=RECP.VOUCHER_DATE;
dbms_output.put_line('V_RATE OPENING:'||V_RATE);
dbms_output.put_line('OP.QTY2:'||V_QTY);
EXIT WHEN P1%NOTFOUND;
--SALES CURSOR
IF S1%ISOPEN THEN
CLOSE S1;
END IF;
OPEN S1;
LOOP
FETCH S1 INTO RECS;
EXIT WHEN S1%NOTFOUND;
dbms_output.put_line('OP.QTY:'||V_QTY);
dbms_output.put_line('SOLD:'||RECS.TRANS_QTY);
dbms_output.put_line('TRANS_NO:'||RECS.TRANS_NO);
dbms_output.put_line('TRANS_NO:'||RECS.TRANS_NO);
IF ABS(RECS.TRANS_QTY)<=V_QTY
AND V_QTY<>0
AND RECS.TRANS_COST IS NULL THEN
--IF RECS.TRANS_COST IS NULL THEN
--dbms_output.put_line('SOLD:'||RECS.TRANS_QTY);
--dbms_output.put_line('BAL1:'||V_QTY);
UPDATE FIFO
SET TRANS_COST=V_RATE,
PUR_DATE=V_DATE
WHERE TRANS_NO=RECS.TRANS_NO
AND TRANS_COST IS NULL;
COMMIT;
dbms_output.put_line('UPDATE TRANS_NO:'||RECS.TRANS_NO);
dbms_output.put_line('OP.QTY:'||V_QTY);
dbms_output.put_line('SOLD:'||RECS.TRANS_QTY);
dbms_output.put_line('TRANS_NO:'||RECS.TRANS_NO);
dbms_output.put_line('BAL2:'||TO_CHAR(RECS.TRANS_QTY+V_QTY));
END IF;
IF ABS(RECS.TRANS_QTY)>ABS(V_QTY)
AND V_QTY<>0 AND RECS.TRANS_COST IS NULL THEN
UPDATE FIFO
SET
TRANS_QTY=-V_QTY,
TRANS_COST=V_RATE,
TRANS_AMT=ROUND(V_QTY*V_RATE,2),
PUR_DATE=V_DATE
WHERE TRANS_NO=RECS.TRANS_NO;
--AND TRANS_COST IS NULL;
COMMIT;
dbms_output.put_line('UPDATING 100000:'||TO_CHAR(V_QTY));
dbms_output.put_line('UPDATING 100000 TRANS_NO:'||TO_CHAR(RECS.TRANS_NO));
INSERT INTO FIFO
TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
VOUCHER_DATE,TRANS_QTY,
TRANS_RATE,TRANS_AMT,SHOLD_CODE,SHARE_CODE,ACC_NO,
DTAG,TRANS_COST,SHARE_TYPE,PUR_DATE
VALUES
MCL.NEXTVAL,RECS.VOUCHER_NO,RECS.VOUCHER_TYPE,
RECS.VOUCHER_DATE,RECS.TRANS_QTY+V_QTY,
RECS.TRANS_RATE,(RECS.TRANS_QTY+V_QTY)*RECS.TRANS_RATE,RECS.SHOLD_CODE,
RECS.SHARE_CODE,RECS.ACC_NO,
RECS.DTAG,NULL,'S',V_DATE
dbms_output.put_line('INSERTED RECS.QTY:'||TO_CHAR(RECS.TRANS_QTY));
dbms_output.put_line('INSERTED QTY:'||TO_CHAR(RECS.TRANS_QTY+V_QTY));
dbms_output.put_line('INSERTED V_QTY:'||TO_CHAR(V_QTY));
dbms_output.put_line('INSERTED RATE:'||TO_CHAR(V_RATE));
COMMIT;
V_QTY:=0;
V_RATE:=0;
EXIT;
END IF;
IF V_QTY>0 THEN
V_QTY:=V_QTY+RECS.TRANS_QTY;
ELSE
V_QTY:=0;
V_RATE:=0;
EXIT;
END IF;
--dbms_output.put_line('BAL3:'||V_QTY);
END LOOP;
V_QTY:=0;
V_RATE:=0;
END LOOP;
CLOSE S1;
CLOSE P1;
OPEN CV FOR
SELECT TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
VOUCHER_DATE,TRANS_QTY,
TRANS_RATE,TRANS_AMT,SHOLD_CODE,B.SHARE_CODE,B.ACC_NO,
DTAG,TRANS_COST,SHARE_TYPE, B.SHARE_NAME,A.PUR_DATE
FROM FIFO A, SHARES B
WHERE A.SHARE_CODE=B.SHARE_CODE
--AND A.SHARE_TYPE IS NOT NULL
ORDER BY VOUCHER_DATE,SHARE_TYPE,TRANS_NO;
END PROC_FIFO;
Thanks and Regards,
LuqmanCopy from TODOEXPERTOS.COM
Problem Description
When running a RAM build you get the following error as seen in the RAM build
log file:
14:52:50 2> Updating warehouse tables with build information...
Process Terminated In Error:
[Oracle][ODBC][Ora]ORA-01456: may not perform insert/delete/update operation inside a READ ONLY transaction
(SIGENG02) ([Oracle][ODBC][Ora]ORA-01456: may not perform insert/delete/update operation inside a READ ONLY transaction
) Please contact the administrator of your Oracle Express Server application.
Solution Description
Here are the following suggestions to try out:
1. You may want to use oci instead of odbc for your RAM build, provided you
are running an Oracle database. This is setup through the RAA (relational access
administrator) maintenance procedure.
Also make sure your tnsnames.ora file is setup correctly in either net80/admin
or network/admin directory, to point to the correct instance of Oracle.
2. Commit or rollback the current transaction, then retry running your
RAM build. Seems like one or more of your lookup or fact tables have a
read-only lock on them. This occurs if you modify or add some records to your
lookup or fact tables but forget to issue a commit or rollback. You need to do
this through SQL+.
3. You may need to check what permissions has been given to the relational user.
The error could be a permissions issue.
You must give 'connect' permission or roll to the RAM/relational user. You may
also try giving 'dba' and 'resource' priviliges/roll to this user as a test. Inorder to
keep it simple, make sure all your lookup, fact and wh_ tables are created on
a single new tablespace. Create a new user with the above privileges as the
owner of the tablespace, as well as the owner of the lookup, fact and wh_
tables, inorder to see if this is a permissions issue.
In this particular case, the problem was resolved by using oci instead of odbc,
as explained in suggestion# 1.
Maybe you are looking for
-
Ibooks Author and Read Alouds...
Hi- I am using ibooks author in a classroom with my students with special needs. Any ideas on what is the best way to have the books "read aloud" Thanks. Mark
-
Connecting exchange to hp eprint
I am unable to connect my work outlook account to eprint on my ipad. When i go to add email account. I can enter my email address, domain, password and hostname. There is no place to enter my username that is required for my serve to accept. Please a
-
Auto payment is availabe for interface or API?
Dear all I got some problem on auto payment. Is it possible to pay invoices automatically by interface or API? Thanks. Best Regards Elton
-
Desktop covered in multi-coloured, pixilated pattern
I've read other threads where people seem to be having the same problem I'm seeing, and the screen shots look identical. I am not convinced it's a hardware issue in my case, and none of the solutions I've seen recommended resolve the problem. Due to
-
11" MBA Battery Problem!!
So I've fully charged my MBA. When it reached 100% I unplugged the charger and after exactly 4 minutes the battery went down to 96%?!! Also, the battery meter keeps changing from 8 hrs to 4 and then went up to 5 and then 7? Is there something wrong w