Get result from query in DO satement
How to run SQL statement within an IF condition in plpgsql? I don't want to create or replace a function. This is what I tried: DO LANGUAGE plpgsql $$ BEGIN IF 'Khosla' = 'Khosla' THEN SELECT * FROM test_log limit 10; ELSE RAISE NOTICE 'not worked'; END IF; END; $$; ERROR: query has no destination for result data HINT: If you want to discard the results of a SELECT, use PERFORM instead. CONTEXT: PL/pgSQL function "inline_code_block" line 3 at SQL statement I also tried this but was unable to get data: DO LANGUAGE plpgsql $$ BEGIN if 'a' = 'a' THEN PERFORM * FROM test_log limit 10; else raise