<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: What are the different ways to generate rows?</title>
	<atom:link href="http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/</link>
	<description>Oracle Question and Answer</description>
	<lastBuildDate>Mon, 19 Dec 2011 14:21:07 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Karl Reitschuster</title>
		<link>http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/comment-page-1/#comment-145</link>
		<dc:creator>Karl Reitschuster</dc:creator>
		<pubDate>Thu, 23 Feb 2006 21:37:01 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/#comment-145</guid>
		<description>Hi,
The Date variant of igors model example :

&lt;pre&gt;

SQL&gt; 
SQL&gt; SELECT add_months(trunc(sysdate), - (x-1)) AS date_gen from dual
  2  MODEL DIMENSION BY (1 AS z) MEASURES (1 x)
  3  RULES ITERATE (10) (x[ITERATION_NUMBER]=ITERATION_NUMBER+1);

DATE_GEN
-----------
23.01.2006
23.02.2006
23.12.2005
23.11.2005
23.10.2005
23.09.2005
23.08.2005
23.07.2005
23.06.2005
23.05.2005

10 rows selected

SQL&gt; 

&lt;/pre&gt;

Greetings
Karl</description>
		<content:encoded><![CDATA[<p>Hi,<br />
The Date variant of igors model example :</p>
<pre>

SQL&gt;
SQL&gt; SELECT add_months(trunc(sysdate), - (x-1)) AS date_gen from dual
  2  MODEL DIMENSION BY (1 AS z) MEASURES (1 x)
  3  RULES ITERATE (10) (x[ITERATION_NUMBER]=ITERATION_NUMBER+1);

DATE_GEN
-----------
23.01.2006
23.02.2006
23.12.2005
23.11.2005
23.10.2005
23.09.2005
23.08.2005
23.07.2005
23.06.2005
23.05.2005

10 rows selected

SQL&gt; 
</pre>
<p>Greetings<br />
Karl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Reitschuster</title>
		<link>http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/comment-page-1/#comment-122</link>
		<dc:creator>Karl Reitschuster</dc:creator>
		<pubDate>Sat, 11 Feb 2006 19:00:18 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/#comment-122</guid>
		<description>Igor,
your example with model clause ist very impressing for me! Did not worke with 10G model clause yet
karl</description>
		<content:encoded><![CDATA[<p>Igor,<br />
your example with model clause ist very impressing for me! Did not worke with 10G model clause yet<br />
karl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gamyers</title>
		<link>http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/comment-page-1/#comment-116</link>
		<dc:creator>gamyers</dc:creator>
		<pubDate>Fri, 10 Feb 2006 04:41:23 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/#comment-116</guid>
		<description>10G, MODEL clause, just plug in the ITERATE :

SELECT x from dual
MODEL DIMENSION BY (1 AS z) MEASURES (1 x)
    RULES ITERATE (7) (x[ITERATION_NUMBER]=ITERATION_NUMBER+1);</description>
		<content:encoded><![CDATA[<p>10G, MODEL clause, just plug in the ITERATE :</p>
<p>SELECT x from dual<br />
MODEL DIMENSION BY (1 AS z) MEASURES (1 x)<br />
    RULES ITERATE (7) (x[ITERATION_NUMBER]=ITERATION_NUMBER+1);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stbu</title>
		<link>http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/comment-page-1/#comment-112</link>
		<dc:creator>stbu</dc:creator>
		<pubDate>Wed, 08 Feb 2006 19:56:46 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/#comment-112</guid>
		<description>Seen on asktom website, you may use this:

&lt;pre&gt;
create or replace type array
as table of number;
&lt;/pre&gt;
&lt;pre&gt;
create or replace function
vtable( n in number default null )
return array
PIPELINED
as
begin
   for i in 1 .. nvl(n,999999999)
   loop
       pipe row(i);
   end loop;
   return;
end;
/
&lt;/pre&gt;


Sample usage:

&lt;pre&gt;
select add_months ( to_date( &#039;01.01.2006&#039;, &#039;DD.MM.YYYY&#039; ), column_value-1) dt
  from table( vtable(12) );

DT
----------
01.01.2006
01.02.2006
01.03.2006
01.04.2006
01.05.2006
01.06.2006
01.07.2006
01.08.2006
01.09.2006
01.10.2006
01.11.2006
01.12.2006
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Seen on asktom website, you may use this:</p>
<pre>
create or replace type array
as table of number;
</pre>
<pre>
create or replace function
vtable( n in number default null )
return array
PIPELINED
as
begin
   for i in 1 .. nvl(n,999999999)
   loop
       pipe row(i);
   end loop;
   return;
end;
/
</pre>
<p>Sample usage:</p>
<pre>
select add_months ( to_date( '01.01.2006', 'DD.MM.YYYY' ), column_value-1) dt
  from table( vtable(12) );

DT
----------
01.01.2006
01.02.2006
01.03.2006
01.04.2006
01.05.2006
01.06.2006
01.07.2006
01.08.2006
01.09.2006
01.10.2006
01.11.2006
01.12.2006
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Claudiu Ariton</title>
		<link>http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/comment-page-1/#comment-95</link>
		<dc:creator>Claudiu Ariton</dc:creator>
		<pubDate>Mon, 30 Jan 2006 16:00:02 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2006/01/26/what-are-the-different-ways-to-generate-rows/#comment-95</guid>
		<description>Another way to generate rows is to use pipelined function

create or replace type t_number as table of number
/

create or replace function generate(v_inf number, v_sup number) return t_number
  pipelined
as
 
begin

  for i in v_inf..v_sup loop
    
   pipe row (i);
    
  end loop;
  
  return;
 
end;
/

select * from table(cast(generate(1,11) as t_number))
/

Best regards,
Claudiu Ariton</description>
		<content:encoded><![CDATA[<p>Another way to generate rows is to use pipelined function</p>
<p>create or replace type t_number as table of number<br />
/</p>
<p>create or replace function generate(v_inf number, v_sup number) return t_number<br />
  pipelined<br />
as</p>
<p>begin</p>
<p>  for i in v_inf..v_sup loop</p>
<p>   pipe row (i);</p>
<p>  end loop;</p>
<p>  return;</p>
<p>end;<br />
/</p>
<p>select * from table(cast(generate(1,11) as t_number))<br />
/</p>
<p>Best regards,<br />
Claudiu Ariton</p>
]]></content:encoded>
	</item>
</channel>
</rss>

