Below is the stored procedure we are trying to create. Below that is the ISAM error we get when doing the insert into the temporary table. It is very similar to your example but the select is coming out of a temporary table. The parameters used were '0000321234695246' and '''Cust_Delivery_Info'',''Pickup_Delivery'''. I have tried removing the "And SV_Key In(..." statement but I get the same error either way. Any insights would be helpful and appreciated.
Create PROCEDURE SessionVariableGetMany
(
SessionId CHAR ( 16 ),
VarNames CHAR ( 2000 ),
CURSOR VARYING OUTPUT
)
BEGIN
Declare @Sql char(2000);
@Sql = 'Insert Into #tempSVGM (SV_Key, SV_Value) Select SV_Key, SV_Value From SessionV Where SV_CustNum = ''' + _SessionID + ''' And SV_Key In (' + RTrim(_VarNames) + ');';
Try
Create Table #tempSVGM (SV_Key Char( 50 ), SV_Value Char( 254 ));
Catch All
Delete From #tempSVGM;
End Try;
Execute Immediate RTrim(@Sql);
Select * From #tempSVGM;
END;
poQuery: Error 7200: AQE Error: State = HY000; NativeError = 5154; [iAnywhere Solutions][Advantage SQL][ASA] Error 5154:
Execution of the stored procedure failed. Procedure Name: SessionVariableGetMany. Error 7200: AQE Error: State = S0000;
NativeError = 2004; [iAnywhere Solutions][Advantage SQL Engine][ISAM]ISAM error <identifier> - EXECUTE IMMEDIATE --
Location of error in the SQL statement is: 310 (line: 10 column: 21)