Linux 2.4.7-10 Scripting Question
Posted in 2003
Topics: Storage & Space Management, Server Administration, Migration, Import/Export & Data Conversion
Okay
folx, help me with a blind spot...I am having an issue with single
quotes -vs- double quotes in a script developed on Linux.
The issues:
Double quotes are required for the printf command to replace ${UNL_FILE}
with the contents of that variable, but double quotes cause the expression
(t.partnum / 1048576) to execute prior to passing the statement to the
pipe. This results in SQL Error 7607:
7607: Invalid row literal value.
A row literal should be well-formed with respect to its syntax and the type
of objects contained in the literal. For a description of the syntax and
semantics of Literal Row, refer to the Informix Guide to SQL: Syntax.
Single quotes pass ${UNL_FILE} to the pipe as a literal rather than as the
contents of the variable. This results in SQL Error 809:
-809 SQL Syntax error has occurred.
The INSERT statement in this LOAD/UNLOAD/INFO statement has invalid syntax.
Review it for punctuation and use of keywords.
My workaround at this time is to unload to a hardcoded filename and then
play with that file resulting in additional process launches (were he dead
that would cause Dan Michaelis to turn in his grave...). Any ideas folx?
BTW, thanks Art and others who publish code so that I am not required to
really think about this stuff...
The pertinent blocks of code:
#############################################################################
# Generate a list of databases in the instance.
#############################################################################
for DB in $(printf "output to pipe cat without headings select name from \\\\
sysdatabases where name not in
('onpload','sysmaster','sysutils');" \\\\
| dbaccess 2>/dev/null sysmaster);do
#############################################################################
# Unload to a file a list of tables and the dbspaces in which they reside.
#############################################################################
UNL_FILE=${DB}_tabs2dbspace.txt
printf "UNLOAD to ${UNL_FILE} delimiter \\\\" \\\\"
SELECT UNIQUE tabname, name
FROM systables t, sysmaster:sysdbspaces s
WHERE t.tabtype = "T"
and t.partnum != 0
and s.dbsnum = trunc(t.partnum / 1048576)
UNION
SELECT UNIQUE tabname, name
FROM systables t, sysfragments f, sysmaster:sysdbspaces s
WHERE t.tabtype = "T"
and t.tabid = f.tabid
and s.dbsnum = trunc(f.partn / 1048576)
ORDER BY 2;" | dbaccess 2>/dev/null ${DB}done
Regards,
Bill Roberts
AAIS Core Production Support, Informix DBA
Verizon Data Services
Office : (813) 978-2340
Pager: (888) 423-6604
e-mail:bill.roberts@verizon.com
http://dbaman.tmtrfl.tel.gte.com/browser.cgi
Thanks for the responses...the winner is...Art Kagel was the first respndent with the correct solution: I misdiagnosed the error. I needed to escape the rest of the quotes in the SQL: WHERE t.tabtype = "T" changes to WHERE t.tabtype = \\\\"T\\\\" Thanks Art!! Regards, Bill Roberts AAIS Core Production Support, Informix DBA Verizon Data Services Office : (813) 978-2340 Pager: (888) 423-6604 e-mail:bill.roberts@verizon.com http://dbaman.tmtrfl.tel.gte.com/browser.cgi