postgresql

Drop primary key index

Can I drop primary key index without dropping primary key constraint in postgresql? ...

Database frontend for multiple db engines

Hey Stackoverflow, Yeah it's spring and a lot of things happens to me... Also changing some software things at my computer, because suddenly everything seems to be boring after starting my laptop. I even changed my wallpaper!!! Besides I'm looking for a new database frontend and after using google with several queries I didn't find t...

How can I access a postgresql database from matlab with without matlabs database toolbox?

I tried already to use pgmex. Unfortunately it doesn't work with libpq5 (matlab immediately crashes). ...

How to create a sql function using temp sequences and a SELECT on PostgreSQL8

Hello there, I have this issue in either postgreSQL 8.3 or 8.4: I've created a script which (re)creates three temp sequences and then uses them to transpose some tables in order to get a single row. Now I want to put it in a FUNCTION which returns a type already created (I've done a select into and then I took the fields from the creat...

Adding Table Columns to a Group by clause - Ruby on Rails - Postgresql

I am trying to use Heroku and apparently Postgresql is a lot more strict than SQL for aggregate functions. When I am pushing to Heroku I am getting an error stating the below. On another question I asked I received some guidance that said I should just add the columns to my group by clause and I am not sure how to do that. See the full...

PostgreSQL custom exceptions?

In Firebird we can declare custom exceptions like so: CREATE EXCEPTION EXP_CUSTOM_0 'Exception: Custom exception'; these are stored at the database level. In stored procedures, we can raise the exception like so: EXCEPTION EXP_CUSTOM_0 ; Is there an equivalent in PostgreSQL ? ...

Why Banks or Financial Companies prefer Oracle than other RDBMS for their "Core" systems?

I'd like to know why most Banks or Financial companies prefer Oracle than other RDBMS for their core systems (the absolutely minimum features that a Bank must support). I found a few answers that didn't satisfy me. For example: Oracle has more features. But features for what? Can't you implement that in application level if you were not ...

Can I get psycopg2 to work on Windows with a python built with vc9?

I have a question similar to http://stackoverflow.com/questions/1306367/python-importerror-dll-load-failed-when-trying-to-import-psycopg2-library I'm trying to run psycopg2 with Python 2.6.5, built with Visual Studio 2008 (vc9). I get this error: from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID ImportError: DLL load fail...

ROR heroku PostGres issue

getting error: ActiveRecord::StatementInvalid (PGError: ERROR: argument of HAVING must be type boolean, not type timestamp without time zone controller code snippet: def inactive @number_days = params[:days].to_i || 90 @clients = Client.find(:all, :include => :appointments, :conditions => ["clients.user_id = ? A...

PostgreSQL compare databases tool or generating migration script util

In our development we use two servers with PostgreSQL 8.4 - development and production. So, after changes were made on development server we would like to automatically generate SQL migration scripts. I found that EMS DB Comparer for PostgreSQL can do it, but it is only for Windows (our development team use Ubuntu for developing). Do you...

How can I calculate data for a boxplot (quartiles, median) in a Rails app on Heroku? (Heroku uses Postgresql)

I'm trying to calculate the data needed to generate a box plot which means I need to figure out the 1st and 3rd Quartiles along with the median. I have found some solutions for doing it in Postgresql however they seem to depend on either PL/Python or PL/R which it seems like Heroku does not have either enabled for their postgresql datab...

Reporting tools for postresql

Could you recommend a reporting solution for postgresql/django which is: fairly flexible and easy-to use can be deployed online is free/opensource [optional] output format is HTML/CSV(optional) users can create new reports (via SQL) if it can utilise underlying django's models that'd be great ...

Query that ignore the spaces.

What's the best way to run a query so that spaces in the fields are ignored? For example the following queries.... SELECT * FROM mytable WHERE username = "JohnBobJones" SELECT * FROM mytable WHERE username = "John Bob Jones" . would find the following entries: John Bob Jones JohnBob Jones JohnBobJones . I am using php or python...

Updating ResultSets with SQL Array types in JDBC / PostgreSQL

I'm trying to use a SQL Array type with PostgreSQL 8.4 and the JDBC4 driver. My column is defined as follows: nicknames CHARACTER VARYING(255)[] NOT NULL and I'm trying to update it thusly: row.updateArray("nicknames", connection.createArrayOf("CHARACTER VARYING", p.getNicknames().toArray())); (p.getNicknames() r...

Some problem with postgres_psycopg2

Last night I upgraded my machine to Ubuntu 10.04 from 9.10. It seems to have cluttered my python module. Whenever I run python manage.py I get this error: ImportError: No module named postgresql_psycopg2.base Can any one throw any light on this? ...

Fast find near users using PostGIS

I have 5 tables: - users - information about user with current location_id (fk to geo_location_data) - geo_location_data - information about location, with PostGIS geography(POINT, 4326) column - user_friends - relationships between users. I want to find near friends for current user, but it takes a lot of time of executing select que...

How to uninstall postgresql on my Mac (running Snow Leopard)

Upgraded 10.6 from 10.5 and now postgres 8.1 is whacked. To make things worse I tried installing 8.4 which I'm pretty sure just made things ten times worse. Anyhow, the exception I'm getting when I try to fire postgres up and just createuser is this: createuser: could not connect to database postgres: could not connect to serve...

Porting Oracle Date Manipulation

I need to port this following from Oracle syntax to Postgresql. Both FLO_END_DT and FLO_START_DATE are of type DATE in Oracle, and TIMESTAMP WITHOUT TIME ZONE in Postgresql: SELECT TRUNC( TO_CHAR(ROUND(( FL.FLO_END_DT- FL.FLO_START_DT)* 24), '9999D99'), 2) FROM FLOWS FL I am not familiar enough with Oracle to know what it is tryin...

Sending one record from cursor to another function Postgres

FYI: I am completely new to using cursors... So I have one function that is a cursor: CREATE FUNCTION get_all_product_promos(refcursor, cursor_object_id integer) RETURNS refcursor AS ' BEGIN OPEN $1 FOR SELECT * FROM promos prom1 JOIN promo_objects ON (prom1.promo_id = promo_objects.promotion_id) ...

How to resolve this PostgreSQL error on OS 10.6 (Snow Leopard)

I followed the instructions for setting up postgresql from this site All seems to go fine until I try: createuser --superuser myname -U postgres I get the following exception: createuser: could not connect to database postgres: could not connect to server: No such file or directory Is the server running locally and ...