This is untested, but what if you tweaked your code to be something like this?
function pc () { /usr/bin/psql --host=abx --port=1234 --dbname=A --username=user } function one() { pc << EOF SEL 1; EOF } function two() { while IFS= read -r line do three "$line" done < file } function three() { if [ "$1" = Y ] then pc << EOF Update table; EOF fi } # main function one two < file