Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Product Manuals » ElevateDB Version 2 SQL Manual » SQL/PSM Statements » BEGIN..END |
[Label:] BEGIN [<Statement>;] [<Statement>;] END [Label];
-- This procedure produces a summary -- of the number of albums and total album -- purchases by genre, label, or artist CREATE PROCEDURE Summaries(IN "SummaryType" CHAR(1) COLLATE ANSI_CI) BEGIN DECLARE Result CURSOR WITH RETURN FOR Stmt; CASE SummaryType -- Genres summary WHEN 'G' THEN BEGIN PREPARE Stmt FROM 'SELECT Genre AS Name, COUNT(Name) AS NumAlbums, SUM(PurchasePrice) AS TotalPurchases FROM Albums GROUP BY Genre'; OPEN Result; END; -- Labels summary WHEN 'L' THEN BEGIN PREPARE Stmt FROM 'SELECT Label AS Name, COUNT(Name) AS NumAlbums, SUM(PurchasePrice) AS TotalPurchases FROM Albums GROUP BY Label'; OPEN Result; END; -- Artists summary WHEN 'A' THEN BEGIN PREPARE Stmt FROM 'SELECT Artist AS Name, COUNT(Name) AS NumAlbums, SUM(PurchasePrice) AS TotalPurchases FROM Albums GROUP BY Artist'; OPEN Result; END; END CASE; END
Deviation | Details |
None |
This web page was last updated on Thursday, November 16, 2023 at 10:39 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |