postgresql

Pass a CSV parameter in Postgres

I want to store test results in the form of a .CSV file into a central database. The DB has a schema that does not match the CSV file. Ideally, I would just pass the contents of the CSV file as a string directly to the server and have a function that can transform the CSV into a table that can be joined and used in an INSERT. Here's a...

OPENXML in Postgres

SQLServer has a very useful function called OPENXML. It works is used like this: DECLARE @idoc int DECLARE @doc varchar(1000) SET @doc =' <ROOT> <Customer CustomerID="VINET" ContactName="Paul Henriot"> <Order CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00"> <OrderDetail OrderID="10248" ProductID="11" Quantity...

SQL Rights Creator/Owner

Our software has data to store, so it also install MYSQL, a root user and a user with read only access if a third party compagny wants to install a backup solution for our data. But the third party wants to write data (a timestamp for backup purpose or something like that...) to another database. How can I change the user so it has read ...

How can I get a list of all functions stored in the database of a particular schema in PostgreSQL?

I want to be able to connect to a PostgreSQL database and find all of the functions for a particular schema. My thought was that I could make some query to pg_catalog or information_schema and get a list of all functions, but I can't figure out where the names and parameters are stored. I'm looking for a query that will give me the func...

Postgres error on insert - ERROR: invalid byte sequence for encoding "UTF8": 0x00

I get the following error when inserting data from mysql into postgres. Do I have to manually remove all null characters from my input data? Is there a way to get postgres to do this for me? ERROR: invalid byte sequence for encoding "UTF8": 0x00 ...

Modify OWNER on all tables simultaneously in Postgresql

How do I modify all tables in a Postgres database to change the owner? I tried ALTER TABLE * OWNER TO new_owner but it doesn't like the star. ...

How to drop a table in PostgreSQL which includes double quotes in its name

I accidentaly created a table in PostgreSQL which contains, in its name, some double quotes. I used SQL Server 2000 DTS to import data from it to my PostgreSQL server, but while importing, it created the table but with double quotes in it. Actually the table name when I do SELECT * FROM pg_tables is : public","t_freemailer So, when I t...

Problems with $libdir on PostgreSQL

In short, my question is "why doesn't $libdir work on my PSQL installation." CREATE FUNCTION st_box2d_in(cstring) RETURNS box2d AS '$libdir/liblwgeom', 'BOX2DFLOAT4_in' LANGUAGE c IMMUTABLE STRICT; yields an error could not access file "$libdir/liblwgeom": No such file or directory while CREATE FUNCTION st_box2d_in(cstri...

Checking return value of pg_query_params by PHP

How can you check if a resource is false in PHP`s pg query params? I run the following code unsuccessfully $row = pg_num_rows ( $result ); if ( $row !== 0 ) echo "hurray"; else echo "argh"; It gives me the following warnings Warning: pg_query_params() [function.pg-query-params]: Query failed: ERROR: invalid input ...

' or " in PHP's Postgres queries

When should you use the character ' in PHP pg queries? When should you use the character " in PHP pg queries? This question is based on this answer. ...

Restlet implementing post with json receive and response

First, what i wanted to know is what i am doing is the right way to do it. I have a scenario where i have will receive a json request and i have to update the database with that, once the db is updated i have to respond back with the json acknowledgment. What i have done so far is create the class extending application as follows: ...

What's the easiest way to call Postgres from a MinGW program?

All I need is get MinGW talking to Postgres. I've considered several options: Use libpq. The libpq.lib that comes with Postgres for Windows links okay, but crashes when I use the library. I think because it was compiled for VC++. I can't find just the libpq code, so I'd have to recompile the entire Postgres tree in MinGW. Not easy...

Seam 2.2GA + JBoss AS 5.1GA + Postgres 8.4

Hello Stackoverflow Users, Sorry for the big wall of text, but its mostly logs Thx for any help in any of my problems I've been trying to get help from Seam forums, but in vain. I'm trying this Setup mentioned in the title, but unsuccessfully. I have it all installed correctly and the problems start with the seam-gen. This is my bu...

Postgres: fast debugging like in Git?

I am looking for similar commands in Postgres as in Git. The reason is that my debugging is slow in Postges, due to my inability to clone and do things like in Git. How can I clone a db, like a branch? How can I create a new "branch"? Is there some Git mode for Postgres? How do you deal with errors in Postgres? Do you clone the db, o...

Postgres: problem with FK contraint

How can I solve FK contraint? With trigger or something else? #IF "DELETE FROM human where name='a';", error due to the FK contraist. # If the error, I want in the order: # FIRSTLY. DELETE FROM address where name='a'; # SECONDLY. DELETE FROM human where name='a'; DROP TABLE human; DROP TABLE address; CREATE TABLE human( name...

Is there a way to list PostgreSQL servers?

Hi, Currently I am writing client to PostgreSQL servers. I want to list the details (ip address and port number) of the servers that is running PostgreSQL servers in the local network. Is there some methods in libpq or libpqxx ? Regards Devara Gudda ...

Does a Foreign Key referencing PK need the NOT NULL constraint?

Does a Foreign Key referencing a Primary Key need the NOT NULL constraint in a PostgreSQL database? The database is highly normalized and will be very large. I do not wish to add extra constraints that will slow down the queries even more if said queries are unneeded. ...

Can't link libpqxx in MinGW

Using MSYS, I compiled libpq (from compiling postgres). I then compiled libpqxx. Now, I want to create a client that will use libpqxx. libpq seemed to work fine. And, I can compile code with libpqxx. However, linking the libpq client application fails. Here's my code: #include <pqxx/pqxx> #include <iostream> using namespace std; ...

How to sort sql result using a pre defined series of rows

i have a table like this one: -------------------------------- id | name -------------------------------- 1 | aa 2 | aa 3 | aa 4 | aa 5 | bb 6 | bb ... one million more ... and i like to obtain an arbitrary number of rows in a pre defined sequence and the other rows ordered by their name. e.g. in another table i have a short seq...

Calculating and DB Design for getting an average

I'm trying to wrap my head around the proper design to calculate an average for multiple items, in my case beers. Users of the website can review various beers and all beers are given a rating (avg of all reviews for that beer) based on those reviews. Each beer review has 5 criteria that it's rated on, and those criteria are weighted a...