drop table conditionally for help where is?
Hi allNot sure if I'm doing this right. My SQL is to identify the files that I want to delete properly, when I do manual QC, but I don't know how to delete records identified off the Table.
The table I want to remove on a lot of columns, but when a condition is fulfilled on the 2 posts I'm looking on, I want to delete the rest of the columns, regardless of what they are.
When the combination of the two columns CUST_ID and MIN (STAMP_DATE) exists, then delete this line, or maybe I'm not quite do this right. Basically, there are 2 lines (duplicate for each cust_id) and I want to delete lines with the oldest Date, that's why I use MIN (DATE) Date_field and keep the Max (Date) for the remaining fields.
Thanks for help in advance.
DELETE FROM Table_A
WHERE EXISTS
(
SELECT CUST_ID, MIN(STAMP_DATE) as MIN_DATE
FROM
(
SELECT CUST_ID, STAMP_DATE
FROM
(
SELECT T1.*, COUNT(*) OVER ( PARTITION BY CUST_ID ) X
FROM Table_A T1
WHERE SALES_PERSON is null
)
WHERE X > 1
ORDER BY CUST_ID)
Group by CUST_ID
);
Hello
Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
If you ask on a DML, such as DELETE statement, CREATE TABLE and INSERT statements need to re - create the tables as they are before the DML, and results will be the content of the or the tables changed when it's all over.
Always tell what version of Oracle you are using.
Kodiak_Seattle wrote:
Hi allNot sure if I'm doing this right. My SQL is to identify the files that I want to delete properly, when I do manual QC, but I don't know how to delete records identified off the Table.
If you have a query that displays correctly the lines you want to REMOVE? The request message. If it is worth mentioning at all, display it.
The table I want to remove on a lot of columns, but when a condition is fulfilled on the 2 posts I'm looking on, I want to delete the rest of the columns, regardless of what they are.
DELETE means delete a row in a table. All rows have the same number of columns. There is no way to delete only some columns in a row. You can delete the entire line. Changing values on an existing line is called update, do not REMOVE, even if you are chaning the columns to NULL.
You can, however, some of the columns set to NULL and leaving the other intact columns. Is that what you want? It would really help if you posted an example.
When the combination of the two columns CUST_ID and MIN (STAMP_DATE) exists, then delete this line, or maybe I'm not quite do this right. Basically, there are 2 lines (duplicate for each cust_id) and I want to delete lines with the oldest Date, that's why I use MIN (DATE) Date_field and keep the Max (Date) for the remaining fields.
When you say 'field', do you mean "column?
What do you mean by "keep the Max (Date) for the rest fields? Are you talking about an UPDATE? All other dates columns, and you want to make all equal to stamp_date? It would really help if you posted an example.
Thanks for help in advance.
DELETE FROM Table_A WHERE EXISTS ( SELECT CUST_ID, MIN(STAMP_DATE) as MIN_DATE FROM ( SELECT CUST_ID, STAMP_DATE FROM ( SELECT T1.*, COUNT(*) OVER ( PARTITION BY CUST_ID ) X FROM Table_A T1 WHERE SALES_PERSON is null ) WHERE X > 1 ORDER BY CUST_ID) Group by CUST_ID );
I think what you want is:
DELETE FROM table_a
WHERE (cust_id, stamp_date) IN ( SELECT cust_id
, MIN (stamp_date)
FROM table_a
)
;
This assumes that the combination (cust_id, stamp_date) is unique. If it is not (for example, if you have 2 or more lines for the same cust_id, and all have the same exact stamp_date), then you need something a little more complicated.
Tags: Database
Similar Questions
-
I have the data into two table with the structure of similar column, I want to loop through the data in these two tables
based on some condition and runtime that I want to put the query in loop for example, the example is given, please help me
create table ab (a number, b varchar2 (20));
Insert into ab
Select rownum, rownum. "" sample "
of the double
connect by level < = 10
create table bc (a number, b varchar2 (20));
Insert into BC.
Select rownum + 1, rownum + 1 | "" sample "
of the double
connect by level < = 10
declare
l_statement varchar2 (2000);
Boolean bool;
Start
bool: = true;
If it is true, then
l_statement: =' select * ab ';
on the other
l_statement: =' select * from bc';
end if
I'm in execute immediate l_statement - something like that, but I don't know
loop
dbms_output.put_line (i.a);
end loop;
end;
Something like that, but this isn't a peace of the code work.
Try this and adapt according to your needs:
declare
l_statement varchar2 (2000);
c SYS_REFCURSOR;
l_a number;
l_b varchar2 (20);
Boolean bool;
Start
bool: = true;
If it is true, then
l_statement: = "select a, b, AB;
on the other
l_statement: = "select a, b from bc;
end if;
--
Open c for l_statement;
--
loop
extract the c in l_a, l_b;
When the output c % notfound;
dbms_output.put_line (l_a |') -' || l_b);
end loop;
close c;
end;
/
-
Drop table for a user, where the table has special characters.
I have to delete tables starting with BIN. How can I do? This is Oracle database 11g.
SQL > select * from tab;
TNOM TABTYPE CLUSTERID
------------------------------ ------- ----------
BIN$ 7J51dMFbQ36/jjLPLdzXeg == $0 TABLE
BIN$ CaCh7QhdRDqlyJo9JETBaA == $0 TABLE
BIN$ J + 4ibk96QZ + PZCDGGNx8Tw == $0 TABLE
BIN$ NvnXFcd4QBW4uYMqOu8H6A == $0 TABLE
BIN$ RaCaPOaTSXyKDlZZG2ua7Q == $0 TABLE
BIN$ aGKXrnwlQRe + e0IH6tEBPQ == $0 TABLE
BIN$ fA5I + 2xsQy66mF7koOoYkA == $0 TABLE
BIN$ lLxLZF3BQ0eum9Ia4rtqYA == $0 TABLE
BIN$ nKZ5hquHRRWHa9daNsa5XQ == $0 TABLE
BONUS BOARD
DEPT TABLE
TNOM TABTYPE CLUSTERID
------------------------------ ------- ----------
EMP TABLE
SALGRADE TABLE
13 selected lines.
I tried to drop one of them and it gave an error saying that table_name is a special character;
SQL > drop table BIN$ nKZ5hquHRRWHa9daNsa5XQ == $0;
drop table BIN$ nKZ5hquHRRWHa9daNsa5XQ == $0
*
ERROR on line 1:
ORA-00933: SQL not correctly completed command.
Please suggest. Thanks in advance.10 g recyclebin default is on, and whenever there is drop table statement it goes to recyclebin. To avoid this fall of the table must be with the keyword to purge as,.
SQL > drop table t is serving;
Otherwise, you can change db setting to turn off recyclebin and the object will not go to recyclebin after that. See http://www.orafaq.com/forum/t/72161/2/Kind regards
Julien -
With the help of case condition for the date of distinct values is does not
Hello PL/SQL gurus and experts.
I use Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64-bit Production version
I followed two tables
TT3-
TT4create table TT3(FeesCntlr,CommCntlr,LatePayCntlr,Name,Age) as select 1,11,21,'Mike',25 from dual union all select 2,12,22,'Clark',26 from dual union all select 4,17,27,'Ussan',28 from dual union all select 5,13,21,'Linda',29 from dual union all select 6,14,24,'Obrek',35 from dual union all select 7,15,25,'Batty',45 from dual union all select 8,16,26,'Nicky',38 from dual;
Now, if I use the following DML for the year 2012, then the result is as follows-drop table TT4; create table TT4(TRNID,BlockID,FeesCntlr,CommCntlr,LatePayCntlr,BookDate) as select 221,625,1,11,21,20121101 from dual union all select 223,625,2,12,22,20121101 from dual union all select 224,625,1,11,21,20121101 from dual union all select 225,627,4,17,27,20111001 from dual union all select 226,628,5,13,21,20120701 from dual union all select 227,628,6,14,24,20120701 from dual union all select 334,628,7,15,25,20120701 from dual union all select 339,629,8,16,26,20120701 from dual union all select 393,629,1,11,21,20120701 from dual union all select 432,629,2,12,22,20120701 from dual union all select 347,629,1,11,21,20120701 from dual union all select 556,629,4,17,27,20120701 from dual union all select 558,629,5,13,21,20120701 from dual union all select 974,629,6,14,24,20120701 from dual union all select 976,629,7,15,25,20120701 from dual union all select 980,629,8,16,26,20120701 from dual union all select 1223,650,2,12,22,20110415 from dual union all select 1224,650,1,11,21,20110415 from dual union all select 1225,650,4,17,27,20110415 from dual union all select 1226,650,5,13,21,20110415 from dual union all select 1227,650,6,14,24,20110415 from dual union all select 1334,650,7,15,25,20110415 from dual union all select 1339,710,8,16,26,20120115 from dual union all select 1393,710,1,11,21,20120115 from dual union all select 1432,710,2,12,22,20120115 from dual union all select 1347,710,1,11,21,20120115 from dual union all select 1556,710,4,17,27,20120115 from dual union all select 1558,711,5,13,21,20111231 from dual union all select 1974,711,6,14,24,20111231 from dual union all select 1976,711,7,15,25,20111231 from dual ;
Now, if I use the following DML for 2011, then the result is as follows-SQL> select t3.Name,t3.age,count(t4.TRNID),count(distinct(BlockID)) from 2 tt3 t3,tt4 t4 3 WHERE t3.feescntlr = t4.feescntlr 4 AND t3.commcntlr = t4.commcntlr 5 AND t3.latepaycntlr = t4.latepaycntlr 6 AND t4.bookdate between 20120101 and 20121120 7 GROUP BY t3.name, t3.age; NAME AGE COUNT(T4.TRNID) COUNT(DISTINCT(BLOCKID)) ----- ---------- --------------- ------------------------ Mike 25 12 3 Mike 27 12 3 Batty 45 4 2 Clark 26 6 3 Linda 29 4 2 Nicky 38 6 2 Obrek 35 4 2 Ussan 28 4 2 8 rows selected.
But by using the condition if I use the following dml and results do not match-SQL> select t3.Name,t3.age,count(t4.TRNID),count(distinct(BlockID)) from 2 tt3 t3,tt4 t4 3 WHERE t3.feescntlr = t4.feescntlr 4 AND t3.commcntlr = t4.commcntlr 5 AND t3.latepaycntlr = t4.latepaycntlr 6 AND t4.bookdate between 20110101 and 20111120 7 GROUP BY t3.name, t3.age; NAME AGE COUNT(T4.TRNID) COUNT(DISTINCT(BLOCKID)) ----- ---------- --------------- ------------------------ Mike 25 2 1 Mike 27 2 1 Batty 45 2 1 Clark 26 2 1 Linda 29 2 1 Obrek 35 2 1 Ussan 28 4 2 7 rows selected.
As the expected output, that I expect - isSQL> select Name,Age,sum(Trn),sum(CurYrOrdr) "2011 Order", sum(LastYrOrdr) "2012 Order" 2 from 3 ( 4 select t3.Name,t3.age,count(t4.TRNID) Trn,(case when t4.bookdate between 20110101 and 20111231 then count (distinct(BlockID)) else 0 end) CurYrOrdr, 5 (case when t4.bookdate between 20120101 and 20121120 then count (distinct(BlockID)) else 0 end) LastYrOrdr 6 from 7 tt3 t3,tt4 t4 8 WHERE t3.feescntlr = t4.feescntlr 9 AND t3.commcntlr = t4.commcntlr 10 AND t3.latepaycntlr = t4.latepaycntlr 11 AND t4.bookdate between 20110101 and 20121120 12 GROUP BY t3.name, t3.age,t4.bookdate 13 ) 14 group by Name,Age order by Name,Age; NAME AGE SUM(TRN) 2011 Order 2012 Order ----- ---------- ---------- ---------- ---------- Batty 45 8 2 2 Clark 26 8 1 3 Linda 29 8 2 2 Mike 25 14 1 3 Mike 27 14 1 3 Nicky 38 6 0 2 Obrek 35 8 2 2 Ussan 28 8 2 2 8 rows selected.
I sincerely thank each of you in advance for the input/comments that I fight with it for some time now.---------------------------------- Expected Output - NAME AGE "2012 TRNID" "2011 TRNID" "2012 ORDERID" "2011 ORDERID" ----- ---------- --------------- ----------------------------- ---------- ------------ Mike 25 12 2 3 1 Mike 27 12 2 3 1 Batty 45 4 2 2 1 Clark 26 6 2 3 1 Linda 29 4 2 2 1 Nicky 38 6 2 2 1 Obrek 35 4 2 2 1 Ussan 28 4 4 2 2
Kindly help.user555994 wrote:
Hi JAC
Thanks for the comments and certainly once I comment out the following line.
- AND t4.bookdate between 20110101 and 20111120then the values are adapting, but at the same time why do we need to comment the date range condition as case is just a filter and not the condition.
filter should be-
AND t4.bookdate between 20110101 and 20121120 --"made it 12"
-
several conditions for dhtml menu drop-down
RH11 Webhelp
Chrome browser
First of all, thank you to Peter Grange for his column on conditional text in tables. This problem doesn't seem to be there, so thank you for help.
- The terms in my table (for example ' Print button') are dhtml drop-down lists that I want to assign several conditions.
- Assign a condition and generating the poster State correctly the term in the webhelp generated.
- Assign several conditions and generate the conditions causing the term to not be displayed at all.
What is a dhtml limitation?
DHTML should not be the problem. It is more likely to be linked to your tags and expression.
See www.grainge.org for creating tips and RoboHelp
-
WHERE condition for a column of MDB
Hi gurus,
I have a requirement where, in MDB (The LTS for this logical table is say 'Fact'), I need a logical column with the following definition.
Count (Dim.Status) where Dim.status = 'Accepted' (I adds the array Dim LTS again, should I?)
I know we can do a count (Dim.status) in the source column. but for the where Dim.status = 'Accepted' part im not sure what to do.
Should I put the Sun as a LTS table and set the condition "where" in the content tab? which will work?
But what happens if I have another logical column where I need Sun. State = 'Denied' (we have much higher status)
Help, pleaseJust in case that also works
FILTER ("metrics with ROW_WID" USING (status = "accepted"))
You can take any measure that is equivalent to count (fact.row_wid) in SPR
-
Hello
Need help on SQL to remove all tables and their respective forced & triggers where the table name starts with Ex: Tab_
Thank you
It kind of depends on why you have these FK constraints. If the constraints are only between tables named tab_ *, then the drop statement should be:
stmt: = 'drop table' | r.table_name: ' cascade forced purge';
If the constraints point to or from tables that you do not drop, then you can rethink your criteria to choose the tables to drop.
John
-
I think it would be helpful if when you open the drop-down list for a 3D object keyframe controls have the same color as the 3D arrows in the project window.
You can suggest that here:
-
I'm so frustrated! I have CS5 Master Collection. I want to UPGRADE to CS6 Master Collection. I want to be on the cloud! I can't find where to put up-to-date or any CONTACT to ask for help. It shouldn't be this hard. HELP Please!
See the link below:
-
Y at - it an email address to contact for help me to cancel my subscription? I tried to use the option chat 4 times and my internet keeps dropping out and canceling the cat until I can get the cancelled subscription
You may please check out the link below for instructions on cancellation.
Cancel your membership creative cloud
For more information you can contact the Support from Adobe by clicking on the link below.
Please make sure that you are connected to the right Adobe ID.
Hope this will help you.
Kind regards
Hervé Khare
-
I just bought Adobe Photoshop elements 13 for a Mac and try to install. I'm about to enter the serial number, but it will not letters. What I do and where do I go for help?
Nitan15479421 serial number cannot contain letters. It is likely that you have received a redemption code. Please see Rédemption Code help for more information on how to use your redemption code.
-
Help, where should I choose ' help >; updates "for ID CS5 7.04?
Help, where should I choose ' help > updates "for ID CS5 7.04?
Yes I see. This means that the application using and not using the Web site.
-
Does anyone else have this problem? I use webhelp with contextual sensitivity, and I appeal to the table of contents, Index, search, and glossary to display. If I go to the welcome home page, they are exposed. But when we ask for help on a particular page, these areas are not shown, but they can be opened using the view link. I much prefer to see the exposed left pane, rather that ask the user to click on this link. How can I do this?
Robin ValkHi Robin.
See this link using the appeal of the CSH Webhelp output. -
Execution of statement of UPDATE for the whole table even when the WHERE Clause is presentation
Hi friends,
I have a problem in a stored procedure where I wrote an update with a where clause clause statement. At some point only one line should be updated according to the unique identifier in where clause.
But what is happening is that the Update statement is getting executed for all rows in the table to neglect the WHERE clause. I don't get any idea of why this is happening. Here is the stored procedure and the update statement is BOLD:-
CREATE OR REPLACE PROCEDURE MDMADM.proc_MDM_InsertCntryDetails
(
CntryMasterCode IN VARCHAR2,
CntryName IN VARCHAR2,
MDMUser IN VARCHAR2,
Exists IN ITS ENTIRETY,
status in VARCHAR2,
Inserted_By IN VARCHAR2 default NULL,
Modified_By IN VARCHAR2 default NULL,
Mdm_Code IN the DEFAULT NUMBER 0.
Action in VARCHAR2 DEFAULT 'Add ',.
XGenAttNames IN VARCHAR2 default NULL,
XGenAttValues IN VARCHAR2 default NULL,
MirusAttNames IN VARCHAR2 default NULL,
MirusAttValues IN VARCHAR2 default NULL,
GenisysAttNames IN VARCHAR2 default NULL,
GenisysAttValues IN VARCHAR2 default NULL,
XGenModify IN VARCHAR2 default NULL,
MirusModify IN VARCHAR2 default NULL,
GenisysModify IN VARCHAR2 default NULL
)
IS
strSQLXGen VARCHAR (1000);
strSQLMirus VARCHAR (1000);
strSQLGenisys VARCHAR (1000);
nMaxMDMCode INTEGER.
ifExist INTEGER;
/******************************************************************************
NAME: proc_MDM_InsertCntryDetails
PURPOSE:
REVISIONS:
Worm Date Description of the author
--------- ---------- --------------- ------------------------------------
1.0 03/07/2009 1. Created this procedure.
NOTES:
Keywords to replace automatically available Auto:
Object name: proc_MDM_InsertCntryDetails
SYSDATE: 03/07/2009
Date and time: 03/07/2009, 19:11:20 and 03/07/2009-19:11:20
User name: (put in TOAD Options, editor of the procedure)
Name of the table: (defined in the dialog box "New PL/SQL object")
******************************************************************************/
BEGIN
COUNT (*) of SELECT INTO ifExist OF MDM_COUNTRY_MASTER;
IfExist IF = 0 THEN
SELECT 1 INTO nMaxMDMCode FROM DUAL;
ON THE OTHER
SELECT MAX (MDM_CODE) + 1 IN MDM_COUNTRY_MASTER nMaxMDMCode;
END IF;
IF Action = "add" THEN
INSERT INTO MDM_COUNTRY_MASTER(MDM_CODE,MDM_MASTER_CODE,MDM_DESCRIPTION,MDM_USER,MDM_EXIST,MDM_STATUS,MDM_ACTION,DAT_INSERT_DATE,DAT_INSERTED_BY)
VALUES(nMaxMDMCode,CntryMasterCode,CntryName,MDMUser,exist,Status,action,sysdate,Inserted_By);
strSQLXGen: = ' INSERT IN MDM_COUNTRY_MAPPING (MDM_CODE, SYSTEM_NAME, SYSTEM_CODE,' |) XGenAttNames | DAT_INSERTED_BY, DAT_INSERT_DATE) ' |
"VALUES (' |)" nMaxMDMCode | ',' || '''' || "XGen | '''' || ',1,' || XGenAttValues | ',' || '''' || Inserted_By | '''' || SYSDATE)';
EXECUTE IMMEDIATE strSQLXGen;
strSQLMirus: = ' INSERT IN MDM_COUNTRY_MAPPING (MDM_CODE, SYSTEM_NAME, SYSTEM_CODE,' |) MirusAttNames | DAT_INSERTED_BY, DAT_INSERT_DATE) ' |
"VALUES (' |)" nMaxMDMCode | ',' || '''' || "Mirus | '''' || ',2,' || MirusAttValues | ',' || '''' || Inserted_By | '''' || SYSDATE)';
EXECUTE IMMEDIATE strSQLMirus;
strSQLGenisys: = ' INSERT IN MDM_COUNTRY_MAPPING (MDM_CODE, SYSTEM_NAME, SYSTEM_CODE,' |) GenisysAttNames | DAT_INSERTED_BY, DAT_INSERT_DATE) ' |
"VALUES (' |)" nMaxMDMCode | ',' || '''' || "Genisys | '''' || ',3,' || GenisysAttValues | ',' || '''' || Inserted_By | '''' || SYSDATE)';
EXECUTE IMMEDIATE strSQLGenisys;
ON THE OTHER
UPDATE MDM_COUNTRY_MASTER
SET MDM_DESCRIPTION = CntryName, DAT_MODIFIED_BY = Modified_By, DAT_MODIFY_DATE = SYSDATE.
MDM_USER = MDMUser, MDM_ACTION = Action, MDM_STATUS = status MDM_EXIST = exist WHERE MDM_CODE = Mdm_Code;
COUNT (*) of SELECT INTO ifExist FROM MDM_COUNTRY_MAPPING WHERE SYSTEM_CODE = 1 AND MDM_CODE = Mdm_Code;
IfExist IF = 0 THEN
strSQLXGen: = ' INSERT IN MDM_COUNTRY_MAPPING (MDM_CODE, SYSTEM_NAME, SYSTEM_CODE,' |) XGenAttNames | DAT_INSERTED_BY, DAT_INSERT_DATE) ' |
' VALUES(' ||) Mdm_Code | ',' || '''' || "XGen | '''' || ',1,' || XGenAttValues | ',' || '''' || Modified_By | '''' || SYSDATE)';
EXECUTE IMMEDIATE strSQLXGen;
ON THE OTHER
strSQLXGen: = "UPDATE MDM_COUNTRY_MAPPING SET | XGenModify | ', DAT_MODIFY_DATE = SYSDATE, DAT_MODIFIED_BY =' | '''' || Modified_By | '''' || "WHERE MDM_CODE =' | ' Mdm_Code | "and SYSTEM_CODE = 1';
EXECUTE IMMEDIATE strSQLXGen;
END IF;
COUNT (*) of SELECT INTO ifExist FROM MDM_COUNTRY_MAPPING WHERE SYSTEM_CODE = 2 AND MDM_CODE = Mdm_Code;
IfExist IF = 0 THEN
strSQLMirus: = ' INSERT IN MDM_COUNTRY_MAPPING (MDM_CODE, SYSTEM_NAME, SYSTEM_CODE,' |) MirusAttNames | DAT_INSERTED_BY, DAT_INSERT_DATE) ' |
' VALUES(' ||) Mdm_Code | ',' || '''' || "Mirus | '''' || ',2,' || MirusAttValues | ',' || '''' || Modified_By | '''' || SYSDATE)';
EXECUTE IMMEDIATE strSQLMirus;
ON THE OTHER
strSQLMirus: = "UPDATE MDM_COUNTRY_MAPPING SET | MirusModify | ', DAT_MODIFY_DATE = SYSDATE, DAT_MODIFIED_BY =' | '''' || Modified_By | '''' || "WHERE MDM_CODE =' | ' Mdm_Code | "and SYSTEM_CODE = 2';
EXECUTE IMMEDIATE strSQLMirus;
END IF;
COUNT (*) of SELECT INTO ifExist FROM MDM_COUNTRY_MAPPING WHERE SYSTEM_CODE = 3 AND MDM_CODE = Mdm_Code;
IfExist IF = 0 THEN
strSQLGenisys: = ' INSERT IN MDM_COUNTRY_MAPPING (MDM_CODE, SYSTEM_NAME, SYSTEM_CODE,' |) GenisysAttNames | DAT_INSERTED_BY, DAT_INSERT_DATE) ' |
' VALUES(' ||) Mdm_Code | ',' || '''' || "Genisys | '''' || ',3,' || GenisysAttValues | ',' || '''' || Modified_By | '''' || SYSDATE)';
EXECUTE IMMEDIATE strSQLGenisys;
ON THE OTHER
strSQLGenisys: = "UPDATE MDM_COUNTRY_MAPPING SET | GenisysModify | ', DAT_MODIFY_DATE = SYSDATE, DAT_MODIFIED_BY =' | '''' || Modified_By | '''' || "WHERE MDM_CODE =' | ' Mdm_Code | "and SYSTEM_CODE = 3';
EXECUTE IMMEDIATE strSQLGenisys;
END IF;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHILE OTHERS THEN
-Consider recording the error and then re-raise
LIFT;
END proc_MDM_InsertCntryDetails;
/
Thank you>
WHERE mdm_code = mdm_code
>This will always be value true - similar to WHERE 1 = 1.
You typed it wrong or is the same as the variable column name? If they are the same test rename one of them.
-
Hello
How does this work?
Session 1: Session 2:
SQL > create table t (x number);
Table created.
SQL > insert into t values (1);
1 line of creation.
SQL > insert into t values (2);
1 line of creation.
SQL > commit;
Validation complete.
SQL > start
2 for f in (select * from t) loop
3 dbms_output.put_line(sysdate||) e '|| f.x);
4 dbms_lock.sleep (60);
5 end of loop;
6 end;
7.
SQL > drop table t;
Deleted table.
SQL > select sysdate to double;
13:58:45
13:58:34 1
13:59:34 2
The table has been deleted, but the line is always returned once the table is deleted. With the help of OPEN and FETCH has the same
declare
cursor c is select * from t;
r t % rowtype;
Start
Open c;
extract the c in r;
dbms_output.put_line(sysdate||) e '|| r.x);
DBMS_LOCK. Sleep (60);
extract the c in r;
dbms_output.put_line(sysdate||) e '|| r.x);
end;
/Is this a bug? I could even reproduce it with 1 million rows. Shouldn't this ORA-01001 invalid cursor return?
Start
for f in (select * from t) loop
If f.x in (1,10,100,1000,10000,100000,1000000) thendbms_output.put_line(sysdate||) e '|| f.x);
DBMS_LOCK. Sleep (5);
end if;
end loop;
end;
/Thank you
Laurent
PS: It boils down to having no consistency to the DICTIONARY level... which is ugly
Huh? The dictionary makes perfect sense.
Any query cursor / who uses the data dictionary will get the correct results.
If the cursor that you use should the data dictionary, it will get the correct results - he'll notice the table disappeared and will throw an exception.
Your 'problem' manifests only for a SELECT query. Change the cursor in UPDATES and you can't delete the table.
SQL > drop table t;
drop table t
*
ERROR on line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
Even if you remove a line in this loop.
https://docs.Oracle.com/CD/B28359_01/server.111/b28318/consist.htm#i8841
As a request enters the implementation phase, change current system (SNA) number is determined. Figure 13-1, this system change number is 10023. As data blocks are read in the name of the query, only the blocks that are written with the observed SNA are used.
When the cursor is opened that the SNA is determined, the data file header is read and Oracle knows where the first measure.
The cursor can read this measure without the need of the data dictionary. So if you drop the table in another session your cursor can continue to read this measure.
It is ONLY when the next measurement is necessary that Oracle uses the dictionary of data and notice that the table has been deleted.
https://docs.Oracle.com/CD/B28359_01/server.111/b28318/logical.htm
A scope is a number of blocks of contiguous data allocated for storing a specific type of information.
The cursor can keep accessing the measure, and all these "contiguous data blocks" because he knows where the measurement begins and how many blocks there.
So if 'million' lines fits into this extent (s) the query will keep trucking.
It may take even more to see the missing table if a path to the index is used as the index blocks are pointers to the previous index block. These pointers can span extensions - you can read an entire table once it has been abandoned if the cursor is using the index to find all data or all the blocks table as long as the extensions/blocks being read have not been replaced or reallocated.
It is therefore a problem for SOME ONLY.
Maybe you are looking for
-
Honda, Bluetooth and iPhone
Honda CRV that remains is no longer connected to the iPhone via Bluetooth? < published by host >
-
In the last few days, I noticed a change in behavior of my browser. I don't mind not that he remembers where I've been since the history feature is useful when you are looking for past articles. However, what is happening now is that when I start Fir
-
Context menus for both the left mouse and right-click
I have a desktop HP Pavilion 500 with Windows 8. Installed in the first week of April 2014. I have a mouse wired HP supplied with my desktop computer. Last week, the two mouse clicks left & right to display the context menu. I did not any changes to
-
Windows Installer during the boot
Whenever I start my laptop, I get a message saying "Windows Installer - preparing to install. He then proceeds to install the so-called TrayApp because the next message I get will say "Please wait while Windows configures TrayApp". If I do nothing,
-
When you click on a buttonfield shows the menu options
When I click in a ButtonField, options menu (see the keybord, application Switch, Close) shows where I clicked. How can I stop it?