Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: how to modify query

Re: how to modify query

From: Mark Richard <mrichard_at_transurban.com.au>
Date: Wed, 04 Dec 2002 13:24:09 -0800
Message-ID: <F001.00512863.20021204132409@fatcity.com>


Harvinder,

Let's see what we can come up with:

insert into t_suspended_txn
select 'A', 'B'
from dual
where exists (select col1 from t_suspended_txn where col2 = 'A')

Although I don't honestly know if "dual" exists in SQL Server (in Oracle it's a single row, single column table - you could easily create a "dual" in SQL Server), otherwise:

insert into t_suspended_txn
select distinct 'A', 'B'
from t_suspended_txn where col2 = 'A'

This would work but might do an unnecessarily large sort if t_suspended_txn contains many rows, otherwise:

insert into t_suspended_txn
select 'A', 'B'
from t_suspended_txn where col2 = 'A' and rownum = 1

Although again, I don't know if SQL Server supports "rownum" as a pseudo column.

Hopefully I've given enough ideas to find something that works though.

Cheers,

     Mark.

                                                                                                                          
                    "Harvinder Singh"                                                                                     
                    <Harvinder.Singh_at_Metr       To:     Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>       
                    aTech.com>                  cc:                                                                       
                    Sent by:                    Subject:     how to modify query                                          
                    root_at_fatcity.com                                                                                      
                                                                                                                          
                                                                                                                          
                    05/12/2002 06:04                                                                                      
                    Please respond to                                                                                     
                    ORACLE-L                                                                                              
                                                                                                                          
                                                                                                                          




Hi,

Following code works in sql server but IF NOT EXISTS dosn't work in oracle how can we modify this code so that it should work on both sql server and oracle

 if not exists (
select
col1
from
t_suspended_txn
where
col2 ='A'
begin
insert into t_suspended_txn
select 'A' , 'B'
end

Thanks
--Harvinder

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

   Privileged/Confidential information may be contained in this message.

          If you are not the addressee indicated in this message
       (or responsible for delivery of the message to such person),
            you may not copy or deliver this message to anyone.
In such case, you should destroy this message and kindly notify the sender
           by reply e-mail or by telephone on (61 3) 9612-6999.
   Please advise immediately if you or your employer does not consent to
                Internet e-mail for messages of this kind.
        Opinions, conclusions and other information in this message
              that do not relate to the official business of
                         Transurban City Link Ltd
         shall be understood as neither given nor endorsed by it.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Mark Richard
  INET: mrichard_at_transurban.com.au

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Dec 04 2002 - 15:24:09 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US