Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 42CBC633672 for ; Tue, 22 Sep 2009 12:08:50 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 54652-07 for ; Tue, 22 Sep 2009 15:08:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.potentialtech.com (internet.potentialtech.com [66.167.251.6]) by mail.postgresql.org (Postfix) with ESMTP id BDBE96322F0 for ; Tue, 22 Sep 2009 12:08:37 -0300 (ADT) Received: from localhost (pr40.pitbpa0.pub.collaborativefusion.com [206.210.89.202]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.potentialtech.com (Postfix) with ESMTPSA id 9AE15EBC0A; Tue, 22 Sep 2009 11:08:36 -0400 (EDT) Date: Tue, 22 Sep 2009 11:08:35 -0400 From: Bill Moran To: Gustavo Amarilla Santacruz Cc: pgsql-php@postgresql.org Subject: Re: Error code Message-Id: <20090922110835.a8c5b2b4.wmoran@potentialtech.com> In-Reply-To: References: <4AB821BD.6070508@gmail.com> <20090922093815.7b8ae05f.wmoran@potentialtech.com> Organization: Bill Moran X-Mailer: Sylpheed 2.7.1 (GTK+ 2.16.5; i386-portbld-freebsd7.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/20 X-Sequence-Number: 4078 In response to Gustavo Amarilla Santacruz : > Thank you, Bill. > I can not use the numeric error code such as 23505 ( by coding convention ); > I need to do this: That's fine. Note, however, that those codes are not numeric. Also, you'll be better served putting them in constants, to avoid bugs where the values are accidentally changed. > > > ------------------------ CODE > ----------------------------------------------------------- > > include( "PostgresqlErrorList.php" ); > . > . > . > if( $errorCode == $UNIQUE_VIOLATION ) > echo( "message" ); > > > > > ------------------------ CODE > ----------------------------------------------------------- > > > Here, "PostgresqlErrorList.php" is a file included in PHP libraries. This > file would can contain code such as: > > > > $UNIQUE_VIOLATION = 23505; > $DATETIME_FIELD_OVERFLOW = 22008; > . > . > . > ?> > > > Exists this file for in Postgresql-PHP library? > > On Tue, Sep 22, 2009 at 9:38 AM, Bill Moran wrote: > > > In response to Gustavo Amarilla Santacruz : > > > > > Thank you, Chris. > > > Now, I need to do this in PHP: > > > > > > -------------------- CODE > > > --------------------------------------------------------------- > > > > > > $errorCode = pg_result_error_field($res1, PGSQL_DIAG_SQLSTATE) ; > > > > > > if( $errorCode == UNIQUE_VIOLATION ) > > > > if ( $errorCode == '23505' ) > > > > -- > > Bill Moran > > http://www.potentialtech.com > > http://people.collaborativefusion.com/~wmoran/ > > > > > > -- > Gustavo Amarilla > ISMEB -- Bill Moran http://www.potentialtech.com http://people.collaborativefusion.com/~wmoran/