At 3:16 AM +0200 6/13/01, Luis A. Fdez. de Retana Aguirre wrote:
>Hello,
>
> My problem is about users variables. I want to do
>a script to create a database so:
> SET @dbname:="mydbname";
> CREATE DATABASE @dbname; # <------ Donīt
>work
> CREATE DATABASE (SELECT @dbname);# <------ Donīt
>Work
As the manual says, user-defined variables may be used wherever
an expression is legal. However, expressions aren't legal database
names, so what you're trying to do isn't legal.
If you're trying to write a script, perhaps you can use variable
substitution at the level of your scripting language, rather than
at the SQL level. For example:
#! /bin/sh
DB_NAME=mydbname
mysql <<EOF
CREATE DATABASE $DB_NAME;
EOF
>
>I have tried to define @dbname=mydbname directly
>but it blocks.
>
>Thanks
--
Paul DuBois, [EMAIL PROTECTED]
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php