Update With Case Clause Auto Commits

Nov 26, 2012

i tried the following update on one table:

update siebel.s_contact
set marital_stat_cd =
case
when (marital_stat_cd = 'Casado') then 'Married'
when (marital_stat_cd = 'Solteiro') then 'Single'
when (marital_stat_cd = 'Divorciado') then 'Divorced'
end

As you can see i forgot the else, so my update is wrong.

I thought i could rollback the update issuing the rollback statement, but when i have issue the rollback, the i query the table to confirm that the update was rollbacked and for my suprise the update is commited.

I didn�t issue the commit statement after the update and i confirmed that the auto-commit feature to worksheets is disabled, so i don�t understand whit the update was commited.

View 5 Replies


ADVERTISEMENT

Case Statement In Where Clause

Feb 1, 2012

Depending on which month the user is running this select the TAG_YEAR needs to be calculated differently. I have a feeling that I'm over thinking it.

SELECT DOG_MASTER.DOG_MASTER_ID,
DOG_NAME,
TAG_YEAR,
TAG_NUMBER AS PREVIOUSTAGNUMBER,
ISSUE_DATE
FROM DOG_OWNER
[code].......

View 1 Replies View Related

SQL & PL/SQL :: Case Statement In Where Clause

Aug 10, 2011

select empno,ename,deptno,employee_status from emp,dept where emp.deptno=dept.deptno and
( employee_status in(Case employee_status when {?Status}=1 then 'A'
when {?Status}= 2 then 'T'
When {?Status}= 3 then 'A'||','||'T'))
OR ( end_date >= {?START_DATE}
AND end_date <= {?END_DATE}
)
)

Since when i pass employee_status as input 1 it have given me 4 records. When I pass employee_status as input 2 it have given me 3 records. When I pass employee_status as input 3 it should give me 4 records + 3 records=7 records.

4 records for employee_status 'A'
3 RECORDS for employee_status 'T'
7 records for employee_status 'A' AND 'T'

How I should write a query to get 7 records.

View 2 Replies View Related

SQL & PL/SQL :: DECODE And CASE In WHERE Clause

May 7, 2010

I am facing a problem while retrieving data from table using DECODE/CASE.

Table: PARAM_MSTR

MIN_VALMAX_VALPARAM_CODE DESCRIPTION DATATYPE
AB1000 HARD PARAMETERTEXT
CN1000 SOFT PARAMETERTEXT
0501001 CRYSTAL PARAMETERNUMBER
512001001 STONE PARAMETERNUMBER

Now I want to get the parameter description based upon the PARAM_CODE and a value passed which should be in range of MIN_VAL and MAX_VAL. Means when I pass PARAM_CODE=1000 and :parameter=A, then it should check the DATATYPE of the PARAM_CODE, in our case it is 'TEXT' so it should check the passed value between MIN_VAL and MAX_VAL like

:parameter BETWEEN MIN_VAL AND MAX_VAL and should return 'HARD PARAMETER'.
If I pass PARAM_CODE=1001, then the DATA_TYPE is 'NUMBER', so it will check the :parameter value as Number.
Like :parameter BETWEEN to_number(MIN_VAL) AND to_number(MAX_VAL)

For example:
PARAM_CODE :parametr Result
1000 A HARD PARAMETER
1000 C SOFT PARAMETER
1000 P NULL
1001 25 CRYSTAL PARAMETER
1001 99 STONE PARAMETER
1001 201 NULL

I have written a query using DECODE and CASE statement but it is not working properly.

SELECT * FROM param_mstr WHERE PARAM_CODE=1000 AND :parameter BETWEEN DECODE(DATATYPE,'NUMBER',CAST(MIN_VAL as NUMBER),MIN_VAL)AND DECODE(DATATYPE,'NUMBER',CAST(MAX_VAL as NUMBER),MAX_VAL)

View 3 Replies View Related

SQL & PL/SQL :: Case In Insert Clause?

Aug 30, 2011

is there a possible to use a case statement in insert clause?

View 5 Replies View Related

PL/SQL :: How To Use CASE Statement In Where Clause

May 16, 2013

How to use CASE stmt in WHERE clause?

View 3 Replies View Related

SQL & PL/SQL :: Query With CASE Where Clause?

May 14, 2012

The query has a case statement in the where clause so that results can be filtered. If I pass "ut" for sso_id then the query returns 21 rows. If I remove the case statement and hard code "a.sso_id like lower('ut'||'%')" then the query returns 41 rows. The query should be returning 41 rows all the time.

Problem:

When passing "ut" as an SSOID parameter to the Procedure the query returns 21 rows.Taking the query and hard coding "a.sso_id like lower('ut'||'%')" the query returns 41 rows.

