Jerald Nicholas
Jerald Nicholas

Reputation: 7

WHERE Clause in ORACLE

How to use WHERE clause while inserting values into the table?

I tried the below query to insert values into the column, whichever set address='COB'

insert into table empt (loc,country,mob)
values ('&loc','&country',&mob)
where address='COB';

Upvotes: 0

Views: 85

Answers (3)

gopalakrishna
gopalakrishna

Reputation: 16

insert into table empt (loc,country,mob)
select loc,country,&mob
where address='COB';

Upvotes: 0

vipin
vipin

Reputation: 367

I don't know, why you are using "Table" in insert statement.

INSERT

insert into empt (loc,country,mob)
values ('&loc','&country',&mob)

Hope you need Update.

UPDATE

Update empt
Set loc = '&loc',
country = '&country',
mob = &mob
where address='COB';

Please refer SQL Statements used in oracle

https://docs.oracle.com/database/121/TDDDG/tdddg_dml.htm#TDDDG23100

Upvotes: 0

Ltaylor
Ltaylor

Reputation: 85

This looks like you may need to use update if the field already exists in your table -

i.e.

update empt 
   set loc =?, country = ?, mob=? 
where address ='COB';

Upvotes: 1

Related Questions