Re: Una Consulta sobre valores por defecto en una tabla

From: "Fernando Aguada" <fernandoaguada(at)yahoo(dot)com(dot)ar>
To: "Manuel Sugawara" <masm(at)fciencias(dot)unam(dot)mx>
Cc: <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Una Consulta sobre valores por defecto en una tabla
Date: 2005-04-21 18:50:05
Message-ID: 004c01c546a2$f0a700d0$0400a8c0@fernandoa
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola Manuel,
Ahi va la definicion de la tabla, el campo en cuestion es el que se llama
CDEST,

CREATE TABLE chequest
(
ciden serial NOT NULL,
cfece date NOT NULL DEFAULT '1900-01-01'::date,
cfecc date NOT NULL DEFAULT '1900-01-01'::date,
cfecb date NOT NULL DEFAULT '1900-01-01'::date,
ctipc int2 NOT NULL DEFAULT 0,
ccuen int4 NOT NULL DEFAULT 0,
cbanc int2 NOT NULL DEFAULT 0,
csucu int2 NOT NULL DEFAULT 0,
cnuch varchar(12) NOT NULL DEFAULT ''::character varying,
ccuch varchar(15) NOT NULL DEFAULT ''::character varying,
cimpo numeric(12,2) NOT NULL DEFAULT 0,
cdest varchar(40) NOT NULL DEFAULT ''::character varying,
cpren int2 NOT NULL DEFAULT 0,
cmodo int2 NOT NULL DEFAULT 0,
cnumtra int4 NOT NULL DEFAULT 0,
cori varchar(1) NOT NULL DEFAULT ''::character varying,
ctraven int4 NOT NULL DEFAULT 0,
ctracom int4 NOT NULL DEFAULT 0
)
WITHOUT OIDS;
ALTER TABLE chequest OWNER TO postgres;
GRANT ALL ON TABLE chequest TO postgres;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE chequest TO GROUP operadores;

----- Original Message -----
From: "Manuel Sugawara" <masm(at)fciencias(dot)unam(dot)mx>
To: "Fernando Aguada" <fernandoaguada(at)yahoo(dot)com(dot)ar>
Cc: <pgsql-es-ayuda(at)postgresql(dot)org>
Sent: Thursday, April 21, 2005 11:26 AM
Subject: Re: [pgsql-es-ayuda] Una Consulta sobre valores por defecto en una
tabla

"Fernando Aguada" <fernandoaguada(at)yahoo(dot)com(dot)ar> writes:

> En una tabla tengo un campo definido como varchar (30) no nulo y con
> valor por defecto='' ahora cuando hago un select * from tabla where
> campo varchar='' y el campo esta vacio, no me trae nada, y deberia
> traermelo, pues el campo no tiene nada. Existe alguna funcion que
> devuelva si esta vacio un campo? o como lo puedo averiguar? Si
> alquien sabe, se lo agradecere mucho, saludos y gracias de antemano.

Creo que tendrás que darnos más detalles (como la definción de la
tabla como lo muestra psql con \d). Aqui todo funciona de maravilla:

test=# create table foo (foo varchar(30), bar int);
CREATE TABLE
test=# insert into foo values ('', 1);
INSERT 25519380 1
test=# insert into foo values ('', 2);
INSERT 25519381 1
test=# insert into foo values ('Hola', 3);
INSERT 25519382 1
test=# select * from foo where foo = '';
foo | bar
-----+-----
| 1
| 2
(2 filas)

test=#

Saludos,
Manuel.

---------------------------(fin del mensaje)---------------------------
TIP 10: visita nuestro canal de IRC #postgresql-es en irc.freenode.net

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alvaro Herrera 2005-04-21 19:34:27 Re: [Fwd: [usr] Driver de postgres que no va]
Previous Message Cristofer N. Reyes A. 2005-04-21 18:33:30 Particion NTFS postgre 8.0