Re: [GENERAL] pg_query & $result re-fill

2008-06-12 Thread Stefan Schwarzer
Here I would like to check: IF param1 < 75 THEN region-in-$result-should-be-set-to-NULL Not sure I get what all you're wanting to do from your message, but could you use a case statement in sql to do this? Or put it in the where clause? I knew it too be a bit complicated to explain

[GENERAL] How to INSERT empty line into SEQUENTIAL table from PHP

2008-06-15 Thread Stefan Schwarzer
Hi, rahter dump question, I guess But I have a table with a sequential index field, into which I would like to add from time to time another line (via webbrowser), which in turn, stays first empty, before it's being filled in later (via webbrowser). Because the ID field is sequential

Re: [GENERAL] How to INSERT empty line into SEQUENTIAL table from PHP

2008-06-16 Thread Stefan Schwarzer
Tuskenis wrote: Hi, Stefan. your second example should work for you. INSERT INTO table_xx (field2, field3, field4) VALUES ('', '', ''); (keeping in mind, that your ID column is of type serial or has DEFAULT NEXTVAL('some_sequence') ). You can also insert

Re: [GENERAL] How to INSERT empty line into SEQUENTIAL table from PHP

2008-06-16 Thread Stefan Schwarzer
'') Thanks a lot!! Stef I guess you get duplicate value error because you have previously inserted ID column with your own values. Check the sequence page_input_id_seq if it points to the right next value. If not - correct it to a MAX(ID) +1 Julius Tuskenis Stefan Schwarzer

[GENERAL] How to rename the same column name in dozens of tables in Postgres?

