A question about Sets
A question about Sets
Hello!
I have a Field that is a Set. How can I get a listing of all text choices that are allowable in that Set?
			
									
									
						I have a Field that is a Set. How can I get a listing of all text choices that are allowable in that Set?
- 
				Guest
 
MySQL Server does not give any information to client whether selected field is a SET field. To find out if there is a SET field in result record set, additional request to server is required.
You can work with SET fields like with string fields or like with integer fields. MySQL Server applies bit encoding to values of SET fields if you use following query
Following INSERT statements are allowed
The result of these statements are the same if c_set field are defined as SET('Val1','Val2'...)
			
									
									
						You can work with SET fields like with string fields or like with integer fields. MySQL Server applies bit encoding to values of SET fields if you use following query
Code: Select all
    SELECT c_set+0 as c_set_as_integer, FROM tb_with_setCode: Select all
    INSERT INTO tb_with_set (c_set) VALUES('Val1,Val2');
    INSERT INTO tb_with_set (c_set) VALUES(3);- 
				Guest
 
I did try doing this....it works fine except for the fact it only passes the first 255 characters of the set string to s1.
AnsiString s1 = MyQuery_Site_ID->FieldByName("Site_Status")->AsString;
Unless there is another way to get more than 255 characters passed to s1 I will need to get the set as a int. (I assume a __int64 since a set can have 64 bits?)
So if I were to use a TMyCommand object to get the int value out of the set...what would the command look like? I am also curious as how to pass parameter out of a SQL (as opposed to in to). I have tried many different ways and am having no luck at all.
			
									
									
						AnsiString s1 = MyQuery_Site_ID->FieldByName("Site_Status")->AsString;
Unless there is another way to get more than 255 characters passed to s1 I will need to get the set as a int. (I assume a __int64 since a set can have 64 bits?)
So if I were to use a TMyCommand object to get the int value out of the set...what would the command look like? I am also curious as how to pass parameter out of a SQL (as opposed to in to). I have tried many different ways and am having no luck at all.
- 
				Guest
 
This is my code so far.  My SQL statement is probably wrong....but I have tried many different variations....
TParam *newParam = MyCommand_General_Use->Params->CreateParam(ftInteger, "int_site_status", ptOutput);
MyCommand_General_Use->SQL->Text = "SELECT Site_Status+0 AS int_site_status, From Site_ID WHERE ID = 168";
MyCommand_General_Use->Execute(1);
int i = MyCommand_General_Use->ParamByName("int_site_status")->AsInteger;
			
									
									
						TParam *newParam = MyCommand_General_Use->Params->CreateParam(ftInteger, "int_site_status", ptOutput);
MyCommand_General_Use->SQL->Text = "SELECT Site_Status+0 AS int_site_status, From Site_ID WHERE ID = 168";
MyCommand_General_Use->Execute(1);
int i = MyCommand_General_Use->ParamByName("int_site_status")->AsInteger;
> it works fine except for the fact it only passes the first 
> 255 characters of the set string to s1.
We couldn't reproduce the problem. Please send us (evgeniyD*crlab*com) a complete small sample to demonstrate it, including script to create and fill table.
Also supply us following information
- Exact version IDE
- Exact version of MyDAC. You can see it in About sheet of TMyConnection Editor
- Exact version of MySQL server and MySQL client. You can see it in Info sheet of TMyConnection Editor
> I am also curious as how to pass parameter out of a SQL
MySQL Server data transferring protocol does not support output parameters. Please refer to this topic: http://crlab.com/forums/viewtopic.php?t=2790.
> This is my code so far. My SQL statement is probably wrong....
> but I have tried many different variations....
Your query seems to be correct. But you should use TMyQuery component and set this query to its SQL.Text property. After opening TMyQuery you can access result record set using FieldByName method of TMyQuery.
Please read Delphi Help about usage of TDataSet class.
			
									
									
						> 255 characters of the set string to s1.
We couldn't reproduce the problem. Please send us (evgeniyD*crlab*com) a complete small sample to demonstrate it, including script to create and fill table.
Also supply us following information
- Exact version IDE
- Exact version of MyDAC. You can see it in About sheet of TMyConnection Editor
- Exact version of MySQL server and MySQL client. You can see it in Info sheet of TMyConnection Editor
> I am also curious as how to pass parameter out of a SQL
MySQL Server data transferring protocol does not support output parameters. Please refer to this topic: http://crlab.com/forums/viewtopic.php?t=2790.
> This is my code so far. My SQL statement is probably wrong....
> but I have tried many different variations....
Your query seems to be correct. But you should use TMyQuery component and set this query to its SQL.Text property. After opening TMyQuery you can access result record set using FieldByName method of TMyQuery.
Please read Delphi Help about usage of TDataSet class.
- 
				Guest