pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Insert query
3+ messages / 3 participants
[nested] [flat]

* Insert query
@ 2003-10-17 12:21 Nigel Brookes <nigel.brookes@clerys.ie>
  2003-10-17 13:58 ` Re: Insert query Greg Campbell <greg.campbell@us.michelin.com>
  2003-10-17 13:59 ` Re: Insert query Jeff Eckermann <jeff_eckermann@yahoo.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Nigel Brookes @ 2003-10-17 12:21 UTC (permalink / raw)
  To: pgsql-odbc

Hi Folks,

I'm very new to ODBC and am using VB 5.0.  I have a table with a serial data
type that I'm trying to insert a record into using.

INSERT INTO users VALUES (DEFAULT,'Nigel');

This works when i'm in linux. But when I try to execute it in VB I get an
error 'Too few parameters. Expected 1.'.  Very strange.  Have tried all 3
odbc drivers.  The VB code I use is as follows:

        Dim Backupdb As Database
        '******opens access to PostgreSQL database ***********************
        Connect = "ODBC;DSN=backupdb;DATABASE=backupdb;UID=test;PWD=test;"
        Set Backupdb = OpenDatabase("backupdb", False, False, Connect)
        '*****************************************************************

        Backupdb.Execute txtExecute.Text

Any Ideas??


Regard


Nigel




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Insert query
  2003-10-17 12:21 Insert query Nigel Brookes <nigel.brookes@clerys.ie>
@ 2003-10-17 13:58 ` Greg Campbell <greg.campbell@us.michelin.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Greg Campbell @ 2003-10-17 13:58 UTC (permalink / raw)
  To: Nigel Brookes <nigel.brookes@clerys.ie>; +Cc: pgsql-odbc

I guess you are using RDO under VB5. My first suggestion is to "get thee
to a newer interface."
But the real problem lies in the SQL. 

Serial data types are auto-incrementing and do not need a value in the
INSERT statement ergo:
INSERT INTO users VALUES ('Nigel');
should work just fine -- or almost

Secondly, you are trying to use POSITIONAL syntax on the insert, that is
to say you have written
INSERT INTO mytable VALUES (field1_value, field2_value,
field3_value,..);
This make success dependent on the order of your fields in the INSERT
string being the same as the order of the fields in the database, so the
order of fields in the database better not change.

It is a better practice to use field name explicit syntax 
INSERT INTO mytable (field1_name, field2_name, field3_name,...) VALUES
(field1_value, field2_value, field3_value,..);

example
INSERT INTO users (first_name, last_name) VALUES ('Nigel','Brookes');



Nigel Brookes wrote:
> 
> Hi Folks,
> 
> I'm very new to ODBC and am using VB 5.0.  I have a table with a serial data
> type that I'm trying to insert a record into using.
> 
> INSERT INTO users VALUES (DEFAULT,'Nigel');
> 
> This works when i'm in linux. But when I try to execute it in VB I get an
> error 'Too few parameters. Expected 1.'.  Very strange.  Have tried all 3
> odbc drivers.  The VB code I use is as follows:
> 
>         Dim Backupdb As Database
>         '******opens access to PostgreSQL database ***********************
>         Connect = "ODBC;DSN=backupdb;DATABASE=backupdb;UID=test;PWD=test;"
>         Set Backupdb = OpenDatabase("backupdb", False, False, Connect)
>         '*****************************************************************
> 
>         Backupdb.Execute txtExecute.Text
> 
> Any Ideas??
> 
> Regard
> 
> Nigel
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Insert query
  2003-10-17 12:21 Insert query Nigel Brookes <nigel.brookes@clerys.ie>
@ 2003-10-17 13:59 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Jeff Eckermann @ 2003-10-17 13:59 UTC (permalink / raw)
  To: Nigel Brookes <nigel.brookes@clerys.ie>; pgsql-odbc

--- Nigel Brookes <nigel.brookes@clerys.ie> wrote:
> Hi Folks,
> 
> I'm very new to ODBC and am using VB 5.0.  I have a
> table with a serial data
> type that I'm trying to insert a record into using.
> 
> INSERT INTO users VALUES (DEFAULT,'Nigel');
> 
> This works when i'm in linux. But when I try to
> execute it in VB I get an
> error 'Too few parameters. Expected 1.'.  Very
> strange.  Have tried all 3
> odbc drivers.  The VB code I use is as follows:
> 
>         Dim Backupdb As Database
>         '******opens access to PostgreSQL database
> ***********************
>         Connect =
>
"ODBC;DSN=backupdb;DATABASE=backupdb;UID=test;PWD=test;"
>         Set Backupdb = OpenDatabase("backupdb",
> False, False, Connect)
>        
>
'*****************************************************************
> 
>         Backupdb.Execute txtExecute.Text
> 
> Any Ideas??

Don't know the cause of the error, but: what happens
if you use "INSERT INTO users (fieldname) VALUES
('Nigel');" ?

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-10-17 13:59 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-10-17 12:21 Insert query Nigel Brookes <nigel.brookes@clerys.ie>
2003-10-17 13:58 ` Greg Campbell <greg.campbell@us.michelin.com>
2003-10-17 13:59 ` Jeff Eckermann <jeff_eckermann@yahoo.com>

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