CREATE FUNCTION ColumnValue(IN TableName VARCHAR COLLATE ANSI_CI) RETURNS VARCHAR COLLATE ANSI_CI BEGIN DECLARE ResultCursor SENSITIVE CURSOR FOR Stmt; DECLARE Result VARCHAR DEFAULT ''; PREPARE Stmt FROM 'TABLE '+QUOTEDSTR(TableName,'"'); OPEN ResultCursor; -- Notice that the Company column name is "hard-coded" FETCH FIRST FROM ResultCursor (Company) INTO Result; CLOSE ResultCursor; RETURN Result; END
CREATE FUNCTION ColumnValue(IN TableName VARCHAR COLLATE ANSI_CI) RETURNS VARCHAR COLLATE ANSI_CI BEGIN DECLARE ResultCursor SENSITIVE CURSOR FOR Stmt; DECLARE Result VARCHAR DEFAULT ''; PREPARE Stmt FROM 'TABLE '+QUOTEDSTR(TableName,'"'); OPEN ResultCursor; -- Notice that the Company column name is specified as a string FETCH FIRST FROM ResultCursor ('Company') INTO Result; CLOSE ResultCursor; RETURN Result; END
CREATE FUNCTION "GetMaxOrderID" (IN "LookupID" INTEGER) RETURNS INTEGER BEGIN DECLARE Result Cursor for Stmt; DECLARE ResultID integer; PREPARE Stmt from 'SELECT MAX(OrderID) AS Max FROM MyTable WHERE LookupID = ?'; EXECUTE Stmt using LookupID; FETCH FIRST from Result(Max) into ResultID; RETURN ResultID; END
CREATE FUNCTION "GetMaxOrderID" (IN "LookupID" INTEGER) RETURNS INTEGER BEGIN DECLARE Result Cursor for Stmt; DECLARE ResultID integer; PREPARE Stmt from 'SELECT MAX(OrderID) AS Max FROM MyTable WHERE LookupID = ?'; EXECUTE Stmt using LookupID; FETCH FIRST from Result('Max') into ResultID; RETURN ResultID; END
Tags: ElevateDB, New Releases | Permanent Link |
Comments (0) | You must be logged in to comment |
This web page was last updated on Friday, May 3, 2024 at 10:28 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |