The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
.
google unix.com



UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
regular expressions melanie_pfefer UNIX for Dummies Questions & Answers 8 04-10-2008 04:24 AM
regular expressions whatever Shell Programming and Scripting 4 05-20-2007 04:30 PM
regular expressions ragha81 UNIX for Dummies Questions & Answers 2 03-05-2007 07:24 PM
Regular Expressions AresMedia Shell Programming and Scripting 1 08-22-2002 03:55 PM
Regular expressions in sed mfreemantle Shell Programming and Scripting 2 02-12-2002 04:43 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 09-10-2008
ankimo ankimo is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 23
passing regular expressions to mysql via $1

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.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0