dbTalk Databases Forums  

How to Get Every two weeks settlement --allways Wednesday

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss How to Get Every two weeks settlement --allways Wednesday in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default How to Get Every two weeks settlement --allways Wednesday - 07-28-2006 , 01:17 PM






Hi,

I am trying to get solution for this. I need to get settlement every
two weeks and it alwyas happens on "Wednesday"

Example :To Day's Date Jul 19

My output look like this

Date Day

Jul19 Wed
Aug 2 Wed
Aug 16 Wed
Aug 30 Wed
.....so on till End Date which is 30 years

Kindly let me know ASAP

Oracle Version:Oracle 9i, restriction no PL/SQL


Regards
Jay


Reply With Quote
  #2  
Old   
Jerome Vitalis
 
Posts: n/a

Default Re: How to Get Every two weeks settlement --allways Wednesday - 07-28-2006 , 01:44 PM






rjayanth (AT) gmail (DOT) com wrote:
Quote:
Hi,

I am trying to get solution for this. I need to get settlement every
two weeks and it alwyas happens on "Wednesday"

Example :To Day's Date Jul 19

My output look like this

Date Day

Jul19 Wed
Aug 2 Wed
Aug 16 Wed
Aug 30 Wed
....so on till End Date which is 30 years

Kindly let me know ASAP

Oracle Version:Oracle 9i, restriction no PL/SQL


Regards
Jay

It's not comprehensible. Restate it differently and give at least your
tables description.


Reply With Quote
  #3  
Old   
Frank van Bortel
 
Posts: n/a

Default Re: How to Get Every two weeks settlement --allways Wednesday - 07-28-2006 , 01:47 PM



rjayanth (AT) gmail (DOT) com schreef:

Quote:
Oracle Version:Oracle 9i, restriction no PL/SQL

What else? Would external programs do? Java? Pure SQL?

--
Regards,
Frank van Bortel

Top-posting is one way to shut me up...


Reply With Quote
  #4  
Old   
Sybrand Bakker
 
Posts: n/a

Default Re: How to Get Every two weeks settlement --allways Wednesday - 07-28-2006 , 04:59 PM



On 28 Jul 2006 10:17:00 -0700, rjayanth (AT) gmail (DOT) com wrote:

Quote:
Hi,

I am trying to get solution for this. I need to get settlement every
two weeks and it alwyas happens on "Wednesday"

Example :To Day's Date Jul 19

My output look like this

Date Day

Jul19 Wed
Aug 2 Wed
Aug 16 Wed
Aug 30 Wed
....so on till End Date which is 30 years

Kindly let me know ASAP

Oracle Version:Oracle 9i, restriction no PL/SQL


Regards
Jay
Three solutions

1 Pipelined function, no table. Not allowed because pl/sql
2 dummy table, populated by an anonymous block
begin
for i in 1 .. ((30*52)/2) loop
insert into foo values (sysdate + 14 * i, to_char(sysdate+14*i,
'day');
end loop;
end;
/
but ... pl/sql
3
insert into foo values (sysdate + 14 * 1, to_char(sysdate+14*1,
'day');
insert into foo values (sysdate + 14 * 2, to_char(sysdate+14*2,
'day');
insert into foo values (sysdate + 14 * 3, to_char(sysdate+14*3,
'day');
etc

No pl/sql, but 750 commands.

Hopefully you see how utterly stupid the restriction is.

--
Sybrand Bakker, Senior Oracle DBA


Reply With Quote
  #5  
Old   
Charles Hooper
 
Posts: n/a

Default Re: How to Get Every two weeks settlement --allways Wednesday - 07-28-2006 , 07:08 PM



rjayanth (AT) gmail (DOT) com wrote:
Quote:
Hi,

I am trying to get solution for this. I need to get settlement every
two weeks and it alwyas happens on "Wednesday"

Example :To Day's Date Jul 19

My output look like this

Date Day

Jul19 Wed
Aug 2 Wed
Aug 16 Wed
Aug 30 Wed
....so on till End Date which is 30 years

Kindly let me know ASAP

Oracle Version:Oracle 9i, restriction no PL/SQL


Regards
Jay
You need a table with at least 780 rows in order to seed a counter,
then it is just a matter of multiplying the counter by 14 to hit every
other week: DBA_OBJECTS, USER_OBJECTS, etc. For example:

SELECT
(TO_DATE('2006-07-19', 'YYYY-MM-DD') + (ROWNUM - 1) * 14) NEXT_DATE
FROM
DBA_OBJECTS
WHERE
ROWNUM<=780;

Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc.



Reply With Quote
  #6  
Old   
DA Morgan
 
Posts: n/a

Default Re: How to Get Every two weeks settlement --allways Wednesday - 07-29-2006 , 12:57 PM



Charles Hooper wrote:
Quote:
rjayanth (AT) gmail (DOT) com wrote:
Hi,

I am trying to get solution for this. I need to get settlement every
two weeks and it alwyas happens on "Wednesday"

Example :To Day's Date Jul 19

My output look like this

Date Day

Jul19 Wed
Aug 2 Wed
Aug 16 Wed
Aug 30 Wed
....so on till End Date which is 30 years

Kindly let me know ASAP

Oracle Version:Oracle 9i, restriction no PL/SQL


Regards
Jay

You need a table with at least 780 rows in order to seed a counter,
then it is just a matter of multiplying the counter by 14 to hit every
other week: DBA_OBJECTS, USER_OBJECTS, etc. For example:

SELECT
(TO_DATE('2006-07-19', 'YYYY-MM-DD') + (ROWNUM - 1) * 14) NEXT_DATE
FROM
DBA_OBJECTS
WHERE
ROWNUM<=780;

Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc.
Not necessarily. Why not a pipelined table function that could
be joined in the query (no table and no maintenance ... ever).

There is a demo PTF in Morgan's Library at www.psoug.org that
shows how one is written and used in a join.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #7  
Old   
Sybrand Bakker
 
Posts: n/a

Default Re: How to Get Every two weeks settlement --allways Wednesday - 07-29-2006 , 02:08 PM



On Sat, 29 Jul 2006 09:57:27 -0700, DA Morgan <damorgan (AT) psoug (DOT) org>
wrote:

Quote:
Not necessarily. Why not a pipelined table function that could
be joined in the query (no table and no maintenance ... ever).
The 'restriction' to this quiz question was 'NO Pl/sql'

--
Sybrand Bakker, Senior Oracle DBA


Reply With Quote
  #8  
Old   
Maxim Demenko
 
Posts: n/a

Default Re: How to Get Every two weeks settlement --allways Wednesday - 07-29-2006 , 02:40 PM



DA Morgan schrieb:
Quote:
Charles Hooper wrote:
rjayanth (AT) gmail (DOT) com wrote:
Hi,

I am trying to get solution for this. I need to get settlement every


Not necessarily. Why not a pipelined table function that could
be joined in the query (no table and no maintenance ... ever).

There is a demo PTF in Morgan's Library at www.psoug.org that
shows how one is written and used in a join.
I suggest, all more or less popular approaches to generate rows are
listed here:
http://orafaq.com/wiki/Oracle_Row_Generator_Techniques

Best regards

Maxim


Reply With Quote
  #9  
Old   
DA Morgan
 
Posts: n/a

Default Re: How to Get Every two weeks settlement --allways Wednesday - 07-29-2006 , 04:51 PM



Sybrand Bakker wrote:
Quote:
On Sat, 29 Jul 2006 09:57:27 -0700, DA Morgan <damorgan (AT) psoug (DOT) org
wrote:

Not necessarily. Why not a pipelined table function that could
be joined in the query (no table and no maintenance ... ever).

The 'restriction' to this quiz question was 'NO Pl/sql'

--
Sybrand Bakker, Senior Oracle DBA
Then forget I suggested it. ;-)
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #10  
Old   
Charles Hooper
 
Posts: n/a

Default Re: How to Get Every two weeks settlement --allways Wednesday - 07-29-2006 , 06:13 PM



DA Morgan wrote:
Quote:
Charles Hooper wrote:
rjayanth (AT) gmail (DOT) com wrote:
Hi,

I am trying to get solution for this. I need to get settlement every
two weeks and it alwyas happens on "Wednesday"

Example :To Day's Date Jul 19

My output look like this

Date Day

Jul19 Wed
Aug 2 Wed
Aug 16 Wed
Aug 30 Wed
....so on till End Date which is 30 years

Kindly let me know ASAP

Oracle Version:Oracle 9i, restriction no PL/SQL


Regards
Jay

You need a table with at least 780 rows in order to seed a counter,
then it is just a matter of multiplying the counter by 14 to hit every
other week: DBA_OBJECTS, USER_OBJECTS, etc. For example:

SELECT
(TO_DATE('2006-07-19', 'YYYY-MM-DD') + (ROWNUM - 1) * 14) NEXT_DATE
FROM
DBA_OBJECTS
WHERE
ROWNUM<=780;

Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc.

Not necessarily. Why not a pipelined table function that could
be joined in the query (no table and no maintenance ... ever).

There is a demo PTF in Morgan's Library at www.psoug.org that
shows how one is written and used in a join.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
There is no table to maintain in my example - any table with a
sufficient number of rows will work to seed the counter. My example
uses the DBA_OBJECTS table, which is not the best choice, but will
exist in all Oracle databases (only accessible to users with DBA
rights). A smaller table with just enough rows is a better choice.
Also, the number 780 (52 / 2 * 30) needs to be adjusted. A year is
roughly 52 weeks, 1.24 days, so 783 is probably a better number to use
[ CEIL(52 / 2 * YEARS + 1.24 / 14 * YEARS) ].

There is no need for a complicated solution when a simple SQL statement
with a little math thrown in accomplishes the task - that is not to say
that complicated solutions should not be offered (thanks for the tip on
pipelined table functions - I might find a use for that somewhere).

Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.