pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: iklassen@phhpc.com
To: pgsql-odbc@postgresql.org
Subject: Problems with MFC AddNew
Date: Tue, 23 Jan 2007 10:18:48 -0700 (MST)
Message-ID: <63255.68.145.165.239.1169572728.squirrel@phhpc.com> (raw)

Hello,

I'm having some difficulty with adding new records using the ODBC driver
with MFC.  This is only occurring is certain situations...

I created a simple table:

CREATE TABLE project (project_id INT PRIMARY KEY);

Using Visual Studio C++ I created a CRecordset class (CProject) to
exchange data with the project table.  I then execute the following code:

CDatabase database;
database.OpenEx(_T("DSN=PostgreSQL30"));
CProject project(&database);
project.Open();
project.AddNew();
project.m_project_id = 1;
project.Update();

I get an Access Violation on the Update().  The log file shows the
following error:

psqlodbc_3100.log:
conn=01104290, query='SELECT "project_id"  , "ctid", "project_id" FROM
"public"."project"'
    [ fetched 0 rows ]

mylog_3100.log:
[1800-4.186]extend_putdata_info: entering ... self=016C5EC4,
parameters_allocated=0, num_params=1
[1800-4.191]extend_putdata_info: unable to create 1 new pdata from 0 old
pdata

Now I've been able to get the Update() to work in the following situations:

- remove the primary key:
  CREATE TABLE project (project_id INT);

- change the int to bigint:
  CREATE TABLE project (project_id BIGINT PRIMARY KEY);

- make sure at least one record exists in the table:
  CREATE TABLE project (project_id INT PRIMARY KEY);
  INSERT INTO project (project_id) VALUES (2);

So what's going on?  I would like to use int, but if I have to I can
switch to bigint.  Thanks for your help.

Ian




view thread (3+ messages)  latest in thread

Message-ID: <63255.68.145.165.239.1169572728.squirrel@phhpc.com>
Permalink:  ../63255.68.145.165.239.1169572728.squirrel@phhpc.com/
Also on:    postgresql.org/message-id/63255.68.145.165.239.1169572728.squirrel@phhpc.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: iklassen@phhpc.com
  Subject: Re: Problems with MFC AddNew
  In-Reply-To: <63255.68.145.165.239.1169572728.squirrel@phhpc.com>
  References: <63255.68.145.165.239.1169572728.squirrel@phhpc.com>

* 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