C++Builder6 enum
Hi,
I am using C++Builder6 on WinXPSP3, with Devart's dbExpress driver. I declared a enumeration type called 'professionEnum', which is used by my variable 'profession'. I get an error: 'Cannot access field 'rootcause' as type Text', if I try and enter a value into the enum field.
1. I create the table as follows:
CREATE TABLE IF NOT EXISTS
status(
statusCode BIGINT PRIMARY KEY,
description VARCHAR(50),
level SMALLINT,
rootCause rootCauseEnum,
material VARCHAR(100),
actionTaken VARCHAR(50)
)
2. I add an enum type 'rootCauseEnum' as follows:
AnsiString SQL;
SQL = "CREATE TYPE ";
SQL = SQL + edtEnumerationType->Text; // My entry: rootCauseEnum
SQL = SQL + " AS ENUM ( ";
SQL = SQL + edtEnumerationList->Text; // My entry: 'none','unknown','elec','oil'
SQL = SQL + " )";
int errorCode = frmDataModule->eyeConnection->ExecuteDirect(SQL);
3. I add a record to the status table from the command prompt which works fine as follows:
eye=# INSERT INTO status VALUES( 100002, 'Running', 0, 'none', 'Not applicable', 'NA');
4.I add a record to the status table from C++Builder as follows:
I have an edit box for every field, as I enter the following all is fine:
statusCode=100003
description=Stopped
level=0
As I enter any of the following into the rootCause field:
rootCause=none
rootCause=1
I get the following error:
Cannot access field 'rootcause' as type Text.
Therefore before I apply the updates to the table, i get the error.
The field 'rootCause' is indicated as (Memo) in run-time.
This worked fine when I used MySQL. With MySQL I can enter
rootCause=none
or
rootCause=1
Thanks.
Charl
On 03/15/2013 04:06 AM, Charl Roux wrote:
Hi,
I am using C++Builder6 on WinXPSP3, with Devart's dbExpress driver. I
declared a enumeration type called 'professionEnum', which is used by my
variable 'profession'. I get an error: 'Cannot access field 'rootcause'
as type Text', if I try and enter a value into the enum field.
Not sure where 'professionEnum' comes into play, it not shown anywhere
below. I will assume you mean 'rootCauseEnum'.
1. I create the table as follows:
CREATE TABLE IF NOT EXISTS
status(
statusCode BIGINT PRIMARY KEY,
description VARCHAR(50),
level SMALLINT,
rootCause rootCauseEnum,
material VARCHAR(100),
actionTaken VARCHAR(50)
)2. I add an enum type 'rootCauseEnum' as follows:
AnsiString SQL;SQL = "CREATE TYPE ";
SQL = SQL + edtEnumerationType->Text; // My entry: rootCauseEnum
SQL = SQL + " AS ENUM ( ";
SQL = SQL + edtEnumerationList->Text; // My entry:
'none','unknown','elec','oil'
SQL = SQL + " )";int errorCode = frmDataModule->eyeConnection->ExecuteDirect(SQL);
3. I add a record to the status table from the command prompt which
works fine as follows:
eye=# INSERT INTO status VALUES( 100002, 'Running', 0, 'none', 'Not
applicable', 'NA');4.I add a record to the status table from C++Builder as follows:
I have an edit box for every field, as I enter the following all is fine:
statusCode=100003
description=Stopped
level=0
As I enter any of the following into the rootCause field:
rootCause=none
rootCause=1
I get the following error:
Cannot access field 'rootcause' as type Text.
Are you sure this is not a case sensitivity problem on the field
rootCause. In your table definition it is rootCause, in the error
message it is rootcause. Postgres will fold down unless the field name
is quoted. If the the original table definition quoted the field names
then they retain their case and need to be quoted when used. For more
detail see:
http://www.postgresql.org/docs/9.2/static/sql-syntax-lexical.html
4.1.1. Identifiers and Key Words
Therefore before I apply the updates to the table, i get the error.
The field 'rootCause' is indicated as (Memo) in run-time.
This worked fine when I used MySQL. With MySQL I can enter
rootCause=none
or
rootCause=1Thanks.
Charl
--
Adrian Klaver
adrian.klaver@gmail.com
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Thanks. Case-folding was my problem.
Is there any way of getting PostgreSQL to work according to the SQL standard (The folding of
unquoted names to lower case in PostgreSQL is incompatible with the SQL
standard, which says that unquoted names should be folded to
upper case.), so there is no need for me to add quotes to all names?
Show quoted text
Date: Fri, 15 Mar 2013 07:05:11 -0700
From: adrian.klaver@gmail.com
To: charl.roux@hotmail.com
CC: pgsql-general@postgresql.org
Subject: Re: [GENERAL] C++Builder6 enumOn 03/15/2013 04:06 AM, Charl Roux wrote:
Hi,
I am using C++Builder6 on WinXPSP3, with Devart's dbExpress driver. I
declared a enumeration type called 'professionEnum', which is used by my
variable 'profession'. I get an error: 'Cannot access field 'rootcause'
as type Text', if I try and enter a value into the enum field.Not sure where 'professionEnum' comes into play, it not shown anywhere
below. I will assume you mean 'rootCauseEnum'.1. I create the table as follows:
CREATE TABLE IF NOT EXISTS
status(
statusCode BIGINT PRIMARY KEY,
description VARCHAR(50),
level SMALLINT,
rootCause rootCauseEnum,
material VARCHAR(100),
actionTaken VARCHAR(50)
)2. I add an enum type 'rootCauseEnum' as follows:
AnsiString SQL;SQL = "CREATE TYPE ";
SQL = SQL + edtEnumerationType->Text; // My entry: rootCauseEnum
SQL = SQL + " AS ENUM ( ";
SQL = SQL + edtEnumerationList->Text; // My entry:
'none','unknown','elec','oil'
SQL = SQL + " )";int errorCode = frmDataModule->eyeConnection->ExecuteDirect(SQL);
3. I add a record to the status table from the command prompt which
works fine as follows:
eye=# INSERT INTO status VALUES( 100002, 'Running', 0, 'none', 'Not
applicable', 'NA');4.I add a record to the status table from C++Builder as follows:
I have an edit box for every field, as I enter the following all is fine:
statusCode=100003
description=Stopped
level=0
As I enter any of the following into the rootCause field:
rootCause=none
rootCause=1
I get the following error:
Cannot access field 'rootcause' as type Text.Are you sure this is not a case sensitivity problem on the field
rootCause. In your table definition it is rootCause, in the error
message it is rootcause. Postgres will fold down unless the field name
is quoted. If the the original table definition quoted the field names
then they retain their case and need to be quoted when used. For more
detail see:http://www.postgresql.org/docs/9.2/static/sql-syntax-lexical.html
4.1.1. Identifiers and Key WordsTherefore before I apply the updates to the table, i get the error.
The field 'rootCause' is indicated as (Memo) in run-time.
This worked fine when I used MySQL. With MySQL I can enter
rootCause=none
or
rootCause=1Thanks.
Charl
--
Adrian Klaver
adrian.klaver@gmail.com--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general