Skip site navigation (1) Skip section navigation (2)

Re: Convertion of date/time binary format to text format

From: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
To: "Mavinakuli, Prasanna (STSD)" <prasanna(dot)b-m(at)hp(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Convertion of date/time binary format to text format
Date: 2006-01-02 14:49:15
Message-ID: 20060102144915.GA589@alamut (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
On Jan 02 09:26, Mavinakuli, Prasanna (STSD) wrote:
> Could u give me one more favour..
> That is can u please elobarate on bytea order conversion...?

You can find lots of information about "byte order coersion" on the
internet. I'd suggest reading these links:

But for a "quick & dirty" answer:

 o. You don't have to make any byte order coersion on types smaller
    than 0xFF = 256 bytes - like char.

 o. You _should_ make byte order coersion on types bigger than
    256 bytes - like int. From PostgreSQL documentation's

	char *iptr;
	int   ival;

    iptr = PQgetvalue(res, i, i_fnum);

     * The binary representation of INT4 is in network byte order,
     * which we'd better coerce to the local byte order.
    ival = ntohl(*((uint32_t *) iptr));
    Otherwise, you'll encounter different results in data transfers
    on different architectures with different endianness.


pgsql-interfaces by date

Next:From: JiangWeiDate: 2006-01-06 01:16:31
Subject: HOWTO pass "default value" to PQexecParams ?
Previous:From: Tom LaneDate: 2005-12-30 23:52:15
Subject: Re: PQfformat() and Composite Formatted Results

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group