I am looking to run the following statement in dynamic sql
SET TEXT = ('set ? =(SELECT MAX(' ||m_id || ') FROM ' || database ||'.' || table || ')');
PREPARE S1 FROM TEXT;
EXECUTE S1 into P_id;
this the debug value for the above statement
SELECT MAX(apple_id) FROM SAMPLE.TROY.LOYEE
Apple_id column is an integer data type.
But throwing an error: apple_id is not valid in the context where it is used.. SQLCODE=-206, SQLSTATE=42703.
I never used this Max function inside a dynamic sql yet. I know how to run this alone on static.
I request can some tel me how to use these max,min, avg etc functions inside a dynamic sql. This is very basic, but the help will be a big thing for me.