November 13, 2007, 06:54 PM
MacLonghornREAD fixed length var
I'm trying to read 2 variables from a SQL stored procedure output:
TABLE FILE SQLOUT
PRINT id message
ON TABLE SAVE AS MYSQL
END
-RUN
-READ MYSQL &initid.I11. &message.A120.
the first variable is fine, but the second (&message) being saved as A100V. This is a problem as vars defined this way actually concatenate all columns, so instead of &message being "Insert failed", I get "000037Insert failed". I've read about the -READ command, but I'm still a little unsure how to use it in this case.
November 13, 2007, 10:15 PM
Tom Flynnquote:
TABLE FILE SQLOUT
PRINT id message
ON TABLE SAVE AS MYSQL
END
-RUN
-READ MYSQL &initid.I11. &message.A120.
DEFINE FILE SQLOUT
MSG/A120=MESSAGE;
END
TABLE FILE SQLOUT
PRINT id MSG
ON TABLE SAVE AS MYSQL
END
-RUN
-READ MYSQL &initid.I11. &MSG.A120.
OR
-READ MYSQL &initid.I11. &FILL.A6. &message.A120.
Whatever you think is best....
November 14, 2007, 08:50 AM
PBrightwellMac,
When using var char the first 6 characters are the actual length of the field. The reading that as a separate variable as Tom suggested should work.
November 14, 2007, 09:48 AM
Tony AYou can also issue SQL SQLMSS SET VARCHAR OFF.
T