Hi,
There is an "access violation" caused by ecpgtypes
when using date fields and ecpg.
Everything was runnig ok with dates rangin from
2000 - 2004, but this acces violation
occurs when the date with th year 1968
appears.
Looking at my program, I can see that this happens
inside the SELECT into :data_admissao;
where "data_admissao" is a date type.
When I remove this field from the select, then it
works.
Here is the steps to reproduce the
error:
PostgreSQL 8.0.0 beta5
Windows XP Professional
MingW
Table:
CREATE TABLE funcionarios
( id int4 NOT NULL, nome varchar(40) NOT NULL, data_admissao date NOT NULL, funcao int4 NOT NULL, CONSTRAINT funcionarios_pkey PRIMARY KEY (id) ) WITHOUT OIDS; Data:
INSERT INTO fpcadfun VALUES
(111,'SILVA','1968-01-19',10);
Program:
class funcionario { ... };
typedef std::vector<funcionario>
funcionario_type;
bool db_ler_funcionarios( funcionario_type
&funcs )
{ funcs.clear(); EXEC SQL BEGIN DECLARE SECTION;
int id; VARCHAR nome[40]; date data_admissao; int funcao; EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE func_cur CURSOR
FOR
SELECT id, nome, data_admissao, funcao FROM funcionarios ORDER BY id; EXEC SQL OPEN func_cur;
EXEC SQL WHENEVER NOT FOUND DO break; char *txt_adm;
while(true)
{ EXEC SQL FETCH NEXT FROM func_cur INTO :id, :nome, :data_admissao, :funcao; txt_adm =
PGTYPESdate_to_asc(data_admissao);
funcionario f( id, nome.arr, txt_adm, funcao ); funcs.push_back(f); free(txt_adm); } EXEC SQL CLOSE func_cur; return true; } The access violation occurs at the bold line. I'm
using mingw to compile this
program.
Please fell free to ask for any other question or
comment about this error.
I hope that I could give my 2 cents for this
incredible RDMS.
Best Regards,
Paulo Assis
|