Reply to Re: Stored procedure returns duplicates

Your name:

Reply:


Posted by Ed Murphy on 04/10/07 01:47

yin_n_yang74@yahoo.com wrote:

> --Set up some string variables to build the selection query for the
> parameters supplied
>
> declare @fields varchar(255)
> declare @tables varchar(255)
> declare @where varchar(2000)

These are unused and should be removed. (Unless they're used in code
that you edited out because it wasn't relevant to the problem at hand.)

> IF @rpt_type = 'GRP'

> IF @rpt_type NOT IN ('LOC','GRP','RES','REG')

The blocks following these appear to be identical. I recommend removing
the latter, and adding the following above the first INSERT INTO block:

IF @rpt_type NOT IN ('LOC','GRP','RES','REG') THEN
SET @rpt_type = 'GRP'

> The simplified result looks like:
>
> Sched2 Resource1 Supply1 Order5
> Sched2 Resource1 Supply1 Order6
> Sched2 Resource1 Supply3 Order5
> Sched2 Resource1 Supply3 Order6
> Sched2 Resource2 Supply1 Order5
> Sched2 Resource2 Supply1 Order6
> Sched2 Resource2 Supply3 Order5
> Sched2 Resource2 Supply3 Order6

Oversimplified. Are these SchedID, ResourceUsed, SuppliesVal, and
OrderID?

> However, I want the result to look like:
>
> Sched2 Resource1 Supply1 Order5
> Sched2 Resource2 Supply3 Order6

We need more information about all the tables involved in the stored
procedure's final query, specifically

a) whether their relationships are 1:1 or 1:N or M:N

b) what criteria tell us that Resource1 should associate only with
Supply1 (not Supply3) and Order5 (not Order6), and similarly
for Resource2 and Supply3 (not Supply1) and Order6 (not Order5)

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация