From: Guy Deleeuw <G.De_Leeuw@eurofer.be>
To: pgsql-admin@postgresql.org
Subject: C trigger problem : conversion of CString to Datum
Date: Sat, 20 Feb 2010 16:05:16 +0100
Message-ID: <4B7FFA2C.3030001@eurofer.be> (raw)
Hello,
I cannot convert properly a cstring to a Datum :
Here my code :
int attColNumber;
Datum new_barcode;
bool isnull = 0;
char barcode[14];
elog(INFO, "gd_trigfunc_before_article_insert() : bar_code = %s",
barcode);
attColNumber = COL_BARCODE;
new_barcode = CStringGetDatum(barcode);
workTuple = SPI_modifytuple(trigdata->tg_relation,
trigdata->tg_trigtuple, 1, &attColNumber, &new_barcode, &isnull);
the result :
# INSERT INTO t_articles VALUES (4001, 1, '065', 'White', NULL, 'XS', null);
INFO: gd_trigfunc_before_article_insert() : bar_code = 5492850000012
INSERT 0 1
# select * from t_articles WHERE k_id > 2000;
k_id | product_id | color_id | color_desc | height | size | bar_code
------+------------+----------+------------+--------+------+--------------
4001 | 1 | 065 | White | | XS | 492850000012
(1 ligne)
Missing the firs digit of the barcode.
Thanks in advance for your help
Regards
Guy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: G.De_Leeuw@eurofer.be
Subject: Re: C trigger problem : conversion of CString to Datum
In-Reply-To: <4B7FFA2C.3030001@eurofer.be>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox