Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Table Has C1 And C2 Column If Exits any record in c1 then
Update c2 record Otherwise insert new record in the C1 And
C2 (Using Procedure)

Answer Posted / dinesh a.

select * from x;

C1 C2
----- ----------
1
2
3
4
5
6
7
8
9
10


1 create or replace procedure updt_x is
2 cnt number(4);
3 begin
4 select count(1) into cnt from x where c1 is not null;
5 if cnt > 0 then
6 update x
7 set c2=10;
8 else
9 insert into x
10 values(1,2);
11 end if;
12 commit;
13* end;

SQL> execute updt_x;

PL/SQL procedure successfully completed.

SQL> select * from x;

C1 C2
---------- ----------
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
9 10
10 10

10 rows selected.


SQL> delete from x;

10 rows deleted.

SQL> commit;

PL/SQL procedure successfully completed.

SQL> select * from x;

C1 C2
---------- ----------
1 2

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is literal?

953


Can any one explain me when i execute below query.. select months_between('07-JUL-12','10-FEB-12') from dual; Out put:- 4.90322581 How oracle calculate?

1321


Explain how you would restore a database using RMAN to Point in Time?

2093


How to upsert (update or insert into a table)?

950


Name the various constraints used in oracle?

968


What is integrity and what is constraint??Explain with example

2213


How to run the anonymous block again?

1065


How do we represent comments in oracle?

999


What are advantages of dateset in datastage?

2197


What are the varoius components of physical database structure of oracle database?

942


What are the limitations of check constraint?

960


How to create additional tablespaces for an new database?

968


What are the differences between lov and list item?

989


How to end the current transaction in oracle?

961


How to load a large xml file?

1001