Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id AF403634850 for ; Sat, 20 Feb 2010 11:16:38 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 09756-03 for ; Sat, 20 Feb 2010 15:16:18 +0000 (UTC) X-Greylist: delayed 00:07:32.325677 by SQLgrey-1.7.6 Received: from brublucs01.mactelecom.net (brublucs01.mactelecom.net [217.64.240.242]) by mail.postgresql.org (Postfix) with ESMTP id 7821C634543 for ; Sat, 20 Feb 2010 11:13:06 -0400 (AST) Received: by brublucs01.mactelecom.net (Postfix, from userid 1006) id 968C2F75FC; Sat, 20 Feb 2010 15:05:29 +0000 (UTC) Received: from smtp.eurofer.be (217.64.254.218.mactelecom.net [217.64.254.218]) by brublucs01.mactelecom.net (Postfix) with ESMTP id 42A02F75FA for ; Sat, 20 Feb 2010 15:05:29 +0000 (UTC) Received: from [192.168.5.10] by smtp.eurofer.be with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1NiqtV-00024Q-2e for pgsql-admin@postgresql.org; Sat, 20 Feb 2010 16:05:30 +0100 Message-ID: <4B7FFA2C.3030001@eurofer.be> Date: Sat, 20 Feb 2010 16:05:16 +0100 From: Guy Deleeuw User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); fr; rv:1.9.1.5) Gecko/20091204 Lightning/1.0b1 Thunderbird/3.0 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam_score: -3.8 X-SA-Exim-Connect-IP: 192.168.5.10 X-SA-Exim-Mail-From: G.De_Leeuw@eurofer.be Subject: C trigger problem : conversion of CString to Datum X-SA-Exim-Scanned: Yes (on smtp.eurofer.be) X-All-Recipients: pgsql-admin@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=-10 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 201002/150 X-Sequence-Number: 33753 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