Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Testing external function GreatFunction
Mon, Aug 10 2015 9:41 PMPermanent Link

Peter Evans

Here are the pieces used for getting GreatFunction to work.

Attached is the GreatFunction.zip file.

Question 1 : How do I get the DLL size smaller than 3.4 MB?

Question 2 : Why is the passed function name an AnsiString?

Question 3 : Can the passed function name be an Unicode string?

Appended is the SQL.

Question 4 : When I see the function in the Database Manager it has
assumed Unicode. Do I need to explicitly state that in the SQL?

Question 5 : What steps do I have to take to get all the pieces of
GreatFunction to work?

Regards,
  Peter Evans

==========================

/* Run the following to create the module */
/*
SCRIPT
BEGIN
  EXECUTE IMMEDIATE '
  CREATE MODULE "GreatFunction"
  PATH ''c:\DelphiProj\XXXX\TestServer\GreatFunction.dll''
  DESCRIPTION ''GreatFunction routine for testing''
';
END
*/

/* Run the following to see if it worked */
/*
SCRIPT
BEGIN
  EXECUTE IMMEDIATE '
  SELECT * FROM Configuration.Modules
';
END
*/

/*
SCRIPT
BEGIN
  EXECUTE IMMEDIATE 'CREATE FUNCTION "GreatFunction" (IN AString1
VARCHAR(255) DESCRIPTION ''Source string 1'',
                                                      IN AString2
VARCHAR(255) DESCRIPTION ''Source string 2'') RETURNS FLOAT
        EXTERNAL NAME "GreatFunction" DESCRIPTION ''When the strings
are equal the result is 1.0 otherwise 0.0'';
';
END
*/

/* The following should return every row. It returns no rows.
SELECT *
FROM GSName
WHERE GreatFunction(Surname, Given) <> 2
*/


/* In development the following showed that results were Null
SELECT
  GreatFunction('ABC', 'ABC') IS NULL
FROM GSName
*/



Attachments: GreatFunction.zip
Tue, Aug 11 2015 12:01 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Peter,

<< Question 1 : How do I get the DLL size smaller than 3.4 MB? >>

That's a function of the Delphi compiler, and is not something I can control.

<< Question 2 : Why is the passed function name an AnsiString? >>

Because you didn't use the latest template project as the starting point.  The ANSI/Unicode changes in 2.15 required changes to the external module call interface, which was further refined in 2.16.  You can read about this in the release notes:

http://www.elevatesoft.com/download?action=info&category=edb&type=edbvcltrial&majorversion=2&version=2.19#releasenotes

under 2.16 Breaking Changes - Module Changes.

<< Question 3 : Can the passed function name be an Unicode string? >>

See above.

<< Question 4 : When I see the function in the Database Manager it has assumed Unicode. Do I need to explicitly state that in the SQL? >>

What SQL are you specifically referring to ?

<< Question 5 : What steps do I have to take to get all the pieces of GreatFunction to work? >>

Start with the latest module template project, and then be sure to follow the instructions included in the main unit:

unit unit1;

interface

uses SysUtils, Classes, DB, edbextmodule;

{  Define the compiler define EDB_UNICODE in the project's compiler defines
  if you want the external module to be a Unicode module }  <<<<<<<<<<<<<<<<<<<  HERE

Also, modules can also use relative path names in the CREATE MODULE statement, so I would suggest using them in order to avoid the same issue you had with the databases.

Tim Young
Elevate Software
www.elevatesoft.com
Image