multiple statements, assign it to a variable. The following example shows how to do this, and illustrates that attribute values are available in subsequent statements by means of the variables, but not by calling mysql_query_attribute_string() : 

mysql> query_attributes n1 v1 n2 v2; mysql> SET @attr1 = mysql_query_attribute_string(’n1’), @attr2 = mysql_query_attribute_string(’n2’); mysql> SELECT @attr1, mysql_query_attribute_string(’n1’) AS ’attr 1’, @attr2, mysql_query_attribute_string(’n2’) AS ’attr 2’; +--------+--------+--------+--------+ | @attr1 | attr 1 | @attr2 | attr 2 | +--------+--------+--------+--------+ | v1 | NULL | v2 | NULL | +--------+--------+--------+--------+ 

Attributes can also be saved for later use by storing them in a table: 

mysql> CREATE TABLE t1 (c1 CHAR(20), c2 CHAR(20)); mysql> query_attributes n1 v1 n2 v2; mysql> INSERT INTO t1 (c1, c2) VALUES( mysql_query_attribute_string(’n1’), mysql_query_attribute_string(’n2’) ); mysql> SELECT * FROM t1; +------+------+ | c1 | c2 | +------+------+ | v1 | v2 | +------+------+ 

Query attributes are subject to these limitations and restrictions: 

•If multiple attribute-definition operations occur prior to sending a statement to the server for execution, the most recent definition operation applies and replaces attributes defined in earlier operations. 

•If multiple attributes are defined with the same name, attempts to retrieve the attribute value have an undefined result. 

•An attribute defined with an empty name cannot be retrieved by name. 

•Attributes are not available to statements prepared with PREPARE . 

•The mysql_query_attribute_string()  function cannot be used in DDL statements. 

•Attributes are not replicated. Statements that invoke the mysql_query_attribute_string() function will not get the same value on all servers. 

## Prerequisites for Using Query Attributes 

To access query attributes within SQL statements for which attributes have been defined, the query_attributes  component must be installed. Do so using this statement: 

INSTALL COMPONENT "file://component_query_attributes"; 

Component installation is a one-time operation that need not be done per server startup. INSTALL COMPONENT  loads the component, and also registers it in the mysql.component  system table to cause it to be loaded during subsequent server startups. 

