I have 2 groups of users user_group1, user_group2 and also two different schemas schema_group1,schema_group2 containing the same table names with a different content.
Now, i have to write a stored procedure which takes user name as input and depending on which group the user belongs to, i want to work with table in that user_group schema. i.e.(if user_group1 then "schema_group1"."table". if user_group2 then "schema_group2"."table" )
i tried to set schema using dynamic sql but it seems that the schema is changing only after the end of the stored procedure.