comp.lang.ada
 help / color / mirror / Atom feed
* GNATcoll and parameterized queries have me confused
@ 2011-02-23 11:58 Thomas Løcke
  2011-02-23 12:32 ` Thomas Løcke
  2011-02-25 14:11 ` Possible "bug" found in gnatcoll-sql_impl.adb Thomas Løcke
  0 siblings, 2 replies; 8+ messages in thread
From: Thomas Løcke @ 2011-02-23 11:58 UTC (permalink / 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



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

end of thread, other threads:[~2011-03-01  8:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-23 11:58 GNATcoll and parameterized queries have me confused Thomas Løcke
2011-02-23 12:32 ` 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

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