Re: [SQL] CHECK constraint removing brackets

2010-01-11 Thread Andy Shellam
Hi Tom and Scott, > > I think your real problem is that you're trying to use "= NULL" and > "!= NULL" where you should say IS NULL or IS NOT NULL. Argh such a school-boy error! This is the first bit of database programming I've done for about 2 months, and I hadn't switched my C++ brain off.

[SQL] CHECK constraint removing brackets

2010-01-11 Thread Andy Shellam
Hi, I notice this had been raised as a bug (and subsequently over-ruled) so I'm asking how I can achieve the following business rule. I have an order table which has an invoice_id column that links to an invoice table (an order can only have 1 invoice, but one invoice can have multiple orders.

Re: [SQL] PHP pg_escape_string

2009-06-15 Thread Andy Shellam
Hi, Zdravko Balorda wrote: there are both pg_(un)escape_bytea() functions but only one pg_escape_string()... I wonder if I may be missing something here? Yeah, I think you are. pg_escape_string (funnily enough) escapes string data which is then stored in the database. You would use this for

Re: [SQL] drop PW

2009-06-13 Thread Andy Shellam
Mark, As Joshua said, you can modify pg_hba.conf. What's happening is PostgreSQL is configured to require a password for the IP address that user is connecting from, but you're not supplying one. Set that user and the IP address they connect from to "trust" security in pg_hba.conf and bounc

Re: [SQL] Obtaining a limited number of records from a long query

2009-05-25 Thread Andy Shellam
Hi Oliveiros Certainly! What you're looking for is the LIMIT...OFFSET syntax. Some examples: SELECT ... LIMIT 10 - return the first 10 records only. SELECT ... LIMIT 10 OFFSET 10 - return 10 records, starting with record 11. Manual page: http://www.postgresql.org/docs/8.3/interactive/queries

Re: [SQL] Storing null bytes in bytea

2009-04-28 Thread Andy Shellam
Hi Tom, Your example works fine in psql: regression=# create table t1 (f1 bytea); CREATE TABLE regression=# insert into t1 values (E'IsLoggedIn|b:1;CurrentUser|O:17:"Class_SystemUser":4:{s:26:"\\000Class_SystemUser}'::bytea); INSERT 0 1 regression=# select * from t1;

[SQL] Storing null bytes in bytea

2009-04-27 Thread Andy Shellam
Hi all, I was going to post this on the pgsql-php list but I think the issue is more on the PostgreSQL side of things. I'm using PHP 5.2.9 connected to a PostgreSQL 8.3.7 server running on Solaris 10 to try to store the session data for an application using a custom session handler class. T