BIT as TLargetInt and parameters

BIT as TLargetInt and parameters

Postby Upscene » Fri 27 Jan 2006 10:32

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
Upscene
 

Postby Ikar » Tue 31 Jan 2006 10:11

It is MySQL Server behaviour. We tested this situation using "mysql.exe" utility. The result is:
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)

For more information read MySQL Reference Manual.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby upscene » Tue 31 Jan 2006 11:02

This doesn't look like the same behaviour to me.

1) I'm using parameters, not a direct INSERT INTO.

2) when using parameters, I'm using .AsString, but given that the datatype is BIT, shouldn't this be passed as a number?

3) My BIT ends up as $30, not as empty.

--
Martijn Tonies
Upscene Productions
upscene
 

Postby Ikar » Mon 06 Feb 2006 10:39

>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.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby upscene » Mon 06 Feb 2006 15:36

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 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?

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
upscene
 

Postby Ikar » Tue 07 Feb 2006 14:03

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.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56


Return to MySQL Data Access Components