From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,89e2ed92b27de792,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!feeder.news-service.com!news.netcologne.de!ramfeed1.netcologne.de!news.tele.dk!feed118.news.tele.dk!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Date: Fri, 25 Feb 2011 16:45:32 +0100 From: =?ISO-8859-1?Q?Thomas_L=F8cke?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101210 Thunderbird/3.1.7 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Problem in GNATColl when using prepared queries: GNATCOLL.SQL.POSTGRES.GNADE.POSTGRESQL_ERROR is raised Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4d67ce9c$0$23765$14726298@news.sunsite.dk> Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 83.91.213.86 X-Trace: news.sunsite.dk DXC=OTmb8f]E1b=OPCTD3`iC24YSB=nbEKnk;:0HF:[2V9b:1GQX8;5?Cn7RED9SjB8:69Qo^8G8>And=d?0oG]>ih_9aBPdSh0TI04 X-Complaints-To: staff@sunsite.dk Xref: g2news1.google.com comp.lang.ada:17598 Date: 2011-02-25T16:45:32+01:00 List-Id: 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