You will need to build a string for the select statement and use execute immediate.