postgresql

How to reuse sql query result in PHP?

I'd like to do different operations on the data returned from a single sql query, something like this: $sql = "SELECT * FROM mandant"; $res = pg_query($_db,$sql); while ($mandant_list = pg_fetch_object($res)) { # do stuff } while ($mandant = pg_fetch_object($res)) { # do other stuff } But this doesn't work. The fir...

Function in Postgres to convert a varchar to a big integer

I have a varchar column in Postgres 8.3 that holds values like: '0100011101111000' I need a function that would consider that string to be a number in base 2 and spits out the numeric in base 10. Makes sense? So, for instance: '000001' -> 1.0 '000010' -> 2.0 '000011' -> 3.0 Thanks! ...

dynamic column formatting in sql - and a backend to store the formatting

Hi all, I'm trying to create a system in Python in which one can select a number of rows from a set of tables, which are to be formatted in a user-defined way. Let's say the table a has a set of columns, some of which include a date or timestamp value. The user-defined format for each column should be stored in another table, and querie...

Slow Postgres Query

I'm new to Postgres and SQL. I created the following script that draws a line from a point to a projected point on the nearest line. It works fine on a small data set 5 to 10 points with the same number of lines; however, doing it on 60 points with 2,000 lines, the query takes about 12 hours. it is based on a nearest neighbour function p...

Log usage of database tables in PostgreSQL

Possible Duplicate: How do I find the last time that a PostgreSQL database has been updated? I need to be able to determine when the last time a database table was modified. I have seen the usage of sys.dm_db_index_usage_stats and last_user_update but this is not available in PostgreSQL. Is there similar functionality in Postgre...

Detecting errors to decide whether to rollback or commit

I'm trying to be as lazy as possible by generating a series of SQL commands in a file to feed to psql for processing. In a nutshell, I'm loading a series of import tables from outside sources (already done, via COPY), and then in a final step, deleting/updating/inserting records into the primary tables (which is functionally also done). ...

How to configure query timeout threshhold for c3p0/hibernate

I have an application that is using Hibernate 3, c3p0, and spring 2.5.6. We have a datasource that is configured to speak with a postgres database. Everything was working great until a firewall was introduced between the application server and the database. We intermittently are getting java.net.SocketTimeoutException: Read Timed Out err...

Alternate location for PostgreSQL configuration files

In the documentation for postgresql.conf, it implies that they envisage a scenario where one might want to store the configuration files in a non-default location (i.e. not inside the data directory). This is done by passing the location of the config files when starting up the server as postgres -D /path/to/config/directory, and having...

save (postgre) sql output to csv file

hi there, what is the easiest way to save PL/pgSQL output from a PostgreSQL database to a csv file? I'm using PostgreSQL 8.4 with pgAdmin III and psql plugin where I run queries from... thanks! martin ...

PostgreSQL and Sequential Data

I have a dataset that contains: Table { date itemName } The date for the most part is sequential. There are no duplicates of the date [as it is the primary key]. The question is split up into multiple parts (all with respect to using SQL): Is it possible to find gaps in the date series listed in the table? For example: Dates 1/2/09...

PostgreSQL TDE support

Does PostgreSQL support Transparent Data Encryption (TDE)? We are planning to use PostgreSQL for our remote clients, but are worried that the data files can be copied and a new instance of the database can be recreated on an unauthorized machine. TDE solves this problem. But we're not sure if PostgreSQL supports TDE -- does it? ...

Deadlock error in INSERT statement

We've got a web-based application. There is a time-bound database operation (INSERTs and UPDATEs) in the application which takes more time to complete, hence this particular flow has been changed into Java Thread so it will not wait (block) for the complete database operation to be completed. My problem is, if more than 1 user come a...

How to limit the effect of client modifications to production systems

Our shop has developed a few WEB/SMS/DB solution for a dozen client installations. The applications have some real-time performance requirements, and are just good enough to function properly. The problem is that the clients (owners of the production servers) are using the same server/database for customizations that are causing problems...

Is it possible to get a history of queries made in postgres

Is it possible to get a history of queries made in postgres? and is it be possible to get the time it took for each query? I'm currently trying to identify slow queries in the application I'm working on. I'm using Postgres 8.3.5 ...

How to cancel a postgres query in java/JDBC

How do I cancel a long running postgres query via JDBC or Java? The usecase would be that an user starts a query on a postgres database via a front end, but then he decides otherwise and wants to abort/cancel the currently running query. ...

PostgreSql + C#:Design Time Support in VS2008

I've installed Npgsql Data Provider for .net and I've executed gacutil -i Npgsql.dll as the user manual said, but I can't use the Dataset designer. When I add a TableAdapter to the designer, It ask me for a new connection, but the options are Access, MS Sql, or SQLite (other dataProviders that already i have installed). There's no op...

Data Warehousing Postgres

We're considering using SSIS to maintain a PostgreSql data warehouse. I've used it before between SQL Servers with no problems, but am having a lot of difficulty getting it to play nicely with Postgres. I’m using the evaluation version of the OLEDB PGNP data provider (tiny.cc/qLoS2). I wanted to start with something simple like UPSERT o...

Using Postgres with Grails

Has anyone gotten Grails working with Postgres? I have used this tutorial and everything seems to make sense and be correct to me. However when I 'grails run-app' I get this error Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://10.0.0.21/tribes' java.sql.SQLException: No suitable driver My D...

PostgreSQL UTF8 Handling

From time time to time my PostgreSQL DB is reporting a strange error: [client] postgres7 error: [-1: ERROR: invalid byte sequence for encoding \"UTF8\": 0xb4 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by \"client_encoding\".] in adodb_throw(INSERT INT...

CodeIgniter and PostgreSQL - Retrieving data from Function returning refcursor

I have a PostgreSQL function that selects data and returns it via a refcursor, similar to the following declaration: CREATE OR REPLACE FUNCTION my_function() RETURNS refcursor AS ... How do I retrieve data from this function via a CodeIgniter model? I can't just SELECT directly from the function as it does not return the data dire...