2013-12-17 Thread Stefan Schwarzer
Hi there, I have dozens of tables where I need to rename one column in each of these. Is there any generic way to do that? I am not really familiar with the scripting possibilities of Postgres. Thanks a lot for your help! Stefan -- Sent via pgsql-general mailing list (pgsql-general@postgresq

Re: [GENERAL] How to rename the same column name in dozens of tables in Postgres?

2013-12-17 Thread Stefan Schwarzer
> Hi there, > > I have dozens of tables where I need to rename one column in each of these. > Is there any generic way to do that? > I am not really familiar with the scripting possibilities of Postgres. > > Thanks a lot for your help! > > Stefan > > > You can do with script. I made one on fl

[GENERAL] Problem installing extensions on Lion

2012-06-12 Thread Stefan Schwarzer
Hi there, I upgraded my machine from Snow Leopard to Lion, and ran, as usual, into some Postgres update problems. I used Kyngchaos libraries for all frameworks and Postgres. Now, I'd like to install the tablefunc/crosstab function. But the "make" process gives me this: cd contrib/tablefunc ta

Re: [GENERAL] Problem installing extensions on Lion

2012-06-12 Thread Stefan Schwarzer
>> I upgraded my machine from Snow Leopard to Lion, and ran, as usual, into >> some Postgres update problems. >> >> I used Kyngchaos libraries for all frameworks and Postgres. Now, I'd like to >> install the tablefunc/crosstab function. >> >> But the "make" process gives me this: > > Looks lik

Re: [GENERAL] Problem installing extensions on Lion

2012-06-14 Thread Stefan Schwarzer
> In file included from /usr/local/pgsql-9.1/include/server/postgres.h:47, > from tablefunc.c:33: > /usr/local/pgsql-9.1/include/server/c.h:67:19: error: stdio.h: No such file > or directory > /usr/local/pgsql-9.1/include/server/c.h:68:20: error: stdlib.h: No such file > or direc

[GENERAL] Error message "psql: could not connect to server: No such file or directory"

2012-06-14 Thread Stefan Schwarzer
Hi there, I guess this is a typical user error. I searched around to find the solution, but in vain. I just upgraded to Lion, and used Kyngchaos libraries for installation of Postgres. Try to get running postgres, and I get this: /usr/local/pgsql-9.1/bin/psql -U postgres psql: co

Re: [GENERAL] Problem installing extensions on Lion

2012-06-14 Thread Stefan Schwarzer
On Jun 14, 2012, at 3:32 PM, Adrian Klaver wrote: > On 06/14/2012 04:47 AM, Stefan Schwarzer wrote: >>> In file included from /usr/local/pgsql-9.1/include/server/postgres.h:47, >>> from tablefunc.c:33: >>> /usr/local/pgsql-9.1/include/server/c.h:

Re: [GENERAL] Error message "psql: could not connect to server: No such file or directory"

2012-06-14 Thread Stefan Schwarzer
>> Hi there, >> >> I guess this is a typical user error. I searched around to find the >> solution, but in vain. >> >> I just upgraded to Lion, and used Kyngchaos libraries for installation of >> Postgres. >> >> Try to get running postgres, and I get this: >> >> /usr/local/pgsql-9.1/bi

[GENERAL] How to include Tablefunc as an extension

2012-06-18 Thread Stefan Schwarzer
Hello, I read through the Postgres doc and many Google results, but it seems still unclear to me how to include additional packages into my postgres database. I see that there are a few installed under "/usr/local/pgsql-9.1/share/extension/" (I am on Lion and installed the Kyngchaos libs).

Re: [GENERAL] How to include Tablefunc as an extension

2012-06-18 Thread Stefan Schwarzer
>> I read through the Postgres doc and many Google results, but it seems >> still unclear to me how to include additional packages into my postgres >> database. I see that there are a few installed under >> "/usr/local/pgsql-9.1/share/extension/" (I am on Lion and installed the >> Kyngchaos libs).

Re: [GENERAL] Error message "psql: could not connect to server: No such file or directory"

2012-06-19 Thread Stefan Schwarzer
>>> I guess this is a typical user error. I searched around to find the >>> solution, but in vain. >>> >>> I just upgraded to Lion, and used Kyngchaos libraries for installation of >>> Postgres. >>> >>> Try to get running postgres, and I get this: >>> >>> /usr/local/pgsql-9.1/bin/psql -U

Re: [GENERAL] Error message "psql: could not connect to server: No such file or directory"

2012-06-20 Thread Stefan Schwarzer
>> I need unfortunately to come back to this issue. I (again) re-installed Lion >> from scratch, and finally got everything working. The Postgres was running, >> I uploaded a couple of dumped SQL files. And then re-started the machine for >> another reason. And suddenly it says again the it can

Re: [GENERAL] How to include Tablefunc as an extension

2012-06-20 Thread Stefan Schwarzer
I read through the Postgres doc and many Google results, but it seems still unclear to me how to include additional packages into my postgres database. I see that there are a few installed under "/usr/local/pgsql-9.1/share/extension/" (I am on Lion and installed the Kyngcha

Re: [GENERAL] How to include Tablefunc as an extension

2012-06-21 Thread Stefan Schwarzer
>> I do as indicated in Kyngchaos ReadMe file: > >>export PATH="/usr/local/pgsql-9.1/bin:$PATH" >>export USE_PGXS=1 >>make >>sudo make install > > I'm beginning to wonder who are Kyngchaos and whether they are competent > at all. They obviously didn't test the above advice. It d

Re: [GENERAL] Error message "psql: could not connect to server: No such file or directory"

2012-06-21 Thread Stefan Schwarzer
>> >> When I do: sudo launchctl load >> /Library/LaunchDaemons/org.postgresql.postgres.plist >> it says: org.postgresql.postgres: Already loaded >> >> When I do: /usr/local/pgsql-9.1/bin/initdb -U postgres -D >> /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US >> it s

Re: [GENERAL] Error message "psql: could not connect to server: No such file or directory"

2012-06-22 Thread Stefan Schwarzer
> sudo su - _postgres /usr/local/pgsql-9.1/bin/initdb -U postgres -D > /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US > sudo su - _postgres /usr/local/pgsql-9.1/bin/pg_ctl start -D > /usr/local/pgsql-9.1/data > > Although I don't get an error message, I don't have the feeling that it

Re: [GENERAL] Problem installing extensions on Lion

2012-06-22 Thread Stefan Schwarzer
>>> 1) Do the above files actually exist in the above location? > >> Yes, the c.h exist in the mentioned location. However, as it does not >> indicate where it looks for the stdio.h, perhaps the problem lies there. > > Indeed. Where did you get the advice to use "-isysroot > /Developer/SDKs/Mac

[GENERAL] pg_dump not dumping all tables

2012-06-22 Thread Stefan Schwarzer
Hi there, I am pg_dump-ing all tables from schema public on the server /usr/local/pgsql/bin/pg_dump -U user my_database --schema=public --encoding=UTF-8 > dump.sql and re-loading it via psql on my local machine. But instead of having 708 tables as on the server, I end up with only 570

Re: [GENERAL] pg_dump not dumping all tables

2012-06-24 Thread Stefan Schwarzer
>> Hi there, >> >> I am pg_dump-ing all tables from schema public on the server >> >> /usr/local/pgsql/bin/pg_dump -U user my_database --schema=public >> --encoding=UTF-8 > dump.sql >> >> and re-loading it via psql on my local machine. >> >> But instead of having 708 tables as on the ser

Re: [GENERAL] Error message "psql: could not connect to server: No such file or directory"

2012-06-24 Thread Stefan Schwarzer
>>> sudo su - _postgres /usr/local/pgsql-9.1/bin/initdb -U postgres -D >>> /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US >>> sudo su - _postgres /usr/local/pgsql-9.1/bin/pg_ctl start -D >>> /usr/local/pgsql-9.1/data >>> >>> Although I don't get an error message, I don't have the feeli

Re: [GENERAL] Error message "psql: could not connect to server: No such file or directory"

2012-06-25 Thread Stefan Schwarzer
> I just went back to the postgres documentation [1] (actually reading all > google results on the error message one after the other) and tried out what > was said there (adapted to my conditions): > > sudo -u _postgres /usr/local/pgsql-9.1/bin/postgres -D > /usr/local/pgsql-9.1/data > > and s

[GENERAL] ERROR: function crosstab(unknown, unknown) does not exist

2012-07-03 Thread Stefan Schwarzer
Hi there, I am using 9.1.3. I inserted the tablefunc extension, into a SCHEMA called tablefunc, in order to separate it from my tables. I had to create it as postgres user, but changed than the Owner of both schema and functions to my user XXX. Now, when I launch a query which includes "crosst

Re: [GENERAL] ERROR: function crosstab(unknown, unknown) does not exist

2012-07-04 Thread Stefan Schwarzer
>>> Now, when I launch a query which includes "crosstab()" as a postgres user, >>> everything works fine. However, if I launch it as user XXX, it complaints: > >> Are you schema qualifying the function name when you use it? >> If not, does user XXX have schema tablefunc in their search_path? > >

Re: [GENERAL] ERROR: function crosstab(unknown, unknown) does not exist

2012-07-05 Thread Stefan Schwarzer
> Now, when I launch a query which includes "crosstab()" as a postgres > user, everything works fine. However, if I launch it as user XXX, it > complaints: >>> Are you schema qualifying the function name when you use it? If not, does user XXX have schema tablefunc in their

Re: [GENERAL] ERROR: function crosstab(unknown, unknown) does not exist

2012-07-09 Thread Stefan Schwarzer
> If the textual value of search_path (as per "show search_path") lists > the schema but current_schemas() doesn't, I have to think that you've > got a permissions problem --- the system will silently ignore any > search_path entries for which you don't have USAGE permission. > You said you'd done

[GENERAL] ERROR: out of shared memory - But the table is empty

2012-07-12 Thread Stefan Schwarzer
Hi there, not being an expert for Postgres…. I have a Postgis table with the countries of the world. Now, I would like to drop it. I got the error message: ERROR: out of shared memory HINT: You might need to increase max_locks_per_transaction. and thought that it would be easier to

Re: [GENERAL] ERROR: out of shared memory - But the table is empty

2012-07-13 Thread Stefan Schwarzer
> not being an expert for Postgres…. I have a Postgis table with the countries > of the world. Now, I would like to drop it. I got the error message: > > ERROR: out of shared memory > HINT: You might need to increase max_locks_per_transaction. > > and thought that it would be easier

[GENERAL] Make & Install contrib/tablefunc Problems

2010-06-10 Thread Stefan Schwarzer
Hi there, strange thing, but every time I need to (re)install the tablefunc, I run into problems. I am using the Kyngchaos packages for Snow Leopard. Everything works smoothly, until I arrive at the additional, manual installation of tablefunc. I downloaded the correct version of the postgres

[GENERAL] Make & Install contrib/tablefunc Problems

2010-06-10 Thread Stefan Schwarzer
Hi there, strange thing, but every time I need to (re)install the tablefunc, I run into problems. I am using the Kyngchaos packages for Snow Leopard. Everything works smoothly, until I arrive at the additional, manual installation of tablefunc. I downloaded the correct version of the postgres

[GENERAL] Make & Install contrib/tablefunc Problems

2010-01-25 Thread Stefan Schwarzer
Hi there, I deleted involuntarily my tablefunc functions in my database. Now, I am trying to get them back into it again. But without success. I am running Mac OS X, 10.5, with postgres 8.3.1 and have used the Kyngchaos packages. It seems to me that before I succeeded in doing this from w

Re: [GENERAL] Make & Install contrib/tablefunc Problems

2010-01-25 Thread Stefan Schwarzer
But when I do this I get this error message: Makefile:17: ../../src/Makefile.global: No such file or directory Makefile:18: /contrib/contrib-global.mk: No such file or directory make: *** No rule to make target `/contrib/contrib-global.mk'. Stop. What is the problem? What

Re: [GENERAL] Make & Install contrib/tablefunc Problems

2010-01-26 Thread Stefan Schwarzer
The following does basically the same thing, but I find it a bit easier to follow: sudo -u postgres /usr/local/pgsql/bin/pgsql < tablefunc.sql Thanks for that. Looks indeed less complicated! :-) But not yet success for me: I did re-start, just to be sure. for postgres: ./configu

[GENERAL] How to escape apostrophes when apostrophes already used to escape something else

2010-02-05 Thread Stefan Schwarzer
Hi there, probably not too complicated, but although googling my way through many pages, I don't find the solution. I have a query which uses already an apostrophe to escape something else: $query = "SELECT * FROM crosstab('S

[GENERAL] Subqueries or Joins? Problems with multiple table query

2010-02-23 Thread Stefan Schwarzer
Hi there, gush, shouldn't be that complicated. But neither in Postgres, nor in Access I succeed in getting the result I wish. I have a couple of times for the Environmental Conventions (Kyoto, Montreal, CITES etc.). They look like this: id_country,year,value 4,1992,0 4,1993,0 4,1994,0 4,1

Re: [GENERAL] Subqueries or Joins? Problems with multiple table query

2010-02-23 Thread Stefan Schwarzer
Select countries.name, basel.year, basel.value, cites.year, cites.value From countries Left Join basel on basel.id_country = countries.id_country and basel.value=1 Left Join cites on cites.id_country = countries.id_country and cites.value=1 I would have thought so, but the query turns fore

Re: [GENERAL] Subqueries or Joins? Problems with multiple table query

2010-02-23 Thread Stefan Schwarzer
Select countries.name, basel.year, basel.value, cites.year, cites.value From countries Left Join basel on basel.id_country = countries.id_country and basel.value=1 Left Join cites on cites.id_country = countries.id_country and cites.value=1 I would have thought so, but the query turns forever.

Re: [GENERAL] Subqueries or Joins? Problems with multiple table query

2010-02-23 Thread Stefan Schwarzer
Select countries.name, basel.year, basel.value, cites.year, cites.value From countries Left Join basel on basel.id_country = countries.id_country and basel.value=1 Left Join cites on cites.id_country = countries.id_country and cites.value=1 I would have thought so, but the query turns forever.

Re: [GENERAL] Subqueries or Joins? Problems with multiple table query

2010-02-23 Thread Stefan Schwarzer
You may also wish to review Andreas' suggestions as they propose a more sensible table structure rather than having a table for each convention. The table proposal really looks nice. But our database is structured by variable - so each convention has its own table. It is a really bad design -

[GENERAL] SELECT only those values of table B which have a value in table A

2010-02-25 Thread Stefan Schwarzer
Hi there, I have tables with values for each country of the world. Now, there is the possibility for the user to generate regional (Europe, Africa...) or subregional (Western Europe, Central Europe...) aggregations on-the-fly. In some cases, these aggregations need to be calculated by usin

Re: [GENERAL] SELECT only those values of table B which have a value in table A

2010-02-25 Thread Stefan Schwarzer
SELECT COALESCE(r.name, ) AS name, d.year_start AS year, SUM(d.value * d_nom.value) / SUM(d_nom.value) AS value FROM pop_total_access_water AS d RI

[GENERAL] INSERT 0 1 "problems"

2006-07-17 Thread Stefan Schwarzer
Hi there, how comes that sometimes, when I use something like this: psql name_of_my_database < inserts.sql Postgres displays INSERT 0 1 INSERT 0 1 INSERT 0 1 but sometimes it counts INSERT 48593 1 INSERT 48594 1 INSERT 48595 1 ??? Altho

[GENERAL] Replace NULL values

2006-09-06 Thread Stefan Schwarzer
; WHEN a=2 THEN 'two' ELSE 'other' END FROM test; a | case---+--- 1 | one 2 | two 3 | otherdoesn't work either, cause the titles of my columns are very varied...Thanks for any advice,Stefan Schwarzer        _______Stefan Schwarzer

Re: [GENERAL] Replace NULL values

2006-09-07 Thread Stefan Schwarzer
On Thu, Sep 07, 2006 at 07:45:19AM +0200, Stefan Schwarzer wrote: Hi there, is there a simple way to replace NULL values in multiple columns within the SQL statement? I changed the underlaying country template of your database; so now there are a couple of NULL values when I join the stats

Re: [GENERAL] Replace NULL values

2006-09-07 Thread Stefan Schwarzer
and in what circumstance? I imagine your table looks like this ID,country,1950,1951,1952,1953, 1 usa50 null 70 10 2 canada 10 45 null 4 Please mention what you would like to do with this? Stefan Schwarzer wrote: On Thu, Sep 07, 2006 at 07:45:19AM +0200, Stefan Schwarzer wrot

Re: [GENERAL] Replace NULL values

2006-09-07 Thread Stefan Schwarzer
lesce(datafield,-) as datafield,... and that will change all nulls to -9999 and give it the correct fieldname. Stefan Schwarzer wrote: I have an internet map server connected to my database. Until now, "no data" fields within the table were filled with a "-",

<    1   2