Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Looking for SQL Checksum function
Mon, Jul 23 2007 5:05 PMPermanent Link

Dave Harrison
I am looking for a way that would allow me to run a checksum on a string
using SQL. I thought there would be some sort of checksum functions
(doesn't have to be MD5) available like there are in other databases. I
know I can do it in Delphi code using one of the many checksum functions
that are available, but it would be much easier with SQL. Any suggestions?

Dave
Mon, Jul 23 2007 6:08 PMPermanent Link

Eryk Bottomley
Dave,

> I am looking for a way that would allow me to run a checksum on a string
> using SQL. I thought there would be some sort of checksum functions
> (doesn't have to be MD5) available like there are in other databases. I
> know I can do it in Delphi code using one of the many checksum functions
> that are available, but it would be much easier with SQL. Any suggestions?


You'll need a custom SQL function for that I think. The implementation
is simple though:

Result := dbisamcr.MD5DigestToString(dbisamcr.MD5String(AString));

Eryk

PS: You can execute:

SELECT RecordHash AS CheckSum FROM MyTable

....and get the MD5 digest of a record ...but that doesn't help with an
arbitrary string value.
Mon, Jul 23 2007 6:19 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Dave,

<< I am looking for a way that would allow me to run a checksum on a string
using SQL. I thought there would be some sort of checksum functions (doesn't
have to be MD5) available like there are in other databases. I know I can do
it in Delphi code using one of the many checksum functions that are
available, but it would be much easier with SQL. Any suggestions? >>

You can do so via a custom function (accepts string and returns string) and
by referencing the following functions in the dbisamcr unit included with
DBISAM 4.x:

function MD5String(const AString: AnsiString): TMD5Digest;
function MD5DigestToString(const ADigest: TMD5Digest): string;

--
Tim Young
Elevate Software
www.elevatesoft.com

Image