Hi there,
When I'm setting a parameter for a BIT(10) field, and assign string value "3" ( IMO, bit value 11 ), this comes though as $30 ...
On a field of type BIGINT, if I assign a string value of "3", it will come though as 3.
What is the expected behaviour when setting values for these type of parameters? How am I supposed to enter values for the BIT datatype when working with parameters?
--
Martijn Tonies
Upscene Productions
BIT as TLargetInt and parameters
It is MySQL Server behaviour. We tested this situation using "mysql.exe" utility. The result is:
For more information read MySQL Reference Manual.
Code: Select all
mysql> CREATE TABLE BitTable
-> (
-> uid int AUTO_INCREMENT PRIMARY KEY,
-> BitFld bit(10) NOT NULL,
-> BigIntFld BigInt(10) NOT NULL
-> );
Query OK, 0 rows affected (0.07 sec)
mysql> INSERT INTO BitTable (BitFld, BigIntFld) VALUES ('3', '3');
Query OK, 1 row affected (0.02 sec)
mysql> select * from bittable;
+-----+--------+-----------+
| uid | BitFld | BigIntFld |
+-----+--------+-----------+
| 1 | | 3 |
+-----+--------+-----------+
1 row in set (0.00 sec)
>when using parameters, I'm using .AsString, but given that the datatype is
>BIT, shouldn't this be passed as a number?
When you explicitly assign parameter value as a string, it causes putting it into the quotes and sending it to the server as a string value. The automatically formed INSERT query looks like the one presented in my previous post. Therefore you have invalid result. Assigning value to the parameter AsInteger gives the correct result. Please note, that MyQuery doesn't "know" about column types on the server.
>My BIT ends up as $30, not as empty.
It isn't empty, MySQL Command Line Client just doesn't display this symbol.
>BIT, shouldn't this be passed as a number?
When you explicitly assign parameter value as a string, it causes putting it into the quotes and sending it to the server as a string value. The automatically formed INSERT query looks like the one presented in my previous post. Therefore you have invalid result. Assigning value to the parameter AsInteger gives the correct result. Please note, that MyQuery doesn't "know" about column types on the server.
>My BIT ends up as $30, not as empty.
It isn't empty, MySQL Command Line Client just doesn't display this symbol.
I fail to see how this works -- I'm using parameters! Shouldn't this use a binary representation of the value? Or will assigning "as string" change this too? How would it work for, for example, the DATE type?When you explicitly assign parameter value as a string, it causes putting it into the quotes and sending it to the server as a string value.
I'm a bit puzzled here. I thought (or at least, that's what I have experienced with other database engines so far), that using parameters avoids these string, date/time settings, etc etc issues...
--
Martijn Tonies
Upscene Productions
When MyDAC passes parameter to server, it doesn't know about destination datatype (CHAR, INT, BIT etc). As result, MyDAC can only use information specified in TParam object. If you set TParam.AsString, MyDAC passes specified value as string to server. If you set TParam.AsInteger, MyDAC passes specified value as integer. So, MyDAC doesn't affect interpretation process on a server.