I am writing a BASH Shell Script to execute one SELECT query on postgreSQL and also print a custom message before the SELECT Query o/p.
FYI...
PGPASSWORD=XXXXX psql --host=XXX --port=5432 --username=XXXXX --dbname=XXXXX << EOF
DO language plpgsql $$
BEGIN
raise notice 'USER';
END
$$;
SELECT email,username,count(*) FROM users GROUP BY username,email HAVING count(*) > 1;
EOF
But this is throwing ERROR, as it replaces $$
with the PID. How can i resolve this. What can i use instead of $$
.