Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Product Manuals » ElevateDB Version 2 SQL Manual » DDL Statements » CREATE FUNCTION |
CREATE FUNCTION <Name> ([<ParamDefinition>[,ParamDefinition]]) RETURNS <DataType> EXTERNAL NAME <ModuleName> | <BodyDefinition> [DESCRIPTION <Description>] [VERSION <VersionNumber>] [ATTRIBUTES <CustomAttributes>] <ParamDefinition> = <Mode> <Name> <DataType> [<Description>] <Mode> = IN|OUT|INOUT <DataType> = CHARACTER|CHAR [(<Length>]) [<CollationName>] CHARACTER VARYING|VARCHAR [(<Length>]) [<CollationName>] GUID BYTE [(<LengthInBytes>]) BYTE VARYING|VARBYTE [(<LengthInBytes>]) BINARY LARGE OBJECT|BLOB CHARACTER LARGE OBJECT|CLOB [<CollationName>] BOOLEAN|BOOL SMALLINT INTEGER|INT BIGINT FLOAT [(<Precision>,<Scale>)] DECIMAL|NUMERIC [(<Precision>,<Scale>)] DATE TIME TIMESTAMP INTERVAL YEAR [TO MONTH] INTERVAL MONTH INTERVAL DAY [TO HOUR|MINUTE|SECOND|MSECOND] INTERVAL HOUR [TO MINUTE|SECOND|MSECOND] INTERVAL MINUTE [TO SECOND|MSECOND] INTERVAL SECOND [TO MSECOND] INTERVAL MSECOND <BodyDefinition> = BEGIN [<Declaration>;] [<Declaration>;] [<Statement>;] [<Statement>;] RETURN <Expression> [EXCEPTION [<Statement>;]] END
-- This function looks up the sales tax -- rate for a given state and county CREATE FUNCTION LookupSalesTaxRate(IN State CHAR(2), IN County VARCHAR) RETURNS DECIMAL(19,2) BEGIN DECLARE TempCursor CURSOR FOR stmt; DECLARE Result DECIMAL(19,2) DEFAULT 0; PREPARE stmt FROM 'SELECT * FROM SalesTaxes WHERE State = ? AND County = ?'; OPEN TempCursor USING State, County; IF (ROWCOUNT(TempCursor) > 0) THEN FETCH FIRST FROM TempCursor ('TaxRate') INTO Result; END IF; CLOSE TempCursor; RETURN Result; END
Deviation | Details |
DESCRIPTION | The DESCRIPTION clause is an ElevateDB extension. |
VERSION | The VERSION clause is an ElevateDB extension. |
ATTRIBUTES | The ATTRIBUTES clause is an ElevateDB extension. |
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 |