PL/SQL insert based on conditions
I'd appreciate any help I can get. I learn PL/SQL and have stumbled upon a problem, so please help me to find an appropriate way to deal with this situation I am running Oracle 11 GR 2
My diagram:
CREATE TABLE "ENTRY"
(
'TYPE' VARCHAR2 (5 CHAR) ,
'TRANSACTION' VARCHAR2()5 TANK),
'OWNER' VARCHAR2 (5 CHAR)
);
CREATE TABLE "VIEW"
(
'TYPE' VARCHAR2 (5 CHAR) ,
'TRANSACTION' VARCHAR2 (5 CHAR),
'OWNER' VARCHAR2 (5 CHAR)
);
CREATE TABLE "REJECTED"
(
'TYPE' VARCHAR2 (5 CHAR) ,
'TRANSACTION' VARCHAR2 (5 CHAR),
'OWNER' VARCHAR2 (5 CHAR)
);
My sample data:
insert into entry (type, transaction, owner) values (11111, 11111, 11111);
insert into entry (type, transaction, owner) values (22222, 22222, 22222);
Now for the confusing part, I wrote this procedure which has to copy the values from the table ENTRY in the table VIEW if a record is no specific combination (transaction AND owner). If such an association exists in the table for VIEW this record should then go to the REJECTED table. This procedure done that but on the executions of the procedure, I get more entries in the REJECTED table so my question is how do to limit inserts them into the table of REJECTED - if a record already exists in the REJECTED table then do nothing.
create or replace PROCEDURE COPY AS
v_owner_entry ENTRY.owner%TYPE;
v_transaction_entry ENTRY.transaction%TYPE;
v_owner VIEW.owner%TYPE;
v_transaction VIEW.transaction%TYPE;
begin
begin
select e.owner, e.transaction, v.owner, v.transaction
into v_owner_entry, v_transaction_entry, v_owner, v_transaction
from entry e, view v
where e.owner = v.owner and e.transaction = v.transaction;
EXCEPTION when too_many_rows
then insert into REJECTED ( TYPE, TRANSACTION, OWNER ) SELECT s1.TYPE, s1.TRANSACTION, s1.OWNER FROM ENTRY s1;
when no_data_found THEN insert into VIEW ( TYPE, TRANSACTION, OWNER ) SELECT s.TYPE, s.TRANSACTION, s.OWNER FROM ENTRY s;
end;
end;
Any suggestions guys?
See you soon!
UPDATE
Sorry if the original message was not enough - clear the procedure must replicate data (on a daily basis) of DB1 to DB2 and insert in the VIEW or REJECTED depending on the conditions. Here is a picture, it would be perhaps more clearly:
Hello
your procedure could look something like this:
declare -- Local variables here i integer; begin -- Test statements here INSERT INTO REJECTED (TYPE, TRANSACTION, OWNER) SELECT ENTRY.TYPE, ENTRY.TRANSACTION, ENTRY.OWNER FROM ENTRY, VIEW WHERE ENTRY.OWNER = VIEW.OWNER AND ENTRY.TRANSACTION = VIEW.TRANSACTION AND NOT EXISTS (SELECT NULL FROM REJECTED VW2 WHERE VW2.OWNER = ENTRY.OWNER AND VW2.TRANSACTION = ENTRY.TRANSACTION); INSERT INTO VIEW (TYPE, TRANSACTION, OWNER) SELECT TYPE, TRANSACTION, OWNER FROM ENTRY WHERE NOT EXISTS (SELECT NULL FROM VIEW WHERE ENTRY.OWNER = VIEW.OWNER AND ENTRY.TRANSACTION = VIEW.TRANSACTION); COMMIT; end;
Edited: Use SQL syntax
Tags: Database
Similar Questions
-
Must insert based on condition
Hi friends,
I have a form with the following fields
Course_name, duration, on_date
A person several can log into the app with a form of opening with the fields above...
After having all the details in the form of filling and if he pressed 'Send' button, then it will insert in the table...
*) Assume that assume, if a person (for the first time) is logging into the application and fills it with the following details in the form
-> course name: oracle
-> Duration: 21:00 pm
-> date: 11/06/2011
and if he pressed the means of the "submit" button, it will insert in the table...
*) Guess if person B is accessing the request (for the first time, once) and if he meets with the same means (i.e) of following details
-> course name: oracle
-> Duration: 21:00 pm
-> date: 11/06/2011
It should not be allowed to 'submit' and we must say the error message like
* "This duration for this course and this date is already reserved by the other person, in order to select another date" * "
(IE), it should not insert into the table... Because the content of the coursename, duration, date is already inserted...
It's that these three columns of the row of suceeding values must not be equal. How can I achieve this.
Kind regards
MiniHey Mini,
Change uppercase in the where clause similar to below and this should solve your problem.
SELECT 1 FROM course WHERE UPPER(course_name) = UPPER(:P1_COURSE_NAME) AND duration = :P1_DURATION AND date = :P1_DATE
Thank you
Paul
Published by: Paul Broughton on June 11, 2011 13:41
-
Insert, based on condition (constraint unique key)
Hello
Need help with checing the uniqeness of value before inserting
for example
have two table
Book book_owner years and need to inserting 100 rows in the table, but there are a few unique constraints challenged on the table where need to chek the value existing or not, if the value is exisitn jump insertion otherwise insert the value
Here is an example
Insert in the BOOK (BOOK_ID, CNT, ALT_CNT, ROW_INSERT_TMSTMP, ROW_LAST_UPDT_TMSTMP, BOOK_ID)
Values (SEQ_BOOK_ID.nextval, 50, 500, sysdate, sysdate, ' 123456');
commit;
/
Insert into BOOK_OWNER (BOOK_OWNER_ID, BOOK_ID, USER_ID) Values (SEQ_BOOK_OWNER_ID.nextval, SEQ_BOOK_ID.currval, "456");
commit;
/
Insert in the BOOK (BOOK_ID, CNT, ALT_CNT, ROW_INSERT_TMSTMP, ROW_LAST_UPDT_TMSTMP, BOOK_ID)
Values (SEQ_BOOK_ID.nextval, 50, 500, sysdate, sysdate, ' 678901');
commit;
/
Insert into BOOK_OWNER (BOOK_OWNER_ID, BOOK_ID, USER_ID) Values (SEQ_BOOK_OWNER_ID.nextval, SEQ_BOOK_ID.currval, ' 678');
commit;
/
Insert in the BOOK (BOOK_ID, CNT, ALT_CNT, ROW_INSERT_TMSTMP, ROW_LAST_UPDT_TMSTMP, BOOK_ID)
Values (SEQ_BOOK_ID.nextval, 50, 500, sysdate, sysdate, ' 5123987');
commit;
/
Insert into BOOK_OWNER (BOOK_OWNER_ID, BOOK_ID, USER_ID) Values (SEQ_BOOK_OWNER_ID.nextval, SEQ_BOOK_ID.currval, ' 896');
commit;
/
in the Book table BOOK_ID has the unique constraint and the data type is varchar type
BOOK_OWNER table USER_ID) has the unique constraint and as a varchar data type
I use oracle 10gDouble post!
-
Based where conditional clause...
dear team, i have following code.. Declare gv_flag1 Varchar2(1) := 'N'; gv_flag2 Varchar2(1) := 'N'; gv_flag3 Varchar2(1) := 'N'; all_where1 Varchar2(250); all_where2 Varchar2(250); ALL_where3 Varchar2(250); V_QTY Number; Begin If gv_flag1 = 'N' Then all_where1 := 'AND '||'V.OWNER = ''PROD'''; End If; DBMS_OUTPUT.PUT_LINE(all_where1); If gv_flag2 = 'N' Then all_where2 := 'AND '||'V.OPERATION NOT LIKE (''10%'')'; End If; DBMS_OUTPUT.PUT_LINE(all_where2); If gv_flag3 = 'N' Then all_where3 := 'AND '||'V.OPERATION NOT LIKE (''07%'')'; End If; DBMS_OUTPUT.PUT_LINE(all_where3); --select based on conditions.. End; NOW I want where conditions in select statment to be conditional... which means if flag1='N' and flag2 = 'N' then use both all_where1 and all_where2 in *where* clause statement... if flag1='N' and flag3 = 'N' then then use all_where1 and all_where 3 in *where* clause of select statement... if all there flag = 'N' then use all_where conditions in *where* clause of select statement... i have 3 flags, which means total of 9 combinations, is there any simpler way to do such kind of thing?? please assist me nic
Nicloei W wrote:
Hi Jeenesh,What happens if Flag2 = 'Y' and Indicateur3 = 'Y' in this case, I want only the condition with Flag1
concerning
NICSQL> ed Wrote file afiedt.buf 1 Declare 2 gv_flag1 Varchar2(1) := 'N'; 3 gv_flag2 Varchar2(1) := 'Y'; 4 gv_flag3 Varchar2(1) := 'Y'; 5 --all_where1 Varchar2(250); 6 --all_where2 Varchar2(250); 7 --ALL_where3 Varchar2(250); 8 lc_query varchar2(1000):= 'select count(*) from test v '; 9 lc_where varchar2(500) := ' where 1 = 1 '; 10 V_QTY Number; 11 Begin 12 If gv_flag1 = 'N' Then 13 lc_where := lc_where||' AND V.OWNER = ''TEST'''; 14 End If; 15 If gv_flag2 = 'N' Then 16 lc_where := lc_where||' AND V.OPERATION NOT LIKE ''10%'''; 17 End If; 18 If gv_flag3 = 'N' Then 19 lc_where := lc_where||' AND V.OPERATION NOT LIKE ''07%'''; 20 End If; 21 lc_query := lc_query||lc_where; 22 dbms_output.put_line(lc_query); 23 dbms_output.put_line('-----------'); 24 execute immediate lc_query into v_qty; 25 dbms_output.put_line('Count: '||v_qty); 26* End; SQL> / select count(*) from test v where 1 = 1 AND V.OWNER = 'TEST' ----------- Count: 3 PL/SQL procedure successfully completed.
-
2 PL/SQL insert new string in the string specified to a specific Position
Hello
PL/SQL insert new string in the string specified to a specific Position
Continuing the previous thread has answered, I would like to know how to cut the data after the underscore ("_").
Example:
Old chain: D100_RT
New string:APPROX100 d.
Here after, what is there after that execution should be deleted.
Thank you
Suppose that the string = D100_RT
select substr('D100_RT', 1, instr('D100_RT','_')-1 ) from dual
-
How to solve the error ORA-00001 in SQL Insert?
Hi all, I need your help appreciated.
I do a plsql procedure that inserts a line according to the value of the slider, I have error oracle ORA-00001: unique constraint (constraint_name) violated.
This message may appear if a duplicate entry exists at a different level: in the RDBMS MySQL, I have the syntax IGNORES to solve this error of duplication... and in Oracle?
Thanks for your time and your advice.
Miguelitouser6317803 wrote:
How to solve the error ORA-00001 in SQL Insert?ORA-00001 means table a unique/primary key / index and you attempt to insert a row with the key value already exists in the table. I'll assume table has a primary key on COUNTRY_ID. Then modify SQL for:
SQL = "INSERT INTO COUNTRIES (COUNTRY_ID, COUNTRY_NAME, REGION_ID) SELECT"BZ","BLZ", 3 DOUBLE WHERE DOES NOT EXIST (SELECT 1 FROM COUNTRIES WHERE COUNTRY_ID ="BZ").
There is a good chance COUNTRY table also has unique key/index on COUNTRY_NAME. If so use:
SQL = "INSERT INTO COUNTRIES (COUNTRY_ID, COUNTRY_NAME, REGION_ID) SELECT"BZ","BLZ", 3 DOUBLE WHERE DOES NOT EXIST (SELECT 1 FROM COUNTRIES WHERE COUNTRY_ID = 'BZ' OR 'BLZ' = COUNTRY_NAME).
SY.
-
Problem with PL/SQL insert query
Hello to all the genius... Vikram im, Im new in the world of the apex and pl/sql... I need everything that you guys help... This is my first application user (for example)
name of the table - form
name of the column - f_no number, name varchar2, number of salary.
Apex page n - p1_f_no, p1_name, p1_sal
Now my problem is the query that is below works in the workshop of sql (insertion of data in the table in shape) and can be seen using the select query... but when I implement this in the apex... It shows - in all areas:
declare
v_no number (3);
v_Name varchar2 (20);
v_sal number (10);
Start
Insert in the form values (: v_no,: v_name,: v_sal);
end;
IM using this query in the Process button,
Thank you
-Best regards,.
VikramMahir M. Quluzade have already responded.
Published by: Gokhan Atil on 03.May.2011 12:45
-
How to close a sql insert?
I have an ASP poll that takes questions from a sql database. The results table to store the answer is simple. It has a field ID result, QID, and response.
Given that the survey is built dynamically, the number of questions in each survey is limitless. So my problem. How to build a sql Insert loop thru and add value to the db for QID?There is a tutorial on the www.charon.co.uk that may be of some use to you as
It is written for ASP.--
Paul Whitham
Certified Professional Dreamweaver MX2004
Adobe Community Expert - DreamweaverValleybiz Web design
www.valleybiz.NET"Lucky Kitty"
wrote in message
News:f2f1tk$KVG$1@forums. Macromedia.com...
> I have an ASP poll that takes questions from a sql database. Results
> table to store the answer is simple. It has an ID of result, QID, and response
> field.
>
> Since the investigation is built dynamically, the number of questions in each
> investigation
> is limitless. So my problem. How to build a sql insert
> statement to
> loop thru and add value to the db for QID?
> -
PL/SQL Insert Row Assign PK Value
I try to insert a row of data into a table and assign a primary key value. I want to give the first available primary key, not only the nextval in the maxval. Is there a way to do it cleanly, or will I need to create a cursor to do? If I need to create a slider or the sequence, how do I declare it in my procedure? Do I need a sequence so that I couldn't just use a loop for? Please help - it seems such a simple thing, but it has left me speechless.CheRenee
Look at this,
SQL> Create table M_MOVIES(MOVIE_ID NUMBER not null); Table created SQL> Alter table M_MOVIES add constraint PROD_ID_PK primary key (MOVIE_ID); Table altered SQL> Insert Into M_movies 2 (Select level id_movies From dual connect by level <= 10); 10 rows inserted SQL> Commit; Commit complete SQL> CREATE SEQUENCE seq_avail_id 2 START WITH 1 3 INCREMENT BY 1 4 MAXVALUE 99999999 5 / Sequence created SQL> INSERT INTO m_movies(movie_id) VALUES(seq_avail_id.NEXTVAL); INSERT INTO m_movies(movie_id) VALUES(seq_avail_id.NEXTVAL) ORA-00001: unique constraint (SYSTEM.PROD_ID_PK) violated SQL> Drop SEQUENCE seq_avail_id; Sequence dropped SQL> Select max(movie_id) from m_movies; MAX(MOVIE_ID) ------------- 10 SQL> CREATE SEQUENCE seq_avail_id 2 START WITH 11 3 INCREMENT BY 1 4 MAXVALUE 99999999 5 / Sequence created SQL> INSERT INTO m_movies(movie_id) VALUES(seq_avail_id.NEXTVAL); 1 row inserted
Kind regards
Christian Balz -
SQL Help: Derive from 'News' columns based on condition
Hi all
Can someone help me with this please? I am trying to achieve in a SQL (no), if this can be done in two different stages, even that is fine too...
Thanks in advance,
Chavigny
For a "batch - id", there are several Transactions that are denoted by (cr_crncy_cd, dr_crncy_cd, recvr_cntry_cd), and the "NEW_BTCH_NM" column is basically a concatenation of 'BTCH_NM' + above 3 columns (with a ~)SELECT * FROM ( SELECT 2765 BTCH_ID,'payroll' BTCH_NM,'payroll~EUR~EUR~DE'NEW_BTCH_NM,'1234'TMPLT_ID FROM DUAL UNION SELECT 2765,'payroll','payroll~USD~USD~US','1235' FROM DUAL UNION SELECT 2765,'payroll','payroll~USD~USD~US','1236' FROM DUAL UNION SELECT 2765,'payroll','payroll~GBP~GBP~GB','1237' FROM DUAL UNION SELECT 2766,'SALARY','SALARY~USD~USD~US','1238' FROM DUAL UNION SELECT 2766,'SALARY','SALARY~USD~USD~US','1239' FROM DUAL ) T_BATCH;
I'm trying to derive two new columns "SEQ" & "Output_Batch_name".
The SEQ column:
Output_BTCH_NM:For every batch_id, the first row will be assigned by sequence.nextval. For all transactions within BTCH_ID, all the rows with same NEW_BTCH_NM, share the same sequence number if different, then SEQ.nextval for all distinct rows
EXPECTED RESULTSfor a given batch_id, if the NEW_BTCH_NM is the same for all transactions ( batch_id 2766 in the below example) , then Output_BTCH_NM = BTCH_NM should be marked for All transactions which belong to this Batch_id, Else Output_BTCH_NM = New_BTCH_NM END if
Published by: user10711957 on 25 Sep, 2010 16:37*BTCH_ID BTCH_NM NEW_BTCH_NM TMPLT_ID SEQ Output_BTCH_NM* 2765 payroll payroll~EUR~EUR~DE 1234 1 payroll~EUR~EUR~DE 2765 payroll payroll~GBP~GBP~GB 1237 2 payroll~GBP~GBP~GB 2765 payroll payroll~USD~USD~US 1235 3 payroll~USD~USD~US 2765 payroll payroll~USD~USD~US 1236 3 payroll~USD~USD~US 2766 SALARY SALARY~USD~USD~US 1238 4 SALARY 2766 SALARY SALARY~USD~USD~US 1239 4 SALARY
An extension of the solution of the (slightly modified) jiq
function my_sequence(whichval in varchar2) return number is begin if whichval = 'currval' then return your_sequence.currval; else return your_sequence.nextval; end if; end my_sequence; WITH t AS ( SELECT 2765 BTCH_ID,'payroll' BTCH_NM,'payroll~EUR~EUR~DE'NEW_BTCH_NM,'1234'TMPLT_ID FROM DUAL UNION SELECT 2765,'payroll','payroll~USD~USD~US','1235' FROM DUAL UNION SELECT 2765,'payroll','payroll~USD~USD~US','1236' FROM DUAL UNION SELECT 2765,'payroll','payroll~GBP~GBP~GB','1237' FROM DUAL UNION SELECT 2766,'SALARY','SALARY~USD~USD~US','1238' FROM DUAL UNION SELECT 2766,'SALARY','SALARY~USD~USD~US','1239' FROM DUAL ) select btch_id,btch_nm,new_btch_nm,tmplt_id, case when lag(seq,1) over (order by tmplt_id) = seq then my_sequence('currval') else my_sequence('nextval') end seq, out_btch_nm select btch_id,btch_nm,new_btch_nm,tmplt_id, dense_rank() over(partition by btch_id order by new_btch_nm) seq case when count(distinct new_btch_nm) over (partition by btch_id) = 1 then btch_nm else new_btch_nm end out_btch_nm from t
Concerning
Etbin
Posted before you see the following
the sequence # must be continuous, must avoid any shortfall or gaps with the numbering.
the foregoing must be the only user of its own sequence somehow and maybe...
Search for "sequence free gap"... http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:4343369880986
Edited by: Etbin on 26.9.2010 08:21 -
Insert (pl/sql) processes with treatment conditional table?
Hello guys!
I'm seriously lost now! I wrote the following process:
So, what's the problem?begin for i in 1..apex_application.g_f02.count loop insert into tbl_arbeit_zu_gebiet (lng_arbeitsschritt, str_bemerkung, int_bearbeiter, lng_gebiet, date_durchgefuehrt) select apex_application.g_f08(i), apex_application.g_f05(i), apex_application.g_f04(i), apex_application.g_f03(i), sysdate from dual; end loop; commit; end;
I have a report showing the 10 different categories and subcategories in a different column of type select_list. The user is able to select an entry in the list and must insert it into the database. My problem is that because of the loop line, all values are inserted, even if they already exist.
Do you know of a way I can find the value of each line before you perform the insertion. If the values of f05 and f03 exist jump the line and move forward?
Sorry if it's confusing, but I hope that you have an idea what my problem is.
I appreciate your help!
Thank you very much
SebastianHello
I had some typos. I fix those.
Copy the code and try again. If this does not work please also post error messages.I can't test code because I don't have your database objects and Apex page
BR, JAri
-
Dynamic action with multiple values of PL/SQL Expression as a condition
Hel
I am currently using Apex 4.0 for a schoolproject.
I have two selectlists (P8_BUSINESSRULETYPE - which has al businessruletypes) and (P8_OPERATOR) that has a select statement based on the businessruletype.
I want to hide the selectlist operator when P8_BUSINESSRULETYPE = 7,8,9 and 10 or P8_OPERATOR = 9
When: change
SelectionType article (s)
Elements P8_BUSINESSRULETYPE
condition: equal to 10
Real actions: hide items p8_operator
False actions: show p8_operator items
ConditionType PL/SQL EXPRESSION
: P8_BUSINESSRULETYPE = 10 OR: P8_BUSINESSRULETYPE = 8 OR: P8_BUSINESSRULETYPE = 7 OR: P8_BUSINESSRULETYPE = 9
What is the problem with my dynamic action? Because he does not hide the operatorfield when businessruletype 10 or 9 are selected in the selectlist. Sessions has also said operator = 9 and Businessruletype = 10
I hope you guys can help out me.
Thank you very much.
2843640 wrote:
Please update your forum profile with a real handle instead of '2843640 '.
I am currently using Apex 4.0 for a schoolproject.
I have two selectlists (P8_BUSINESSRULETYPE - which has al businessruletypes) and (P8_OPERATOR) that has a select statement based on the businessruletype.
I want to hide the selectlist operator when P8_BUSINESSRULETYPE = 7,8,9 and 10 or P8_OPERATOR = 9
When: change
SelectionType article (s)
Elements P8_BUSINESSRULETYPE
condition: equal to 10
Real actions: hide items p8_operator
False actions: show p8_operator items
ConditionType PL/SQL EXPRESSION
: P8_BUSINESSRULETYPE = 10 OR: P8_BUSINESSRULETYPE = 8 OR: P8_BUSINESSRULETYPE = 7 OR: P8_BUSINESSRULETYPE = 9
What is the problem with my dynamic action? Because he does not hide the operatorfield when businessruletype 10 or 9 are selected in the selectlist. Sessions has also said operator = 9 and Businessruletype = 10
The first thing is that a Condition that is applied to a control of dynamic action if the dynamic action is made the see page. She has therefore no impact on the question of whether the actions of true or false are performed. Control conditions which are those defined in the when the properties of the dynamic action. As they are evaluated in the browser, they must be specified as JavaScript.
Secondly, this expression is not valid because it is a space between the colon and the identifiers. Link the names of rating, the colon and the variable element must be contiguous:
:P8_BUSINESSRULETYPE = 10 OR :P8_BUSINESSRULETYPE = 8 OR :P8_BUSINESSRULETYPE = 7 OR :P8_BUSINESSRULETYPE = 9
However the latter is only of academic interest, in this case you need to remove the condition of dynamic action.
In the dynamic of change when action section, P8_BUSINESSRULETYPE, P8_OPERATOR, Condition of JavaScript Expressionand value to the value of the item (s)
($v('P8_BUSINESSRULETYPE') == '7') || ($v('P8_BUSINESSRULETYPE') == '8') || ($v('P8_BUSINESSRULETYPE') == '9') || ($v('P8_BUSINESSRULETYPE') == '10') || ($v('P8_OPERATOR') == '9')
If you are using a browser that supported, this can be simplified to
(['7', '8', '9', '10'].indexOf($v('P8_BUSINESSRULETYPE')) >= 0) || ($v('P8_OPERATOR') == '9')
-
Tuning sql insert that inserts 1 million lines makes a full table scan
Hi Experts,
I'm on Oracle 11.2.0.3 on Linux. I have a sql that inserts data into a table of History/Archives of a table main application based on the date. The application table has 3 million lines. and all the lines that are more then 6 months old must go in a table of History/Archives. This was decided recently, and we have 1 million rows that meet this criterion. This insertion in table archive takes about 3 minutes. Plan of the explain command shows a full table scan on the main Board - which is the right thing, because we are pulling 1 million rows in the main table in the history table.
My question is that, is it possible that I can do this sql go faster?
Here's the query plan (I changed the names of table etc.)
INSERT INTO EMP_ARCH SELECT * FROM EMP M where HIRE_date < (sysdate - :v_num_days); call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 2 0.00 0.00 0 0 0 0 Execute 2 96.22 165.59 92266 147180 8529323 1441230 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 96.22 165.59 92266 147180 8529323 1441230 Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: FIRST_ROWS Parsing user id: 166 Rows Row Source Operation ------- --------------------------------------------------- 1441401 TABLE ACCESS FULL EMP (cr=52900 pr=52885 pw=0 time=21189581 us)
I heard that there is a way to use opt_param tip to increase the multiblock read County but did not work for me... I will be grateful for suggestions on this. can collections and this changing in pl/sql also make it faster?
Thank you
OrauserN
(1) create an index on hire_date
(2) tip 'additional' use in the 'select' query '
(3) run ' alter session parallel DML'; before you run the entire statement
-
Dynamic SQL insert and dbms_sql.last_row_count
I write a procedure which takes a variable number of parameters, and fills a global temporary table with the results if a dynamic query. I want to know how many lines is in the TWG after insertion, made using dbms_sql.execute. With the help of dbms_sql.last_row_count seems to work, but the documentation: said http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_sql.htm#i1026354 'call this function after a FETCH_ROWS or an EXECUTE_AND_FETCH called. If called after a call to EXECUTE, then the returned value is zero.
A much simplified test case is:
I would like to know if it is OK to use last_row_count in this scenario? His behavior would change in the future, leading to misleading results. Because of the doubts I have I might have just to SELECT COUNT (*) from bc_test_gtt; to get my result, but which seems to be an unnecessary use of SQLCREATE GLOBAL temporary TABLE bc_test_gtt (col1 NUMBER(1)) ON COMMIT DELETE ROWS; DECLARE nSqlCursor PLS_INTEGER; nReturn PLS_INTEGER; sSql VARCHAR2(100); BEGIN sSql := 'INSERT INTO bc_test_gtt SELECT 1 FROM dual'; nSqlCursor := dbms_sql.open_cursor; dbms_sql.parse (nSqlCursor ,sSql ,dbms_sql.native ); nReturn := dbms_sql.execute(nSqlCursor); dbms_output.put_line(TO_CHAR(dbms_sql.last_row_count)||' last_row_count rows'); dbms_output.put_line(TO_CHAR(SQL%ROWCOUNT)||' sql%rowcount rows'); dbms_sql.close_cursor(nSqlCursor); END; / 1 last_row_count rows sql%rowcount rows select * from v$version; BANNER ________________________________________________________________________________ Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 ; Production TNS for 64-bit Windows: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production
Background: I store a copy of the contact information in a denormalised, cleaned of structure. When a user enters a new client in the request, my procedure will return duplicates potential, based on the contact information that the user entered.
Thank you
BenCertainly, the documentation last_row_count should not be used after execution. So probably not safe to rely on this behavior.
But the docs for run statement said:
>
This function executes a given cursor. This function accepts the ID number of the cursor and returns the number of rows processed. The return value is only valid for statements INSERT, UPDATE, and DELETE; for other types of statements, including the DDL, the return value is undefined and should be ignored.
...
Returns the number of rows processed
>And it's the package specification:
function execute(c in integer) return integer; -- Execute the given cursor and return the number of rows processed -- (valid and meaningful only for INSERT, DELETE or UPDATE statements; -- for other types of statements, the return value is undefined and -- should be ignored). -- Input parameters: -- c -- Cursor id number of the cursor to execute. -- Return value: -- Number of rows processed if the statement in the cursor is -- either an INSERT, DELETE or UPDATE statement or undefined otherwise. --
So it should be documented that you can simply use the value of nReturn ;-)
-
Need to do some form of SQL INSERTION while RECORDING was done
I'm trying to update a table based on a backup action by the following code in the page that discusses the section. The code is executed 'On submit - after calculations and Validations'. When you click on save, it will not refresh the table.
Thanks in advance for your help.
declare
Start
INSERT INTO ACT_CHANGE_REQUEST
(INVOICE_ID,
DISTRIBUTION_LINE_NUMBER,
LINE_TYPE_LOOKUP_CODE,
AMOUNT,
DESCRIPTION,
ACCOUNTING_DATE,
POSTED_STATUS,
ACCOUNTING_STRING,
NOUVEL_EMPLACEMENT,
NEW_DEPT
NEW_ACCOUNT,
NEW_MOD,
GL_COMMENTS,
INVOICE_DISTRIBUTION_ID,
INVOICE_NUM,
$VENDOR_NAME)
VALUES
(: P4_INVOICE_ID,)
: P4_DISTRIBUTION_LINE_NUMBER,.
: P4_LINE_TYPE_LOOKUP_CODE,.
: P4_AMOUNT,.
: P4_DESCRIPTION,.
: P4_ACCOUNTING_DATE,.
: P4_POSTED_FLAG,.
: P4_ACCOUNTING_STRING,.
: P4_NEW_LOCATION,.
: P4_NEW_DEPT,.
: P4_NEW_ACCOUNT,.
: P4_NEW_MODALITY,.
: P4_GL_COMMENTS,.
: P4_INVOICE_DISTRIBUTION_ID,.
: P4_INVOICE_NUM,.
(: P4_VENDOR_NAME);
COMMIT;
end;If the "Save" button submits the page and your process is set up to take when you press button = RECORD, so there is not much left to guess.
Is the process created in a process of PL/SQL and it is on fire after calculations and Validations? Asuming it is true:
You can cut and paste the section of the newspaper of debugging, where the process is listed and jumped?
Can else you copy your page at apex.oracle.com and indicate the workspace name and identifiers?
Maybe you are looking for
-
Re: Satellite A200 LEFP6 is slow after updating the BIOS
Hello I have a problem with my Toshiba. 2 days ago, I installed a new driver BIOS on the computer. Since then, a laptop computer is running much more slow then normal. I don't know what to do?I want to get the previous Bios driver but I don't know ho
-
Satellite P200 - 1 FT - audio driver for win 7
Hello! First: I know that Toshiba offers only a 'pilot limited' support for Win 7...I'm looking for a driver for my sound devices. That's why I need to know what audio chip is installed in the laptop. I know it's a realtek chip, but not which... Is t
-
Error code 0 x 80070643 when running Windows Update
Problem started with the loss of the Audio a few months ago, that I had fun today to study took the suggestion to update Windows. followed all the instructions, but the installation failed with error Code 0 x 682. Still no sound. Like others I downlo
-
Assistance has begun importing Advanced UI in eclipse
Hey all, just to start making a few apps wondering, I downloaded the UI breakthrough in zip file and must be able to import into eclipse. It is said: the advanced user interface library is a collection of extensions of classes in the BlackBerry Java
-
Hallo, I can buy an app additional cc next to my photographic map with the same account.And whatt it costs (€24,19 additional to the Netherlands)?THX