comp.lang.ada
 help / color / mirror / Atom feed
From: "Thomas Løcke" <tl@ada-dk.org>
Subject: GNATcoll and parameterized queries have me confused
Date: Wed, 23 Feb 2011 12:58:11 +0100
Date: 2011-02-23T12:58:11+01:00	[thread overview]
Message-ID: <4d64f653$0$23761$14726298@news.sunsite.dk> (raw)

Hey all,

When I insert data into a PostgreSQL database using parameterized
queries, I end up with more characters than I've bargained for.

If I do this:

    Conn.Execute ("INSERT INTO tbl (name) VALUES ('Peter')");

I end up with Peter in the database. Plain Peter. 5 characters.

If I instead do this:

    N : aliased constant String := "Peter";
    P : constant Prepared_Statement := Prepare
      ("INSERT INTO tbl (name) VALUES ($1)");

    Conn.Execute (Stmt => P,
                  Params => (1 => +N'Access));


I end up with 'Peter' in the database. 7 characters. Two single
quotes added by GNATcoll.

I've tried doing a manual parameterized insert using psql:

    PREPARE foo (text) AS INSERT INTO tbl VALUES($1);
    EXECUTE foo ('Peter');

I've also fired up the phpPgAdmin web-tool and tried using that.

And the result is, for both, as expected; plain old 5 character Peter.
So PostgreSQL is apparently not at fault here.

Am I doing something wrong with GNATcoll? I'd rather not have those
extra single quotes added to all my string data.  :o)

-- 
Thomas L�cke

Email: tl at ada-dk.org
Web: http//:ada-dk.org
http://identi.ca/thomaslocke



             reply	other threads:[~2011-02-23 11:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-23 11:58 Thomas Løcke [this message]
2011-02-23 12:32 ` GNATcoll and parameterized queries have me confused Thomas Løcke
2011-02-25 14:11 ` Possible "bug" found in gnatcoll-sql_impl.adb Thomas Løcke
2011-02-25 14:44   ` Ludovic Brenta
2011-02-25 14:53     ` Thomas Løcke
2011-02-28 11:17       ` Ludovic Brenta
2011-02-28 14:04         ` Emmanuel Briot
2011-03-01  8:03           ` Thomas Løcke
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox