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

From: psql2555 <postgresql.10.miller_2555_at_spamgourmet.com>
Date: Fri, 28 Nov 2008 00:15:20 -0800 (PST)

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 <-
dbConnect(PgSQLdrv,host="localhost",dbname="MyDB",user="user",password="password",port=5432) rs <- dbSendQuery(con,statement = paste('SELECT "UID" FROM "mytable" LIMIT 1',sep='',collapse=''))
val <- fetch(rs,n = -1)

How may I correct the error? Is this an endian issue with the Windows driver?


    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.

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 28 Nov 2008 - 08:28:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 28 Nov 2008 - 10:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive