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

Home -> Community -> Usenet -> c.d.o.misc -> Re: LOOPING SQL

Re: LOOPING SQL

From: Ron <support_at_dbainfopower.com>
Date: Thu, 12 Feb 2004 00:12:44 -0800
Message-ID: <MbGdnbDJK5afqbbdRVn-sA@comcast.com>


Hello Dang,

  If I understand issue correctly:

    You can use calling program to generate SQL statement first (shell, perl, pl/sql etc) and then run result statement.

Regards,

  Ron
  DBA Infopower
  http://www.dbainfopower.com
  Standard disclaimer:
http://www.dbainfopower.com/dbaip_advice_disclaimer.html

"Dang" <mdang_at_bigpond.com.au> wrote in message news:c0el3f$9n6$1_at_mws-stat-syd.cdn.telstra.com.au...
> I am running Oracle 8i and trying to run a Loop of SQL based on one
number.
> Problem is this number can vary.
>
> Example:
> How to convert this SQL into one Statement SQL based on LOOP
>
> SELECT SYSDATE, LOOP FROM
> (SELECT SYSDATE, '1' AS LOOP FROM dual
> UNION
> SELECT SYSDATE, '2' AS LOOP FROM dual
> UNION
> SELECT SYSDATE, '3' AS LOOP FROM dual
> UNION
> SELECT SYSDATE, '4' AS LOOP FROM dual
> UNION
> SELECT SYSDATE, '5' AS LOOP FROM dual
> )
>
> Result
>
> SYSDATE LOOP
> 12/02/2004 12:28:32 pm 1
> 12/02/2004 12:28:32 pm 2
> 12/02/2004 12:28:32 pm 3
> 12/02/2004 12:28:32 pm 4
> 12/02/2004 12:28:32 pm 5
>
>
Received on Thu Feb 12 2004 - 02:12:44 CST

Original text of this message

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