Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 10 of 12 total |
Functions |
Tue, Apr 3 2007 11:55 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Anyone using functions with EDB yet, and if so can you share some code.
Roy Lambert |
Wed, Apr 4 2007 5:48 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< Anyone using functions with EDB yet, and if so can you share some code. >> Do you want just any old example, or something specific ? -- Tim Young Elevate Software www.elevatesoft.com |
Thu, Apr 5 2007 3:59 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
Any old example should do. Basically something I can use to see what and how to write them since the manual in its 1.01b1 incarnation isn't massively outspoken on the topic Roy Lambert |
Thu, Apr 5 2007 12:50 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< Any old example should do. Basically something I can use to see what and how to write them since the manual in its 1.01b1 incarnation isn't massively outspoken on the topic >> Well, there is an example in the manual for CREATE FUNCTION: -- 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(20,2) BEGIN DECLARE TempCursor CURSOR FOR stmt; DECLARE Result DECIMAL(20,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 It's basically the same as a stored procedure except that a function has a RETURNS clause and a RETURN statement at the end of the function body. -- Tim Young Elevate Software www.elevatesoft.com |
Thu, Apr 5 2007 1:54 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
>It's basically the same as a stored procedure except that a function has a >RETURNS clause and a RETURN statement at the end of the function body. No need to swear. I don't know what stored procedure's are either Roy Lambert ps didn't think to look under the CREATE part of the OLH |
Fri, Apr 6 2007 10:50 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
I think old pea brain needs a bit more help than that. What I'm trying to do is a simple thing I can do easily in SQL (I though that would give me a head start). Simply test for wether a transaction is in a specific month or not. The SQL is select * from transactions where extract(MONTH from _Date) = 4 What I wanted to do (as a training exercise) is replace it with an SQL function so I would type select * from transactions where IsInMonth(4,_Date) Roy Lambert |
Fri, Apr 6 2007 1:06 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Cracked it
CREATE FUNCTION "IsInMonth" (IN "cDate" DATE, IN "Comparator" INTEGER) RETURNS BOOLEAN BEGIN RETURN ( EXTRACT(MONTH FROM cDate) = Comparator); END Roy Lambert |
Fri, Apr 6 2007 1:06 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
This doesn't work, and I don't understand why CREATE FUNCTION "IsInMonth" (IN "cDate" DATE, IN "Comparator" INTEGER) RETURNS BOOLEAN BEGIN IF EXTRACT(MONTH FROM cDate) = Comparator THEN RETURN TRUE ELSE RETURN FALSE END IF; END ================================================================================ SQL Error (ElevateDB 1.02 Build 1) ================================================================================ ElevateDB Error #700 An error was found in the statement at line 7 and column 1 (Expected : but instead found RETURN) Roy Lambert |
Fri, Apr 6 2007 3:13 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | |
Fri, Apr 6 2007 3:13 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< No need to swear. I don't know what stored procedure's are either >> Swear ? -- Tim Young Elevate Software www.elevatesoft.com |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |