Home All Groups Group Topic Archive Search About
Author
3 Aug 2006 12:39 PM
robken
I've have written the following piece of code, but it keeps saying
theres something wrong with the syntax near the last "END" can anyone
see what I've done wrong..

DECLARE @eu3 AS Varchar(5), @sup3 AS DECIMAL(5,2), @indid AS INT, @ind
AS Varchar(12),
@minid AS INT, @maxid AS INT, @sumpop AS DECIMAL(5,2), @specpop AS
DECIMAL(5,2), @eu4 AS Varchar(7),
@ratio AS DECIMAL(5,2), @sup4 AS DECIMAL(5,2), @place_name as
varchar(40), @x as int

WHILE @x < 11440

SELECT @eu3 = eu_code, @sup3 = ROUND(supply, 2), @indid = ind_id FROM
supdem WHERE id = 1
SELECT @ind = short FROM product WHERE iocode = @indid

DROP TABLE temp

SELECT key_id, euref, place_name, [population] INTO temp FROM place
WHERE euref LIKE
    @eu3 + '%'
SELECT @minid = MIN(key_id), @maxid = MAX(key_id), @sumpop =
SUM([population]) FROM temp

    WHILE @minid <= @maxid BEGIN
        SELECT @specpop = [population], @eu4 = euref FROM temp WHERE key_id =
@minid
        SET @ratio = ROUND(@specpop / @sumpop, 2)
        SET @sup4 = ROUND(@sup3 * @ratio, 2)
        SELECT @place_name = place_name FROM place WHERE euref = @eu4

        UPDATE LocProdYr SET [output] = @sup4 WHERE place = @place_name AND
product = @ind

        SET @minid = @minid + 1
    END

    SELECT @x = @x + 1
END


Thanks

Author
3 Aug 2006 12:48 PM
robken
I doesn't matter guys I've sorted it out, thanks anyway!

AddThis Social Bookmark Button