If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > How do you find Deleted D/O No.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-08-07, 21:53
chiwaki chiwaki is offline
Registered User
 
Join Date: Jun 2005
Location: Singapore
Posts: 60
How do you find Deleted D/O No.

I have 1,000 D/O every month, D/O is deleted when canceled
How do you usually find this deleted D/O ?

this month D/O range is 2,301 to 3,300, D/O table name is do_hdr,
You can list D/O by following SQL
select * from do_hdr where do_no between 2,301 and 3,300
deleted D/O is 2310, 2350, 3000, 3150 (Answer)

1. using SQL only (including stored procedure), for generation of No. from 2301 to 3300.
select * from gen_no(2301,3300) where g_no not in (select do_no from
do_hdr where do_no between 2300 and 3300)
min 2301, max 3300, diff 1000
How do you generate No. ? 2 args, gen_no(2301,3300)

2. Any other way ?

ex. following stored procedure generate no, but need require Server option
PROCEDURE gen_no"(fr_no integer,to_no integer)
begin
with recursive num(nu) as
(select fr_no
union all
select nu+1 from num where nu <= to_no
)
select nu from num;
end

select * from gen_no(2301,3300) where g_no not in (select do_no from
do_hdr where do_no between 2300 and 3300)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On