postgresql

Possible to perform cross-database queries with postgres?

I'm going to guess that the answer is no based on the below error message (and this Google result), but is there anyway to perform a cross-database query using Postgres? databaseA=# select * from databaseB.public.someTableName; ERROR: cross-database references are not implemented: "databaseB.public.someTableName" I'm working with so...

C# .NET + PostgreSQL

I'm looking at working on a project which uses C#.NET (sitting on a windows box) as the primary language and PostgreSQL as the backend database (backend is sitting on a linux box). I've heard that ODBC.NET allows for easy integration of these two components. Has anyone had experience actually setting C# and PostgreSQL up to work toge...

What does it mean when a PostgreSQL process is "idle in transaction"?

What does it mean when a PostgreSQL process is "idle in transaction"? On a server that I'm looking at, the output of "ps ax | grep postgres" I see 9 PostgreSQL processes that look like the following: postgres: user db 127.0.0.1(55658) idle in transaction Does this mean that some of the processes are hung, waiting for a transaction to...

Is it possible to make a recursive SQL query ?

I have a table similar to this: CREATE TABLE example ( id integer primary key, name char(200), parentid integer, value integer); I can use the parentid field to arrange data into a tree structure. Now here's the bit I can't work out. Given a parentid, is it possible to write an SQL statement to add up all the value fields und...

How do I (or can I) SELECT DISTINCT on multiple columns (postgresql)?

I need to retrieve all rows from a table where 2 columns combined are all different. So I want all the sales that do not have any other sales that happened on the same day for the same price. The sales that are unique based on day and price will get updated to an active status. So I'm thinking: UPDATE sales SET status = 'ACTIVE' WHER...

Storing Images in PostgreSQL

Alright, so I'm working on an application which will use a Linux back-end running PostgreSQL to serve up images to a Windows box with the front end written in C#.NET, though the front-end should hardly matter. My question is: What is the best way to deal with storing images in Postgres? The images are around 4-6 megapixels each, and...

What is a prepared statement?

I see a bunch of lines in the .log files in the postgres pg_log directory that say something like: ERROR: prepared statement "pdo_pgsql_stmt_09e097f4" does not exist What are prepared statements, and what kinds of things can cause these error messages to be displayed? ...

mysql_insert_id alternative for postgresql

is there an alternative for mysql_insert_id() php function for PostgreSQL? Most of the frameworks are solving the problem partially by finding the current value of the sequence used in the ID. However, there are times that the primary key is not a serial column.... ...

performing datetime related operations in PHP

how do you actually perform datetime operations such as adding date, finding difference, find out how many days excluding weekends in an interval? i personally started to pass some of these operations to my postgresql dbms as typically i would only need to issue one sql statement to obtain an answer, however, to do it in PHP way I would ...

How to connect to PostgreSQL from .NET using TLS with both client and server authentication?

I want to connect a C# .NET application to a PostgreSQL database, using TLS with client and server authentication: in other words, if the certificate from the client can not be verified against the certificate of the server, the client should get access denied, and if the client can not verify the certificate of the server, the client sh...

In what order are ON DELETE CASCADE constraints processed?

Here is an example of what I've got going on: CREATE TABLE Parent (id BIGINT NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB; CREATE TABLE Child (id BIGINT NOT NULL, parentid BIGINT NOT NULL, PRIMARY KEY (id), KEY (parentid), CONSTRAINT fk_parent FOREIGN KEY (parentid) REFERENCES Parent (id) ON DELETE CASCADE) ENGINE=InnoDB; CREAT...

If possible how can one embed PostGreSQL?

If it's possible, I'm interested in being able to embed a PostGreSQL database, similar to sqllite. I've read that it's not possible. I'm no database expert though, so I want to hear from you. Essentially I want PostGreSQL without all the configuration and installation. If it's possible, tell me how. ...

Installing PDO-drivers for PostgreSQL on Mac (using Zend for eclipse)

How can I get PDO to work on my mac (os x 10.5)? I'm using the built in php and php in Zend/Eclipse. Can't seem to find useful drivers for it at all. ...

PostgreSQL DbLink Compilation on Solaris 10

After successfully building dblink on solaris 10 using Sun C 5.9 SunOS_sparc 2007/05/03 and gmake. I ran gmake installcheck and got the following output: ========== running regression test queries ========== test dblink ... FAILED ====================== 1 of 1 tests failed. The differences that caused some test...

Good ORM for C++ solutions?

Does anyone have a good recommendation for an ORM (Object Relational Mapper) for C++? Our technology stack is: IDE/C-Compiler = Borland C++ Builder so ideally something that is known to compile with BCC. We use PostgreSQL as our database and developed our own database abstraction layer using common API to many driver type interface. S...

PostgreSQL 8.3 privileges not updated - wrong usage?

Hi, I'm having trouble granting privileges to another user in PostgreSQL 8.3. While the GRANT command gives me no error, the privileges do not show up. Do I need to "flush" them? sirprize=# CREATE DATABASE testdb; CREATE DATABASE sirprize=# GRANT ALL PRIVILEGES ON DATABASE testdb TO testuser; GRANT sirprize=# \c testdb You are now conne...

Postgres replication

Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as a data storage to RoR/Python LAMP-like application. What kind tools are there that are simple and robust enough for replication of the main database to a second machine? I looked through some packages (Slony-I and etc.) but it would be great to hear real-life sto...

Trip time calculation in relational databases?

I had this question in mind and since I just discovered this site I decided to post it here. Let's say I have a table with a timestamp and a state for a given "object" (generic meaning, not OOP object); is there an optimal way to calculate the time between a state and the next occurrence of another (or same) state (what I call a "trip")...

hibernate insert batch with postgresql

is there a solution for batch insert via hibernate in partitioned postgresql table? currently i'm getting an error like this... 57286 [pool-1-thread-18] ERROR org.hibernate.jdbc.AbstractBatcher - Exception executing batch: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0...

What is the equivalent of Oracle's REF CURSOR in Postgresql when using JDBC?

In Oracle I can declare a reference cursor... TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE; ...and use it to pass a cursor as the return value... FUNCTION end_spool RETURN t_spool AS v_spool t_spool; BEGIN COMMIT; OPEN v_spool FOR SELECT * FROM ...