[R] Passing bigint (8-byte) values from Postgres to R using RPostgreSQL

psql2555 postgresql.10.miller_2555 at spamgourmet.com
Fri Nov 28 09:15:20 CET 2008

Hi - 

I have a simple R script that inserts values into a Postgres table to
generate a record that autogenerates a bigint unique ID (basically, a
customized bigserial value). When I query the table to retrieve the bigint
value, the value returned is not the same as the value created in the
database (as evidenced by a direct query of the database table via pgAdmin). 

e.g. the value created should be an 8-byte integer (specifically
2007111600000100000). However, the value returned in R is different
(specifically 2007111600000100096). For every bigint value, the value
returned is the value generated by the database + 96. 

An example of the code to obtain the value from the database is as follows:
PgSQLdrv <- dbDriver("PostgreSQL")
con <-
rs <- dbSendQuery(con,statement = paste('SELECT "UID" FROM "mytable"  LIMIT
val <- fetch(rs,n = -1)
How may I correct the error? Is this an endian issue with the Windows

    Postgres v8.3.5
    R v2.8.0 
    RPostgreSQL v0.1-2
    Windows XP SP2

Thanks -
View this message in context: http://www.nabble.com/Passing-bigint-%288-byte%29-values-from-Postgres-to-R-using-RPostgreSQL-tp20730401p20730401.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list