Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Mailing Lists -> Oracle-L -> RE: better sql code

RE: better sql code

From: Mark W. Farnham <>
Date: Wed, 26 Oct 2005 00:53:48 -0500 (EST)
Message-ID: <>

Er, how about using a comma list so you're only running a single subquery?

               Oracle Technology and Business
                        Mark W. Farnham
                        President  Rightsizing, Inc.
                        36 West Street
                        Lebanon, NH 03766-1239
                tel:  (603) 448-1803

            Want a signature like this?

  -----Original Message-----
[]On Behalf Of Freeman, Donald
  Sent: Tuesday, October 25, 2005 1:21 PM   To:; oracle list
  Subject: RE: better sql code

  What version of Oracle is this? Perhaps you can declare the file as an external table then just do a select/ insert from there without previously loading it.

  Don Freeman
  Database Administrator 1
  Bureau of Information Technology
  Pennsylvania Department of Health
  717-783-8095 Ext 337

    -----Original Message-----
[]On Behalf Of raja rao

    Sent: Tuesday, October 25, 2005 1:16 PM     To: oracle list
    Subject: better sql code

    Hi All,

    can someone give me a better code for the below:

    We use the sqlloder to load somedata into oracle.     that will be loaded into a stage table called adtstage.     Later this should be updated into the main table HSP.

    For this purpose, we have develped the code like this.     we will collect the acct# numbers into a flat file (filename is list) and

    for each line will fire theupdate statement like below.

    cat list|while read line
    sqlplus -s <<EOF
    @update.sql ${line}
    # list is a file which contains the acct# to be updated into main table.     update.sql contains teh below code:

    define hsval=&1
    update HSP set
    mr#= ( select mr# from adtstage where acct#= &hsval ),

    facility_code=( select facility_code from adtstage where acct#= &hsval ),

    Patient_LName= ( select Patient_LName from adtstage where acct#= &hsval ),

    where acct#= '&hsval' and hsp_id='XXX'     ;

    In teh abvoe both tables, acct#, mr# columns are primary key.     There are around 100 cols to be updated from stage to main tables. If there are a 1000 records it is taking

    long time to update the main table. Becoz, it should run thru the whole 1000 recods and run the above update

    which is taking lot of time.
    can someone help me in tuning this.


    NOTE: Both the tables HSP and ADTSTAGE are same structures and they have

    acct#, mr# as the primary key.

    Yahoo! FareChase - Search multiple travel sites in one click.

Received on Wed Oct 26 2005 - 01:07:44 CDT

Original text of this message