2

I have a query string in variable

suppose Select Now(); I want to execute it same like SQL do. I use

Execute 'Select Now()';

But It throws an exception

prepared statement "SELECT now()" does not exist

and not allow me to execute it.

Is there any way to do that?

Pooja-G
  • 498
  • 4
  • 19

2 Answers2

2

You mess plpgsql EXECUTE:

t=# do $$ begin execute 'select now()'; end; $$;
DO

and SQLEXECUTE.

t=# prepare example as select now();
PREPARE
t=# execute example;
              now
-------------------------------
 2016-12-01 10:30:15.782433+00
(1 row)
Vao Tsun
  • 42,665
  • 8
  • 85
  • 115
-1

'Select Now()' Run like this in pgadmin

Marlon Abeykoon
  • 10,709
  • 4
  • 53
  • 72