From: tonyg <tonythegair@googlemail.com>
Subject: integer binding and gnade odbc
Date: Tue, 6 Jul 2010 00:48:31 -0700 (PDT)
Date: 2010-07-06T00:48:31-07:00 [thread overview]
Message-ID: <9e7efe1c-1823-49ff-be26-b39bced21e8a@k39g2000yqb.googlegroups.com> (raw)
When I run this code
type Planid_Type is new SQLINTEGER;
type Planid_Ptr is access all Planid_Type;
package Planid_Binding is new
GNU.DB.SQLCLI.IntegerBinding (Planid_Type);
package PB renames Planid_Binding;
StatementHandle : SQLHSTMT;
Len_Macid : aliased SQLINTEGER;
Macid : aliased String := 16 * '.';
Planid : aliased Planid_Type;
Len_Planid : aliased SQLINTEGER ;
query_string : String := "Select heater.macid, room.planid
from heater" &
"join room on heater.roomid = room.roomid order by
room.planid";
begin
SQLAllocHandle (SQL_HANDLE_STMT, ConnectionHandle,
StatementHandle);
SQLPrepare (StatementHandle,
"SELECT " & QuoteIdentifier("heater") & "." &
QuoteIdentifier ("macid") & ", " &
QuoteIdentifier ("room") & "." &
QuoteIdentifier ("planid") &
" FROM " & QuoteIdentifier ("heater") & " INNER
JOIN " &
QuoteIdentifier("room") & " ON " &
QuoteIdentifier ("heater") & "." &
QuoteIdentifier ("roomid") & " = " &
QuoteIdentifier ("room") & "." &
QuoteIdentifier ("roomid") &
"ORDER BY " &
QuoteIdentifier ("room") & "." &
QuoteIdentifier ("planid") );
SQLBindCol
(StatementHandle, 1, Macid'Access, Len_Macid'Access);
PB.SQLBindCol ( StatementHandle, 2, Planid'Access,
Len_Planid'Access);
SQLExecute (StatementHandle);
begin
loop
SQLFetch (StatementHandle);
SQLFixNTS (Macid, Len_Macid);
Put (Macid);
Put (", ");
Put (Planid_Type'image(Planid));
New_Line;
end loop;
exception
when No_Data =>
-- normal loop exit
null;
end;
The code compiles and it returns the macid parameter with the correct
string , however the value I get for planid is 0 which is incorrect. I
took Stephe's Advice and I ran it through the mysql query browser and
got the correct result ( which is 1) .
Am I binding my integer column correctly ? (I suspect not)
reply other threads:[~2010-07-06 7:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox