From: "Thomas Løcke" <tl@ada-dk.org>
Subject: Problem in GNATColl when using prepared queries: GNATCOLL.SQL.POSTGRES.GNADE.POSTGRESQL_ERROR is raised
Date: Fri, 25 Feb 2011 16:45:32 +0100
Date: 2011-02-25T16:45:32+01:00 [thread overview]
Message-ID: <4d67ce9c$0$23765$14726298@news.sunsite.dk> (raw)
If I do this:
declare
-- ... stuff
Cur : Forward_Cursor;
Q : constant SQL_Query := SQL_Select
(Fields => Tmp.Id & Tmp.Name,
From => Tmp,
Where => Tmp.Name = Text_Param (1));
P : constant Prepared_Statement := Prepare
(Query => Q,
On_Server => True);
begin
Cur.Fetch (Connection => Connection,
Stmt => P,
Params => (1 => +Some_Name'Access));
while Cur.Has_Row loop
Put_Line ("id=" & Cur.Integer_Value (0)'Img);
Put_Line ("name=" & Cur.Value (1));
Cur.Next;
end loop;
Put_Line (Cur.Processed_Rows'Img);
end;
Then this exception is raised:
GNATCOLL.SQL.POSTGRES.GNADE.POSTGRESQL_ERROR
and I get no output at all.
But if I instead do this
declare
-- ... stuff
Cur : Forward_Cursor;
Q : constant SQL_Query := SQL_Select
(Fields => Tmp.Id & Tmp.Name,
From => Tmp,
Where => Tmp.Name = Some_Name);
begin
Cur.Fetch (Connection => Connection,
Query => Q);
while Cur.Has_Row loop
Put_Line ("id=" & Cur.Integer_Value (0)'Img);
Put_Line ("name=" & Cur.Value (1));
Cur.Next;
end loop;
Put_Line (Cur.Processed_Rows'Img);
end;
Then I get some nice output, and everything works.
But I don't want to use the latter solution. I want to use prepared and
parameterized queries, but for some odd reason it wont work.
If I get rid of the Cur.Integer_Value (0) and Cur.Value (1) calls in
the while loop from the prepared example, then I also get rid of the
exception, so it appears to be some sort of issue with the *Value
functions and prepared queries.
The exception is raised in gnatcoll-sql-postgres-gnade.adb:1122.
Oh, and both queries do fetch the same amount of data - I check that
with the Processed_Rows function after the loop. It's just that the
prepared query wont allow me to "get to" the data, unless I leave out
the *Value calls.
--
Thomas L�cke
Email: tl at ada-dk.org
Web: http//:ada-dk.org
http://identi.ca/thomaslocke
next reply other threads:[~2011-02-25 15:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-25 15:45 Thomas Løcke [this message]
2011-02-25 16:05 ` Problem in GNATColl when using prepared queries: GNATCOLL.SQL.POSTGRES.GNADE.POSTGRESQL_ERROR is raised Dmitry A. Kazakov
2011-02-25 18:24 ` Thomas Løcke
2011-02-25 20:08 ` Dmitry A. Kazakov
2011-02-25 21:50 ` Thomas Løcke
2011-02-26 19:33 ` Dmitry A. Kazakov
2011-02-27 14:53 ` Thomas Løcke
2011-02-27 15:36 ` Dmitry A. Kazakov
2011-02-27 15:49 ` Thomas Løcke
2011-02-27 20:15 ` Dmitry A. Kazakov
2011-02-27 21:53 ` Thomas Løcke
2011-02-28 13:49 ` Emmanuel Briot
2011-03-01 8:34 ` Thomas Løcke
2011-03-01 10:28 ` Emmanuel Briot
2011-03-01 20:33 ` Thomas Løcke
2011-03-01 20:54 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox