Re: Problem with simple SQL query!

From: John Durst <jdurst_at_sky.net>
Date: 1998/09/30
Message-ID: <3612390D.A086514F_at_sky.net>#1/1


If order is truly important you would have to load the data into a CLUSTER and not a normal table. That aside, if you want to load the data in order into a table you would have to use PL/SQL and not a simple SQL statement. I'm writing this off the top of my head so I won't guarantee 100% accurracy, but the code should like something like this:

declare
  cursor ordered_csr is
  select sedol from t_master_download
  where country='United Kingdom'
  and downloaddate='01-DEC-92'
  order by market_cap desc;
  v_sedol t_sedol.sedol%type;
begin
  open orderded_csr;
  fetch orderded_csr into v_sedol;
  while (ordered_csr%found and orderded_csr%rowcount <=246) loop     insert into t_sedol (sedol) values (v_sedol);     fetch orderded_csr into v_sedol;
  end loop;
  close ordered_csr;
end;
/

Terry Maguire wrote:

> Hi
>
> Sorry there were mistakes in the previous message
>
> Could any please help me with this SQL statement. It seems OK but it returns
> the following error:
>
> order by market_cap desc
> *
> ORA-00933: SQL command not properly ended
>
> Here is the statement:
>
> insert into t_sedol (sedol)
> select sedol from t_master_download
> where rownum<=246
> and country='United Kingdom'
> and downloaddate='01-DEC-92'
> order by market_cap desc;
>
> So basically I want to insert the 'sedol' value(s) into the table 't_sedol'.
> The 'sedol' value(s) is a SELECT query that chooses its data from the table
> 't_master_download'. When I remove the ORDER part of the statement it runs
> fine but the ORDER is essential. Can anyone help on this one?
>
> Regards
>
> Terry Maguire
> IIU
> IFSC House
> Custom House Quay
> Dublin 1
> Ireland
> e:Mail - tmaguire_at_nospam.tinet.ie
> ---Remove the nospam to e:Mail
Received on Wed Sep 30 1998 - 00:00:00 CEST

Original text of this message