Re: [SQL] question

2005-08-30 Thread Halley Pacheco de Oliveira
In PHP I use this code with a prepared statement to insert null in the field justif_emenda when the value in the form is an empty string or a string with only spaces. I hope this will help you. $sql = "INSERT INTO tbl_emenda (" . "id_emenda, subtipo_emenda, tipo_emenda, " . "nome_autor

Re: [SQL] SQL CASE Statements

2005-08-22 Thread Halley Pacheco de Oliveira
Dear Lane, is that what you want? CREATE TABLE network_nodes ( node_id SERIAL PRIMARY KEY, node_name VARCHAR, default_gateway_interface_id INTEGER ); CREATE TABLE router_interfaces ( interface_id SERIAL PRIMARY KEY, node_id INT REFERENCES network_nodes ); CREATE VIEW current

Re: [SQL] SQL CASE Statements

2005-08-20 Thread Halley Pacheco de Oliveira
> Has anybody done this? If so, can you send me a sample? CREATE TEMPORARY TABLE fruits (id SERIAL, name TEXT); INSERT INTO fruits VALUES (DEFAULT, 'banana'); INSERT INTO fruits VALUES (DEFAULT, 'apple'); CREATE TEMPORARY TABLE food (id SERIAL, name TEXT); INSERT INTO food VALUES (DEFAULT, 'apple'

Re: [SQL] [despammed] converting varchar to integer

2005-08-18 Thread Halley Pacheco de Oliveira
A function to check for valid integers: CREATE OR REPLACE FUNCTION retInt(VARCHAR) RETURNS integer AS ' DECLARE number ALIAS FOR $1; i INTEGER := 1; BEGIN IF ((number IS NULL) OR (number = )) THEN RETURN NULL; END IF; WHILE (i <= length(number)) LOOP IF ((subs

Re: [SQL] converting varchar to integer

2005-08-17 Thread Halley Pacheco de Oliveira
Using CASE to avoid '': CREATE TABLE test (number TEXT); INSERT INTO test VALUES('123'); INSERT INTO test VALUES('a123b'); INSERT INTO test VALUES(''); teste=> SELECT CASE number WHEN '' THEN NULL ELSE to_number(number,'990') END AS number FROM test;; number 123 123

Re: [SQL] Postgres for Fedora Core 2 OS ****************

2005-07-19 Thread Halley Pacheco de Oliveira
There is the postgresql-8.0.3-1.i386.rpm for Fedora Core 4 in http://ftp.idilis.ro/mirrors/fedora/core/4/i386/os/Fedora/RPMS/ and others mirrors. I don't know if it works with Fedora Core 2. Probably not. For Fedora Core 3 there is the postgresql-7.4.6-1.FC3.1.i386.rpm in http://ftp.idilis.ro/m