Re: longitud y tipo de datos

From: "Oscar Cano" <oscarcanorodriguez(at)gmail(dot)com>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
Cc: Postgres Español <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: longitud y tipo de datos
Date: 2007-05-24 18:33:03
Message-ID: edacf7a30705241133x344e4ad5s408fefc456dcceb2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Bueno pensandolo bien lo que quiero es saber la longitud del string, para
poder solo mandarle string de esa longitud.

Es mas me gustaria saber el tipo de dato para construir un objeto html
dependiendo del mismo,
por ej, bolean -> radio
varchar(n) -> text de tamaño n

estoy revisando

$dbh->column_info de perl (DBI), pero no lo entiendo muy bien como implementarlo
----
$sth = $dbh->column_info( $catalog, $schema, $table, $column );

# then $sth->fetchall_arrayref or $sth->fetchall_hashref etc

Returns an active statement handle that can be used to fetch information
about columns in specified tables.

The arguments $schema, $table and $column may accept search patterns
according to the database/driver, for example: $table = '%FOO%';

Note: The support for the selection criteria is driver specific. If the
driver doesn't support one or more of them then you may get back more than
you asked for and can do the filtering yourself.

If the arguments don't match any tables then you'll still get a statement
handle, it'll just return no rows.

The statement handle returned has at least the following fields in the order
shown below. Other fields, after these, may also be present.

*TABLE_CAT*: The catalog identifier. This field is NULL (undef) if not
applicable to the data source, which is often the case. This field is empty
if not applicable to the table.

*TABLE_SCHEM*: The schema identifier. This field is NULL (undef) if not
applicable to the data source, and empty if not applicable to the table.

*TABLE_NAME*: The table identifier. Note: A driver may provide column
metadata not only for base tables, but also for derived objects like
SYNONYMS etc.

*COLUMN_NAME*: The column identifier.

*DATA_TYPE*: The concise data type code.

*TYPE_NAME*: A data source dependent data type name.

*COLUMN_SIZE*: The column size. This is the maximum length in characters for
character data types, the number of digits or bits for numeric data types or
the length in the representation of temporal types. See the relevant
specifications for detailed information.

*BUFFER_LENGTH*: The length in bytes of transferred data.

*DECIMAL_DIGITS*: The total number of significant digits to the right of the
decimal point.

*NUM_PREC_RADIX*: The radix for numeric precision. The value is 10 or 2 for
numeric data types and NULL (undef) if not applicable.

*NULLABLE*: Indicates if a column can accept NULLs. The following values are
defined:
SQL_NO_NULLS 0 SQL_NULLABLE 1 SQL_NULLABLE_UNKNOWN 2

*REMARKS*: A description of the column.

*COLUMN_DEF*: The default value of the column.

*SQL_DATA_TYPE*: The SQL data type.

*SQL_DATETIME_SUB*: The subtype code for datetime and interval data types.

*CHAR_OCTET_LENGTH*: The maximum length in bytes of a character or binary
data type column.

*ORDINAL_POSITION*: The column sequence number (starting with 1).

*IS_NULLABLE*: Indicates if the column can accept NULLs. Possible values
are: 'NO', 'YES' and ''.

----

El día 24/05/07, Alvaro Herrera <alvherre(at)commandprompt(dot)com> escribió:
>
> Oscar Cano escribió:
> > Como puedo hacer para que independientemente de la longitud del string
> el
> > campo en postgres solo me tome el de la longitud en que esta definido,
> > por ejemplo
> > c1 varchar(5)
> >
> > update tabla set c1='123456789'
> >
> > solo me tome los primeros 5 caracteres
>
> En otras palabras, como hacer que el UPDATE pierda datos silenciosamente
> sin avisarte? Me parece una mala idea ya desde el planteamiento. ¿Hay
> algun motivo para desear este comportamiento?
>
> --
> Alvaro Herrera
> http://www.PlanetPostgreSQL.org/
> "Cuando no hay humildad las personas se degradan" (A. Christie)
>

--
Oscar Cano Rodríguez
PLD Consultores

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alvaro Herrera 2007-05-24 20:04:12 Re: Ayuda con Explain de consulta
Previous Message Alvaro Herrera 2007-05-24 18:18:25 Re: longitud y tipo de datos