Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3756038
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:47:26+00:00 2026-05-19T09:47:26+00:00

In Delphi XE, I am storing crc32 hash of a string in an SQlite

  • 0

In Delphi XE, I am storing crc32 hash of a string in an SQlite database, in a column declared as INTEGER. My understanding is that SQlite does not distinguish among integer types: int, int64, signed and unsigned, they’re all the same as far as the database is concerned. However, when I store a value declared as longword in Delphi, a WHERE clause fails to match on that value later.

My insert statement (trimmed down here) is:

INSERT INTO main VALUES (id, crc) (?, ?);

The longword value gets bound to the second parameter and all goes well. But when I do

SELECT id FROM main WHERE crc = ?;

the query returns no results.

Viewing the database in SQLiteSpy, the longword values are displayed as negative integers. If I execute the above SELECT with the negative value copy-and-pasted from that display, the query returns the expected record.

It would seem that when I bind a longword value to the INSERT statement, SQLIte does something else then when I bind the same longword value to the SELECT statement. Casting the value to integer (in Delphi code, not in SQL) fixes the problem, but it should not be necessary, and it’ll be easy to forget to cast in other places. Is there a better solution? Is SQLite behaving correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:47:27+00:00Added an answer on May 19, 2026 at 9:47 am

    The problem is not in SQLite, but in the way you’re binding your parameters to the SQLite engine.

    Depending on the SQlite framework you’re using, you must explicitely bound an Int64 to your statement:

    INSERT INTO main VALUES (id, crc) (?, ?);
    

    For example, using our framework, with a CRC declared as a Cardinal, you must use this code (and NOT any integer(CRC)):

    sqlite3_check(RequestDB,sqlite3_bind_Int64(Request,2,Int64(CRC)));
    

    If the above code doesn’t work, this will always work:

    var CRC64: Int64;
        CRC64Rec: TInt64Rec absolute CRC64;
    begin
      CRC64Rec.Lo := CRC;
      CRC64Rec.Hi := 0;
      sqlite3_check(RequestDB,sqlite3_bind_Int64(Request,2,CRC64));
    

    In all cases, without showing your own code about binding parameters, it’s difficult to know what’s wrong in your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will be storing datetime values in an SQLite database (using Delphi and the
Delphi strings use single quotes, for example ' a valid string '. How does
Delphi 2009 has changed its string type to use 2 bytes to represent a
I'm using the Delphi function StringCodePage I call it on a string returned by
Delphi has a $WARN compiler directive that allows one to selectively enable or disable
In Delphi, I want to be able to create an private object that's associated
I am writing a program using Delphi 2006 and storing data in XML files
In Delphi 2009 and later versions, string type implicitly equal to UnicodeString type. My
How do I declare a fixed size string property in Delphi? This is what
Is there any way in Delphi 5 to convert a string to a TDateTime

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.