SQL & PL/SQL :: Merge Vs Cursor Processing
Apr 2, 2010
My requirement is ..
SQL> CREATE TABLE EMP (EMPID VARCHAR2(100), U_EMPID VARCHAR2(100));
Table created.
SQL> INSERT INTO EMP VALUES ('DUMMY1','J0001');
1 row created.
SQL> INSERT INTO EMP VALUES ('DUMMY2','J1002');
1 row created.
SQL> INSERT INTO EMP VALUES ('DUMMY3','J1003');
1 row created.
SQL> SELECT * FROM EMP;
EMPID U_EMPID
------------------
DUMMY1 J0001
DUMMY2 J1002
DUMMY3 J1003
in this example empid is dummy empid (which will be issued for contractors), once the contractors are considered to be taken into payroll that u_empid will be updated by HR manually, we need to replace empid with u_empid. then data will become like this.
SQL> SELECT * FROM EMP;
EMPID U_EMPID
---------------------------
DUMMY1 J0001
DUMMY2 J1002
DUMMY3 J1003
J1001 NULL
J1002 NULL
J1003 NULL
now my requirement is there are approximately 60 child tables are there for EMP table, and EMPID is the foreign key for all of them with "on delete cascade" defined on those. Now first i need to create records in all the child tables with actual employee id's (which is u_empid). if the actual id is already exists then just need to update rest of the columns in that table except the EMPID.
Once the records are created with actual empid, then i will issue a delete command to remove dummy employee id's in emp table which will take care of deletion in child tables as well.
I was thinking of two options, one is go with Merge other is write a cursor and handle the update in exception block using when duplicate value on index feature.
View 2 Replies
ADVERTISEMENT
Jun 28, 2010
I am trying to merge into test table using a cursor. If the contract number in the test table matches with the contract number from the cursor then i need to update the creation_date else i need to insert values from the cursor into the test table.
MERGE INTO test
USING cursortest
ON (i.contract_number = test.contract_number)
WHEN MATCHED THEN
[code]......
View 9 Replies
View Related
Apr 18, 2013
SQL Statement Processing Steps:
1. Create a cursor.
2. Parse the statement.
parsing (syntax check, semantic check, privilege check, allocate private sql area, shared pool check (library cache check shared sql area. Here is hard or soft parse)SQL queries submitted to the system first run through the parser, which checks syntax and analyzes semantics. The result of this phase is called a parsed representation of the statement.
This parsed representation is then sent to the optimizer, which handles three main functionality:Transformation, estimation, and execution plan generation.
3. Describe query results.
4. Define query output.
5. Bind variables.
6. Parallelize the statement.
7. Execute the statement.
8. Fetch rows of a query.
9. Close the cursor.
- What stages from the above are included in the 'Query Optimizer Stage'
- Is the parse tree created after doing both syntax check and systematic check as I found notes where they mention it was done before symantic check
- What stages are skipped when doing soft parse vs hard parse
-when mentioned parsed representation, is that the same as parse tree.
I am just trying to understand more the flow of the query processing.
View 1 Replies
View Related
Mar 3, 2003
Outside of convoluted loop using the SUBSTR() function, is there an easy way to extract each element from a comma-sepearted list that's passed in to a stored proc?
View 4 Replies
View Related
Oct 6, 2010
I am running one update statement which is running almost one hour still no response.
I would like to know either query is processing or hanging(suppose to finish the update within few minutes).
Is there any way or sql to find either the statement(my update query) is running or hanging.
View 4 Replies
View Related
Nov 26, 2011
I want to make report of processing time for tasks. Every task has several stages and connected with them modification dates. I need calculate total processing time for every task.
In my calculations i have to consider only "working" hours. There is time window table (For example working hours: from 8 a.m to 4 p.m, but can be different thats why i use table with id - different id = different time window). Scripts i used to simulate problem:
create table t (
id number,
s_date date,
e_date date
);
declare
[code]........
table t constrains "working" hours:
12011-04-10 08:00:002011-04-10 16:00:00
12011-04-11 08:00:002011-04-11 16:00:00
...
but could be also
22011-04-10 09:00:002011-04-10 17:00:00
22011-04-11 09:00:002011-04-11 17:00:00
...
table w contains tasks history processing by team (8 hours for tenet, rest time (out of hours defined in table t) of working trough incident should be ignored/omitted in calculations):
12011-04-10 10:00:00
12011-04-11 02:08:16
12011-04-11 16:23:10
22011-04-12 08:12:30
22011-04-13 00:40:15
32011-04-14 09:37:54
32011-04-14 15:54:36
32011-04-15 06:40:44
32011-04-16 09:48:06
32011-04-16 20:06:01
32011-04-18 14:11:29
At the beginning I tried this query, but I don't know how consider/dose time window from table t
select id, change_date,
round( to_number(change_date-lag(change_date) over (partition by id order by change_date))*24*60*60) sec
from w;
12011-04-10 10:00:00
12011-04-11 02:08:1658096 - sholud be 21600 (sum time only for 2011-04-10 16:00:00)
12011-04-11 16:23:1051294 - should be 28800 (sum time only from 2011-04-11 08:00:00 to 2011-04-11 16:00:00)
22011-04-12 08:12:30
22011-04-13 00:40:1559265 - should be 28050 (sum time only from 2011-04-12 08:12:30 to 2011-04-12 16:00:00)
32011-04-14 09:37:54
View 5 Replies
View Related
Oct 16, 2012
I have created a form based on a table and I want to override the processing which inserts/updates the data in the database. I have figured out how to create a new process but I am having trouble referencing the form field data.
If I have a filed call P40_USERNAME how do I reference this in the insert/update statement in the custom process.
View 1 Replies
View Related
Jul 16, 2011
if there is any package provided with DB that would allow me to import XML file and then use XPath to read the data? I need to insert it in proper tables then. I could see packages to create XML files, but I could not see any one to load it from the file. I could see it could be done in Java using XMLDOM, but is there any way of doing this using pure PL/SQL?
View 4 Replies
View Related
Nov 16, 2010
Today, I've got an error:
$ sqlplus / as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Wed Nov 17 09:45:50 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
idle> startup
ORA-01078: failure in processing system parameters
ORA-01565: error in identifying file '+DATA/DOISOAT/spfileDOISOAT.ora'
ORA-17503: ksfdopn:2 Failed to open file +DATA/DOISOAT/spfileDOISOAT.ora
ORA-15077: could not locate ASM instance serving a required diskgroup
idle> exit
SP2-0042: unknown command "exit" - rest of line ignored.
idle> exit
Disconnected
First time, I tried to recreate spfile from pfile, however, it - the errors continued to occur. And I searched in metalink, so, I've got ID 387217.1. I've been beging followed:
1- Check the REQUIRED_RESOURCES was listed by crs_stat -p command, wasn't it? Then, the REQUIRED_RESOURCES did not contain anything
2- Modify by Metalink comment solution:
srvctl modify instance -d <database name> -i <instance name> -s <ASM instance name>
Everything is done, however, I still did not startup database instance. The above error continued, and I force to stop all by crs_stop -all.
View 1 Replies
View Related
Apr 15, 2013
While configuring Data Guard as I have inserted following parameters in SPFILEPRMDB.ora (PRMDB is Primary DB).
*.db_unique_name='PRMDB'
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(PRMDB,STLDB)'
*.LOG_ARCHIVE_DEST_1='LOCATION=C:oracleproduct10.2.0flash_recovery_areaPRMDBARCHIVELOG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PRMDB'
*.LOG_ARCHIVE_DEST_2='SERVICE=STLDB LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STLDB'
[code]....
when I SQL> shutdown immediate; and SQL> Startup;
Oracle gives me following Error
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file 'C:ORACLEPRODUCT10.2.0DB_1DATABASE
INITPRMDB.ORA'
When I Restored old spfileprmdb.ora without these parameters then it Starts Up Normally.
View 1 Replies
View Related
Jul 22, 2013
Insert statements from Java are processing very slow i.e 1L records taking 15Mins on every row commit ( Batch insert is not applicable that's why they are committing on every row). - Only 1 index
View 21 Replies
View Related
Aug 2, 2011
I've created a form that is working on the basis of Invoice Processing. There I want to get the sum of all the total of the products * quantity..I'm getting this error
FRM-30425: Summarized database item must reside in a block with Query All Records or Precompute Summaries set to Yes.
Item: TOTAL
Block: SBM_SALES_PRODUCTS
FRM-30085: Unable to adjust form for output.
View 4 Replies
View Related
Feb 25, 2010
I had newly installed oracle 11g database, for testing & learning purpose.
Don't know wht happen to it after successfull installation , I am not able to start database.
Following error is appearing, how to resolve this.
Ora-01078:failure in processing system parameters
I can do only login to idle instance.
View 9 Replies
View Related
Feb 19, 2012
I am learning how to clone database using cold backup.
I have copied all datafile ,redofile and also created control file but I am getting error while inititialisation of my clone(CVM) instance.
SQL> startup nomount pfile=C:ORACLEPRODUCT10.1.0DB_1DATABASEINITCVM.ORA;
LRM-00109: could not open parameter file 'C:ORACLEPRODUCT10.1.0DB_1DATABASE
INITCVM.ORA'
ORA-01078: failure in processing system parameters
but I have copied this file to C:ORACLEPRODUCT10.1.0DB_1DATABASE location but still giving me error.
View 9 Replies
View Related
Oct 4, 2013
db11gxe and apex 4.0 , difference of the processes in these two columns , what is the diff ? the same "Select the category of the process you wish to create:"? there is no difference i can see ?so what is the diff again ?
View 7 Replies
View Related
Apr 28, 2011
I am importing the dump.All the tables are getting imported but when it comes to the part as shown in the error it gets struck there and nothing is showed after.
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
The dumps for which I am doing the import is huge. Its around 46 GB.
select
sl.sid,
sl.serial#,
sl.sofar,
sl.totalwork
from
v$session_longops sl,
v$session s,
dba_datapump_sessions d
where
s.saddr = d.saddr
and s.sid = sl.sid
and s.serial# = sl.serial#
order by start_time;
It showing the lock for two sid's. Should I kill the process and import the dump again? I used below command to import dums
impdp sys/*****@dbname directory=dump_dir dumpfile=prod_dump_%U_200311 SCHEMAS=int_aaa int_bbb int_ccc int_ddd int_eee int_fff
int_ggg int_hhh int_iii int_jjj int_kkk int_lll
View 10 Replies
View Related
Oct 11, 2004
I have a small problem with creating the SPFILE,
These are the commands i had issued :-
1. startup nomount
2. create SPFILE from PFILE ;
Then i got an error :-
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file 'C:ORACLEORA92DATABASEINITORCL.ORA'
Ever since this happened i am unable to connect to ORACLE under any schema !
I get the following error : -
SQL> conn scott/tiger
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Warning: You are no longer connected to ORACLE.
WHY DOES THIS HAPPEN AND HOW CAN I OVERCOME IT ?
View 8 Replies
View Related
Dec 6, 2010
I am trying to create standby database on second machine ie. not on my machine. For this i have made added the required parameters in the pfile of the primary database but when I am trying to startup the database using the new pfile I am receiving some errors.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount pfile='E:oracleproduct10.2.0db_1databaseinitden1.ora'
LRM-00101: unknown parameter name 'L0G_ARCHIVE_DEST_2'
ORA-01078: failure in processing system parameters
SQL>
Below are the parameters of my pfile:
*.core_dump_dest='E:oracleproduct10.2.0/admin/den/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='den'
*.db_recovery_file_dest='E:oracleproduct10.2.0/flash_recovery_area'
[code]....
View 10 Replies
View Related
Oct 1, 2013
If I use the conventional path will SQL*Loader process a data file sequentially from top to bottom? I have a file comprised of header and detail records with no value found in the detail records that can be used to relate to the header records. The only option is to derive a header value via a sequence (nextval) and then populate the detail records with the same value pulled from the same sequence (currval). But for this to work SQL*Loader must process the file in the exact same sequence that the data has been written to the data file. I've read through the 11g Oracle® Database Utilities SQL*Loader sections looking for proof that this is what will happen but haven't found this information and I don't want to assume that SQL*Loader will always process the data file records sequentially.
View 9 Replies
View Related
Sep 21, 2012
I have the following code which allows me to disable the "f04" field if pThis is set to 'N'
<script type="text/javascript">
function hide_show_comments(pThis){
//get the curren row index on change
[Code].....
View 9 Replies
View Related
Sep 7, 2007
I'm dealing with an ORA-1000 error in a Pro*C application where all the cursors are correctly closed (or so it seems to me).
Here is the code for a simple program which reproduces the problem:
Each cursor is opened in a PL/SQL package:
CREATE OR REPLACE PACKAGE emp_demo_pkg AS
TYPE emp_cur_type IS REF CURSOR;
PROCEDURE open_cur(curs IN OUT emp_cur_type, dept_num IN NUMBER);
END emp_demo_pkg;
[Code]....
While testing the initialization parameter open_cursors is set to 50.
It's my understanding that Oracle doesn't close the cursors until it needs the space for another cursor, which in my test case seems to happen when I enter a value of 50 or bigger for "number of loops". To see how oracle is reusing the cursors, while the test program is running I run SQL*Plus and query v$sesstat for the session that's running the test with the following sentence:
select name, value
from v$sesstat s, v$statname n
where s.statistic# = n.statistic#
and sid = 7
and name like '%cursor%';
Even before I enter a value for number of loops I can see that the session opened 4 cursors and closed 2 of them:
NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 4
opened cursors current 2
Entering a value of 5 for number of loops yields
NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 11 <----- 7+
opened cursors current 8 <----- 6+
With a value of 30
NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 36 <----- 25+ (apparently, Oracle reused at least 5 cursors)
opened cursors current 33 <----- 25+
With a value of 47
NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 53 <----- 17+
opened cursors current 50 <----- 17+
Now I reached the upper limit set by the initialization parameter open_cursors.
Entering a value of 48, I get the ORA-1000 error.
ORA-01000: maximum open cursors exceeded
ORA-06512: at "SCOTT.EMP_DEMO
Since I open and close the cursor in the same loop iteration, I expect to find in every iterarion 1 explicit cursor and a number of implicit cursors (the PL/SQL call along with the so-called recursive cursors), but I don't expect the sum of all of them to be greater than 50. If my understanding is correct Oracle should be reusing the 50 cursors previously marked as "closeable", not raising the ORA-1000 error.
View 1 Replies
View Related
Feb 8, 2011
I successfully created a DB manually with PFILE.
I want the DB to startup with SPFILE at next login.So i fired the below command.
CREATE SPFILE='path/SPFILEPRAGAT.ORA' FROM PFILE='path/file.ora'.
But it shows the error as below:
ORA-01078: failure in processing system parameters
ORA-27040: file create error, unable to create file
OSD-04002: unable to open file
O/S-Error: (os 123) The filename, directory name,or volume label syntax is incorrect.
View 20 Replies
View Related
Mar 8, 2007
I'm using an 'On-Update trigger' to replace the default Form Builder processing for updated records. When I try to change a column in the form I get: ORA- 01446: cannot select ROWID from, or sample, a view with DISTINCT, GROUP BY, etc.
The on-update doesn't fire. How do I get around this. The block is based on a view.
View 9 Replies
View Related
Feb 25, 2011
Is it possible to:
-define a cursor with bind variables
-get a cursor record from these cursor
-and pass the bind variable in the OPEN clause
Did'nt succeed as shown in the example.
SET SERVEROUTPUT ON SIZE 900000;
DECLARE
--works fine
CURSOR c1 IS SELECT * FROM USER_TABLES WHERE rownum<3;
--doesn't work
--CURSOR c1 IS SELECT * FROM USER_TABLES WHERE rownum<:1;
crec c1%rowtype;
BEGIN
--works fine
OPEN c1;
--isn't possible ?
--OPEN c1 USING 3;
[Code]....
View 3 Replies
View Related
Sep 11, 2011
just looking around to use the new feature available in oracle 11g to convert the dbms_sql numeric cursor to reference cursor, how to do it?
parse and execute the sql string first with dbms_sql and then convert it to ref cursor?
View 1 Replies
View Related
Nov 23, 2011
I want to return ref cursor based on explicit cursors
create table jumbo(id number, name varchar2(20));
insert into jumbo values(1,'jumbo');
create table mumbo(id number, name varchar2(20));
insert into mumbo values(1,'mumbo');
commit;
[Code].....
The above procedure has compilation errors when I am trying to open ref cursor
LINE/COL ERROR
-------- --------------------------------------------------------
20/24 PL/SQL: SQL Statement ignored
20/38 PL/SQL: ORA-00942: table or view does not exist
32/24 PL/SQL: SQL Statement ignored
32/38 PL/SQL: ORA-00942: table or view does not exist
SQL>
View 5 Replies
View Related
Aug 7, 2013
Can i user exist when cursor will using For Cursor .
View 15 Replies
View Related
Sep 8, 2011
run down of the implications of MERGE by ROWID in such a fashion:
CODE MERGE
INTO XXWT_AP_ACCRUALS_RECEIPT_F EXT
USING (
SELECT PO_DISTRIBUTION_ID,
[code]...
Can this lead to an "Unstable Set of Rows?". Is it possible for the ROWID's to change during the execution of this statement - meaning certain ROWIDs identified in the SELECT will not actually be updated when it comes to the MERGE operation?
Basically, is it sound practice to use ROWID to merge on - in cases where you dont have a WHEN NOT MATCHED condition?
View 8 Replies
View Related
Sep 17, 2011
i HAVE TWO TABLES
EMP_NAME_DETAILS
EMP_ID EMPNAME
EMP_ADD_DETAILS
EMP_ID EMPCITY
NOW I WANT TO MERGE/COMBINE THIS TWO TABLES INTO ONE FLAT TABLE SO MY REPORTS WILL RUN ONLY FROM ONE TABLE INSTEAD OF TWO.
MY DESIRED OUTPUT TABLE WOULD BE
EMP_ID EMPNAME EMPCITY
View 2 Replies
View Related
Nov 23, 2012
the query ..
Below are the codes
create table testing1
(
id number,
data varchar2(20)
)
insert all into testing1 values (1,'100')
into testing1 values (2,'Ram')
[Code]....
I want the output as
100 Ram Pune
200 Shyam Mumbai
300 Kamal bangalore
View 8 Replies
View Related