NAME:
mysqlquery
PURPOSE:
Submit MySQL query and get response as vectors of data (like readcol).
DESCRIPTION:
Submit a simple SQL query to MySQL server, using the connection
previously opened with openmysql. Retrieve the result into
a row of variables, much as readcol does. Return dimensionality
of result(s).
CATEGORY:
Database
CALLING SEQUENCE:
mysqlquery,lun,query,[varables...],[format='(a,f,...)']
INPUTS:
lun - The logical unit of the pipe (opened by openmysql).
query - String (or array of strings) to send to pipe.
OPTIONAL INPUT PARAMETERS:
KEYWORD INPUT PARAMETERS:
format - Specify format of output variables (default is ascii).
cmd - Flag indicating this is a command, not a query so
don't bother processing the output (but do report the
number of rows affected/warnings? - not implimented).
verbose - Flag turns on debugging output to standard out.
OUTPUTS:
variables - A list of variables to recieve columns of output.
Default type is ascii, but use the format keyword to
specify other data types.
KEYWORD OUTPUT PARAMETERS:
HEADS - String to receive array of column heads.
NGOOD - Number of valid lines found that were read.
COMMON BLOCKS:
SIDE EFFECTS:
RESTRICTIONS:
Requires an open connection to MySQL server (established by
use of openmysql) as well as valid permissions for whatever
query or command is to be executed.
PROCEDURE:
MODIFICATION HISTORY:
2002-02-14 Will Grundy, adapted from earlier version called mysql.pro
2002-02-27 WG changed behavior so 'NULL' becomes NaN instead of
making the line be ignored when it occurs in a numerical
field.
2002-03-25 WG changed to split on tab instead of white space, so that
strings with internal spaces (but not tabs) can be retrieved.
2003/01/10, MWB, fixed multi-line query error. Only one query per
call is allowed.
2006/11/09, PLC, changed strsplit call to use /preserve_null flag
this means a field can now return an empty string.
The behavior for non-'a' type fields is not defined
in this case.
2007/07/15, MWB, added NGOOD output keyword
2010/03/11, MWB, change behavior so that if there is only one valid
line the result is returned as a scalar instead of
a one-element vector.
BUGS/WISH LIST:
Ought to verify connection to MySQL server.
Does nothing helpful with SQL command results.
Does nothing helpful to identify/report bad SQL syntax.