Your &MISC# variable is being passed as a numeric parm, and that’s fine as long as it was generated in the calling program as *DEC (4 0) or a compatible data type in a different language. But when it is used by the STRQMQRY command, it needs to be a series of character digits.

We do that by creating a *CHAR variable that is 4 bytes long and letting the CHGVAR command do a straight conversion. Bear in mind that the CL variable named &MISC has no relationship at all with your QM replacement variable of the same name. It’s probably not a good idea to use the same name for both, but it will work. It just brings potential confusion when errors come up.

I also got rid of the ALWQRYDFN() parameter. Since you’re creating a QM query, you don’t want some *QRYDFN object of the same name getting into this. I’d make other changes, but they aren’t actually required for this question.

I replaced the “&MISC” for the second column with a column name of “somecolumn”, though I think I can see why you had it there. If you really wanted a column from a table, then use the name of that column. You might even put &MISC back and have it work. It doesn’t make much sense, though, for this SELECT statement since the same value is going to show up in the bcbgcd column anyway. Your WHERE clause guarantees that both columns will be nothing but repeats of the value in &MISC — if 1000 rows match, then that value will display 2000 times and nothing else will show up.

I assume that you will develop the SELECT statement over time to make it more meaningful. This should get you closer.

But what is the SET statement for? You already have a replacement variable in the WHERE clause that would receive your numeric parameter. You don’t need a SET statement for anything. The value will be set when you run the STRQMQRY command.

Also, you have &MISC at the beginning of statement 0008.00. It doesn’t seem appropriate there, especially if it’s going to be a numeric value. You need to replace &MISC in statement 0008.00 with a column name from your table.

(Or are you trying to reference the ordinal column number?)

Maybe the best thing would be if you showed us what you want your final SQL statement to look like when it executes.

Tom

]]>By: a1maidahttp://itknowledgeexchange.techtarget.com/itanswers/query-manager-error/#comment-81417
Mon, 13 Sep 2010 13:56:55 +0000#comment-81417I am trying to pass a numeric parameter.
]]>By: tomliottahttp://itknowledgeexchange.techtarget.com/itanswers/query-manager-error/#comment-81377
Fri, 10 Sep 2010 20:45:38 +0000#comment-81377I don’t quite understand what you are trying to do. If this is a QM query, then what is this statement doing in there:

0001.00 SET MISC :MISC6

SET <variable> isn’t a valid QM query statement. And if it was, it wouldn’t have a syntax that looked that way. What are you trying to do?