Result:
query should be returning 41 rows when "ut" is passed an an SSOID parameter.

Returns 21 rows

procedure SSO (SSOID in varchar2 default null,
Name in varchar2 default null,
Campus in varchar2 default null,
Department in varchar2 default null,

[code]...

Returns 41 rows

open Results for
select a.sso_id,
(a.name_last||', '||a.name_first) as name,
b.site,

[code]...

Test Data
CREATE TABLE ID
(
SSO_ID VARCHAR2(60 BYTE),
NAME_FIRST VARCHAR2(100 BYTE),
NAME_LAST VARCHAR2(100 BYTE),

[code]...

Test Data
CREATE TABLE NT
(
LOWER_NT_ID VARCHAR2(60 BYTE),
DEPARTMENT VARCHAR2(100 BYTE),

[code]....

View 3 Replies View Related

Ignore Case In SQL Select With Where Clause

Oct 11, 2010

We have and Upper and a Lower function.Is there any function or way in which I can issue a select while ignoring the case(like IgNoReCaSe) in a where clause? I don't want to use like

select * from emp where upper(job)= upper('dba');
or
select * from emp where lower(job)= lower('dba');

I just want to know if there is any way in which I could do it without using upper and lower.

View 2 Replies View Related

SQL & PL/SQL :: Syntax - Case Statement In Where Clause?

Mar 12, 2013

I am trying to use the following case statement in my where clause. My problem here is, I get no rows.

tab1.col1 =
case
when (tab1.col1 = 'VAR') and (tab1.col2 is null or tab1.col2 >= tab2.datecol) then
tab1.col1
else
null
end

View 13 Replies View Related

SQL & PL/SQL :: Filter Data Using CASE Statement In WHERE Clause?

May 29, 2013

Want to filter a data using CASE statement in WHERE clause for the following scenario.

Need to Filter tb1.fallback_keyword if the fallback_flag is "Y' or 'N' and pg_number is null.Else no partial search of keyword.

where CASE WHEN (fallback_flg = 'Y' OR fallback_flg = 'N') and (pg_number is NULL )
THEN tb1.fallback_keyword = SUBSTR(key_word,1, INSTR(key_word,'#',-2))
ELSE (tb1.keyword = key_word ) AND (tb1.keyword like regexp_replace(key_word, '[*]+', '%'))
END

View 3 Replies View Related

SQL & PL/SQL :: Conditional Date Range Using CASE Statement In WHERE Clause

Mar 28, 2011

Is it possible within a CASE statement to put conditions on the date range that I want to pull? IE: am versus pm. The query has to pull specific time ranges for an AM run versus a PM run.
.....
FROM
table
WHERE
CASE
WHEN TO_CHAR(SYSDATE,'AM') = 'AM'
THEN table.date BETWEEN TRUNC(SYSDATE) AND SYSDATE
ELSE table.date BETWEEN TRUNC(SYSDATE+12/24) AND SYSDATE

View 6 Replies View Related

SQL & PL/SQL :: Auto Update Trigger

Apr 2, 2012

I have 2 tables where the data is related.table ot_pack_list,ot_delv .ot_pack_list contains details of items information that are packed to be delivered sometimes what happens user may remove some items from this, and the summary column of dl_wt and dl_qty in ot_delv must get automatically changed whenever there is addition in ot_pack.

create table ot_pack_list (item varchar2(12),pack_qty number,pack_wt number,pack_no number)
insert into ot_pack_list values ('a',2,10,1);
insert into ot_pack_list values ('b',3,55,1);
create table ot_delv (d_no varchar2(12),d_qty number,d_Wt number,d_pack_no number)

[Code]...

--after updating the data in ot_delv should be like..

select * from ot_delv;

d_no d_qty d_wt d_pack_no
----- ----- ---- -------
1 5 75 1

View 15 Replies View Related

SQL & PL/SQL :: Update With Case Using Select

Oct 30, 2013

Can we use select statement in case statment for an update?

Example

UPDATE x SET field = CASE WHEN
(SELECT field1
FROM Y
WHERE field3 = x.field3
IS NOT NULL
THEN 'B'
ELSE 'C'
where cny# = 112160

View 3 Replies View Related

SQL & PL/SQL :: Update Query Using Case When Exists?

Jan 4, 2013

I am trying to use the below query

update t_emp set TTL_FLG =
CASE
WHEN EXISTS
(SELECT 1 from Schema1.T_STG_LW_EMP E
WHERE E.Employee = Schema2.T_emp.EMPLOYEE_NUMBER
AND E.JB_CODE like '%TP%' or E.JB_CODE like '%DGD%' or E.JB_CODE like '%PDD%'
or E.JB_CODE like '%YND%'
)
THEN 'Y'
ELSE 'N'
END;

View 1 Replies View Related

SQL & PL/SQL :: Use FROM Clause In Update Command?

Jul 13, 2011

Can we use FROM clause in update command?

View 2 Replies View Related

SQL & PL/SQL :: Join Update Clause

Jun 9, 2010

I want to use join condition in update syntax.Like the following way but it doesnot work.how to fix it.

update tab_1 a
set a.qty = b.sell_qty
from tab_2 b
where a.nbr=b.nbr

View 3 Replies View Related

With Clause - Use Values Of Cteas In Update?

May 2, 2013

with cteas
as
(
select hit from radial,gib
where no=id
)
select hit from cteas

[code]...

for the above query can i use the values of cteas in update .because it throws error cteas as table/view not found

if i use like this am getting error in update (missing select key word)

with cteas
as
(
select hit from radial,gib
where no=id
)
update xenon
set nub=(select hit
from cteas
where ren=hit)

View 3 Replies View Related

SQL & PL/SQL :: Update Table With Primary Key In Where Clause

Dec 11, 2012

Is is required to check the number of rows updated in a table when the primary key of the table is used in the filter criteria of the update statement? As I know,by default it will update only one record. But if it happens to be an important transaction table and only one record is required to be updated, then is it the best practice to use the 'SQL%ROWCOUNT' check in the query, even if the update query is using primary key in filter clause.

Example:Consider Trans table with trans_id as primary key. Then:
Update Trans
set trans_status='pass'
where trans_id=123;

I know this will update only one record. But what is the best practice? Shall I use 'SQL%ROWCOUNT' after this update to double check whether the record is updated or not?

View 7 Replies View Related

WHERE Clause Of Some Update Statements Not Using Primary Keys

Feb 3, 2009

Inside procedure,I need to validate all the columns (Ex:col1 should not accept more than 40 chars) and update status(containing error or not) of these columns into another column in the same table.For this,I mentioned only 'UPDATE' statements.So 'WHERE' clause of some update statements not using Primary keys.

In that table composite primary key was created.This procedure is successfully complied & executed now.But this procedure took more than 10 mins to execute.I need to reduce the time to less than a min.

View 8 Replies View Related

Lock Child Table By FOR Update Clause?

May 7, 2013

I am using the Oracle 10g and I have question related to "for Update" clause.We have the data warehouse db, so no foreign key constraint between parent and child.We process the data files every hour, the condition is If we find the row in parent table then we go and look into child tables and perform insertion (if no corresponding record is present) or updation (if one corresponding record is present) in the child table.

The problem is If I run the two process simultaneously for the same kind of data, and if no record is present in the child table then it create the duplicate in child table.My question is if I use FOR Update clause while selecting the data in parent table will it lock the child table for any insertion or updation?

Ex- We have employee table for employee 1

In my data files I have the row for employee 1, so when I run the select query on employee table I found 1 row.The I look the child table "Salary" as there is no record for emp_id =1 in this table I insert the record for this

Emp_id Salary
1 500

The problem is if both the process run at same time then I get duplicate rows in child table

Emp_id Salary
1 500
1 500

we do not want the duplicate row insertion. Can I lock the child table during first process run

View 4 Replies View Related

PL/SQL :: ORA-06592 / CASE Not Found While Executing CASE Statement

Oct 16, 2013

My DB version is

BANNER                                                       
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production                         
CORE 10.2.0.1.0 Production                                       
TNS for Linux: Version 10.2.0.1.0 - Production                 
NLSRTL Version 10.2.0.1.0 - Production      

I'm getting this error while executing a package.But this is unpredictable because sometimes it's coming and sometimes it's not. Everytime I'm passing the value as 'ALERT' for the transaction name. Sometimes it's successful and sometimes it's throwing ORA-06592 

CASE UPPER(IC_TRANSACTION_NAME)
WHEN 'ALERT' THEN
SELECT A.FACILITY_ID INTO VN_FACILITY_ID FROM ALERT A
WHERE A.ALERT_ID = IN_PARENT_NODE_ID;
INSERT INTO TRANSACTION_HISTORY (TXN_HISTORY_ID,

[code]....

View 23 Replies View Related

Auditing And Implicit Commits

May 11, 2009

I'm working on a Java-based web application and we have unit tests that we use to test all our all code that interacts with the database or code that interacts with our DB code. The Spring framework allows us to perform some DML within a transaction before each test and then rollback the changes. For the most part, this works, however when I run the full suite of unit tests, it will randomly commit data to the database causing the rest of the tests to fail.

will Oracle's auditing let me see where this odd-ball commit is occurring? Is there another way for me to see when data is being committed?

This does not appear to be happening on any of the systems we've deployed, however this is a bit unsettling and would like to know why this is occurring so that we can prevent it from happening in production.

View 1 Replies View Related

(log File Sync) And Commits?

Jan 23, 2013

When a user session commit he is waiting on 'log file sync' untill LGWR sends the message back to user session after writing log buffer content into redo log file.As far as i understand this is serialize operation(one at a time).

So how come i have 7 ms average 'log file sync' wait time and i can still perform 200 commits per sec ?

7 ms * 200 waits = 1400ms = 1.4 sec

View 2 Replies View Related

PL/SQL :: Finding Commits In Plsql During Runtime?

Jul 19, 2012

In any application, we will have many commit statements issued in many places. How can we find out as to where all commits have happened during runtime.

Basically in our application, when am trying an operation, am getting the error ORA-01086: savepoint <save point name> never established.

My guess is that there is a commit somewhere because of which system is not able to rollback to that save point.

View 1 Replies View Related

Forms :: Post Built-in Commits Changes In The Database?

May 7, 2010

I have been testing out a form using 10.1.2.0.2 on a v10.2.0.1 db and in my local env. the form works correctly i.e. if I make a change and 'post' it and then exit and press NO (when asked to save changes) then it correctly leaves the value in the database as it originally was.

The process works by the user pressing a button in form A (read only form) and this opens form B (using open_mode,session,activate) and the user makes their change(s) in form B (a 'post' command is issued in a When New Rec Inst trigger on a db block when the user navigates to a new record within the same block if it is determined that the block status <> 'QUERY') before returning to form A and pressing 'NO' when prompted to save changes.

However, if I run the same process in the TEST env. using the same executable against the same database then it actually updates the database value.

I have tested this by adding a debug message at the end of form B to retrieve the db value back AFTER having issued a clear_form(no_commit) just for the sake of the test and it still returns me the 'new' i.e. amended value - which is obviously incorrect. From what I can see it would appear that the commit occurs straight after the 'post' has been issued and well before the user even exits the form.

Is this a known bug with the 'post' built-in or could it be that a parameter is set to act in this way (i.e. is there an 'autocommit' setting that is 'ON') within the application server?

View 8 Replies View Related

SQL & PL/SQL :: Cursor Loop With 3 Commits In Middle Based

Feb 19, 2010

We have a fact table t1 in the warehouse which has above 6 million records.There is to be an update like this where t2 has aid+bid as composite primary key. column aid repeats in t1.There's performance problem and we'v been told to break this huge update into pieces with few commits in the middle.

update t1
set t1.aid =
(select t2.aid from t2
where t1.bid = t2.bid
)

I've tried cursor loop with 3 commits in the middle based on if condition that evaluates on every iteration.

View 8 Replies View Related

SQL & PL/SQL :: Regular Expression To Find Commits In All Oracle Source?

Oct 14, 2013

I would like to write a select that would return all places in DB that are commiting transaction.

E.g. package for testing:

CREATE OR REPLACE PACKAGE test.TEST_COMMIT AS
PROCEDURE THE_ONLY_COMMIT_IN_DB ;
END TEST_COMMIT;--not a match
CREATE OR REPLACE PACKAGE BODY test.TEST_COMMIT AS

[code]....

The select should return 4 rows with --ok.

SELECT *
FROM ALL_SOURCE ASO
WHERE
REGEXP_LIKE(ASO.TEXT,'commit(s*);','i' )
AND name = 'TEST_COMMIT'

View 18 Replies View Related

Server Utilities :: Intermediate COMMITS When Using Sqlldr Or Imp Utilities

Oct 29, 2013

I want to load lakhs of records into a table. My problem is when after loading the ¼ of records my process is abend due to the size of my rollback segment area. I don't have an option to increase it. So, Is there any way to go for intermediate commits when I am using the imp or sqlldr utilities to load the entire data without abend?

View 2 Replies View Related

SQL & PL/SQL :: OrderBy Clause Before From Clause?

Apr 23, 2010

can we use something like this

"select ... order by emp from emp"

what is to be done? so that this qurey runs. no co-related subquery to be used.

View 6 Replies View Related

Auto Rotation Table

Nov 18, 2010

Is there any strcuture or fucntion that can make the table have something like rotation.

I mean the record can be first in first delete.

So,for example , even the table have limit row for example , 100 row .

so, the new data can be replace the oldest row in the table auto and insert into the table .

so the new row will replace the oldest 99 th row auto .the table still keep 100 row but the data can be update .

Is it "partition" or other ??

how can I create it .

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved