QUESTION 1) I am not having any problems. This works for me:
$DBCOMMAND << MSG SELECT * FROM s_user INTO TEMP my_table WITH NO LOG; SELECT * FROM my_table WHERE user_id = "nails" MSG
Based on the -668 error, it looks like you don't have permission to create temporary tables.
QUESTION 2)
Every Unix version of Informix I've worked on, the dbaccess utility does not require a user or password. The Informix DBA controlled access using the Informix GRANT and REVOKE commands. Are you using the Window's version of Informix? If so, perhaps it requires a user and password?
I have absolutely no experience with the Window's version of Informix. Let's assume that dbaccess requires a -U for user option and a -P for password. You'll have to check. Then, consider something like this:
# send to standard output DBCOMMAND="$INTERFACE_CMD -e $DBNAME"; export DBCOMMAND;
engine_up=$(onstat - | grep "Up" | wc -l)
if [ $engine_up -eq 0 ] then "Informix Engine must be Up to execute commands" exit fi
$DBCOMMAND<< MSG UNLOAD TO ARCHIVE2008.csv DELIMITER "," SELECT DISTINCT "FIELD1","FIELD2","FIELD3","FIELD4" FROM SYSTABLES UNION ALL SELECT DISTINCT * FROM TMPUP;
Since I'm not at all familiar with your data I can only make a few guesses:
1) What is the table TMPUP? Based on the name, is it a temp table? I stated in an earlier post, temp tables only exist while your program - dbaccess in this case - is running. The only was your script will work is if TMPUP is a normal database table or if you create it in the same instance of $DBCOMMAND.
2) What is this???:
SELECT DISTINCT "FIELD1","FIELD2","FIELD3","FIELD4" FROM SYSTABLES
SYSTABLES is an informix system table containing information of the database's tables. FIELD1, FIELD2, etc. are not valid column names for this table.
I can't tell from your post, but are FIELD1, FIELD2, etc suppose to be shell variables?
OK, I understand what you are doing with systables. That should work.
However, what I said about the temporary table still goes.
$DBCOMMAND<< MSG -- create temp table TMPUP before the unload UNLOAD TO ARCHIVE2008.csv DELIMITER "," SELECT DISTINCT "FIELD1","FIELD2","FIELD3","FIELD4" FROM SYSTABLES UNION ALL SELECT DISTINCT * FROM TMPUP;
MSG
The TMPUP temp table MUST be created in the same DBCOMMAND instance.
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE