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

Home -> Community -> Mailing Lists -> Oracle-L -> Where is the problem in this INSERT statement?

Where is the problem in this INSERT statement?

From: Bala Muru <muru321_at_yahoo.com>
Date: Sun, 3 Dec 2000 18:28:09 -0800 (PST)
Message-Id: <10699.123497@fatcity.com>


Hello Lists,

Should there a difference between the following two INSERT statements?
1)INSERT INTO <table1>
SELECT DISTINCT * FROM <table2>
2)INSERT INTO <table1>
SELECT DISTINCT * FROM
(SELECT DISTINCT * FROM <table2>)

The first one inserts more records than the second. The second one seems to be correct. To me both should return same number of records, am I wrong somewhere?

Any help would be highly appreciated.

Thanks in advance.
Muru

A realtime example is given below:

INSERT INTO resale_psrc
{In the second query add SELECT DISTINCT * FROM here) SELECT DISTINCT

      b.market_area_id market_area_id,
      b.package_id ci_code,
      b.package_type_code ci_type,
      c.charge_code rate_code, 

'W' charge_unit_type,
'Resale Generic' ps_name,
'$' increment_type,
'Resale Generic' rate_name,
c.amount amount, TO_DATE('01/01/1996','MM/DD/YYYY') date1 TO_DATE('01/01/2099','MM/DD/YYYY') date2
'L' ps_local_non_local,
'$' ps_applicator_type,
d.charge_type_code

FROM
    package_info@"lrds.world" b,
    package_charge_info@"lrds.world" c,
    cis_charge_code_ref_t@"lrds.world" d WHERE
      b.market_area_id=c.market_area_id AND
      b.package_id=c.package_id AND
     c.charge_code = d.charge_code

/

Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products. Received on Sun Dec 03 2000 - 20:28:09 CST

Original text of this message

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