Platform: Windows Server 2016 - latest updates. Lazarus 2.0.10, FPC 3.2.0, Firebird 3x
ADDED THE LINE BELOW TO THE DESCRIPTION OF THE PROBLEM-BEGIN
The Account ID is a GUID, not a number stored as a string. I need to ensure the customer didn't just make up a GUID like, GUID looking string of characters, that is not actually convertable to a GUID. A real GUID is convertible to OCTET form.
ADDED THE LINE ABOVE TO THE DESCRIPTION OF THE PROBLEM-END
I have a "customer" table with an OCTET field as the unique identifier. (CHAR(16) Character set OCTETS, Collation OCTETS. The "customer" table also has a "Username" field that is a VARCHAR(50). Customers can log in using either their Username (which is the normal way) or the Account ID (which is a string that converts to an OCTET, which is the "account recovery" mode if they forgot their Username.
I did this so I'd have an unlimited number of non-sequentially issued unique identifiers to assign, even larger than a BIGINT, and yet maintain a lighting fast query speed, since an OCTET is handled like an integer.
Goal: I'm at the point where I need to validate that the Account ID string is a valid OCTET, before I try to use it in a query against the Firebird database. Firebird will choke and error out if it cannot convert the queried string to an OCTET, so I want to ensure the string coming in the Username input from the web page is convertible to an OCTET in Pascal first.
I can't find a function to do this, only a function to do the opposite conversion (OctStr) which is not what I want. Here is what I have at the moment:
...
var login_id, login_id_oct, pwd, err_msg: String;
begin
// Determine if the Login ID is an Account ID
if (Length(login_id) = 36) then
begin
if TryStrToOct(login_id, login_id_oct) then
begin
// Customer has entered their Account ID for lookup as an OCTET
end
else
begin
// Customer has entered something other than an Account ID, so treat it as an ordinary string
end;
end;
I need a "TryStrToOct" which doesn't seem to exist.
Any suggestions?