EXECUTE IMMEDIATE in Enterprise Postgres - query returned no rows error

706 Views Asked by At

I'm using Enterprise Postgres 9.5 with Oracle Compatibility. I have a problem with the EXECUTE IMMEDIATE command.

Say I have a table with few columns and one of them can accept NULLs. If I do

EXECUTE IMMEDIATE 'select null_col from '||table_name||' where col1=10' into x;

It sends the value to x, if null_col returns any.

When I given the condition col1=19, where 19 is not present in the table, then I get the error like this.

  query returned no rows

and my execution stops. So how can I handle that. Oracle doesn't given any error for such statements, whereas EDB does. Please help. I didn't find any EDB tags, so please tag if you think this is inappropriate question here. Thanks for understanding.

0

There are 0 best solutions below