PG_CMD="psql -d portal -U portal -c "
PG_CMD_TP="psql -d portal -U portal -t -P format=unaligned -c "
abc()
{
$PG_CMD "
DO \$$
BEGIN
select * from customer;
END;
\$$";
}
*******MAIN***
abc
I want to print result of query on command line as well as I want to send it to excel file.
ERROR: query has no destination for result data
Erwin Brandstetter
186k28 gold badges463 silver badges636 bronze badges
asked Feb 25, 2015 at 2:07
1 Answer 1
Three misunderstandings:
You cannot return data from a
DO
command.You cannot
SELECT
without target in plpgsql code. That's what the error message tells you.You don't need either for a simple
SELECT
statement. Just run the statement itself:
abc()
{
$PG_CMD 'select * from customer'
}
answered Feb 25, 2015 at 6:02
-
thanks Erwin just one more question I need to use variable value inside copy function while writing in .csv formatuser3526905– user35269052015年02月25日 07:10:00 +00:00Commented Feb 25, 2015 at 7:10
-
@user3526905: That's seems like an unrelated question. Please start a new question, comments are not the place. Or consider related question on SO like here or here.Erwin Brandstetter– Erwin Brandstetter2015年02月25日 07:15:42 +00:00Commented Feb 25, 2015 at 7:15
Explore related questions
See similar questions with these tags.
lang-sql