Tag Info

New answers tagged

1

You have hugely overcomplicated the solution. SQL code After removing much of the cruft, it boils down to this: DO $do$ DECLARE customer_schema text; BEGIN FOR customer_schema IN SELECT cname FROM customer LOOP EXECUTE format('COPY ( SELECT p.*, t1.*, t2.* -- etc. Or just: * FROM %1$I.portal p ...


0

what you are doing is maybe not the right approach. what you want is ... COPY (SELECT ...) TO 'some_file_name' CSV; the crux might be your loop. you can get rid around that one easy: there is a function called unnest, which can transform an array into a table which can then be joined or whatever (via a LATERAL join maybe). you are on the wrong path with ...


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' }


2

Postgres.app has a short documentation here: http://postgresapp.com/documentation/ which tells among other things: Configure your $PATH Postgres.app includes many command line tools. If you want to use them, you must configure the $PATH variable. If you are using bash (default shell on OS X), add the following line to ~/.bash_profile: ...


0

A nice way to do this is using the 9.3-specific \gset psql command: SELECT current_setting('search_path') AS my_path \gset set search_path to schema_a, :my_path; \gset is documented here and is demonstrated nicely on depesz.com. I was not able to test this as I don't have access to an instance of 9.3. I'd be grateful to anyone who could confirm to me ...


0

Another way to do this is to originally set the search_path in a two-step procedure: \set my_path schema_b, schema_c, public set search_path to :my_path; Then, whenever you want to extend search_path, do it like so: \set my_path schema_a, :my_path set search_path to :my_path; This does not allow for storing the existing value of search_path however.


0

You can always prefix the query with the postgres comment string: --select foo from bar; and the query will not run but will be available in the psql deadline history buffer for editing.



Top 50 recent answers are included