Re: can I use a user variable for xpath_expr
Hallo,
what is here the problem ???!!!
mysql> set @p_column = 'name';
Query OK, 0 rows affected (0.00 sec)
mysql> select @p_column , extractValue(@p_xml,'//dachs/host[1]/$@p_column');
ERROR 1105 (HY000): XPATH syntax error: '$@p_column'
.....but
mysql> select @p_column , extractValue(@p_xml,'//dachs/host[1]/name');
+-----------+---------------------------------------------+
| @p_column | extractValue(@p_xml,'//dachs/host[1]/name') |
+-----------+---------------------------------------------+
| name | nottuln5 |
+-----------+---------------------------------------------+
1 row in set (0.00 sec)
Or another example....
mysql> select @p_column;
+-----------+
| @p_column |
+-----------+
| name |
+-----------+
1 row in set (0.01 sec)
mysql> select extractValue(@p_xml,concat(@p_xpath,'[1]/',@p_column));
+--------------------------------------------------------+
| extractValue(@p_xml,concat(@p_xpath,'[1]/',@p_column)) |
+--------------------------------------------------------+
| |
+--------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select extractValue(@p_xml,concat(@p_xpath,'[1]/name'));
+--------------------------------------------------+
| extractValue(@p_xml,concat(@p_xpath,'[1]/name')) |
+--------------------------------------------------+
| nottuln5 |
+--------------------------------------------------+
1 row in set (0.00 sec)
mysql> select extractValue(@p_xml,concat(@p_xpath,'[1]/','name'));
+-----------------------------------------------------+
| extractValue(@p_xml,concat(@p_xpath,'[1]/','name')) |
+-----------------------------------------------------+
| |
+-----------------------------------------------------+
1 row in set (0.01 sec)
Thanks for help...
best regards
Steffen Sens
Edited 1 time(s). Last edit at 01/28/2008 07:38AM by Steffen Sens.