hi, unix and mysql gurus.
i'm trying to create a simple ksh script that accesses the mysql system database table, user. the idea is that the user can call the script with a regular expression to see some users, or call it without any options to see all users. this is what i have so far:
*****************************************************
mysql -BCNnqs --disable-pager -u system -pmanager << EOJ
use mysql;
set @regex = '$1';
select user from user where user REGEXP @regex;
quit
EOJ
*****************************************************
the problem, of course, is that if $1 is null, i get this error:
==> ERROR 1139 (42000) at line 8: Got error 'empty (sub)expression' from regexp
i changed my set statement to this, but it didn't work:
*****************************************************
set @regex = if(@regex is null, '^[a-z]','$1');
*****************************************************
does anyone know what i'm doing wrong? i'd appreciate your input. thanks.