1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
-------------------------------------------------------------------------------
-- --
-- GNADE : GNu Ada Database Environment --
-- --
-- Author : Juergen Pfeifer <juergen.pfeifer@gmx.net>
--
-- Copyright (C) 2000-2002 Juergen Pfeifer
-- --
-- GNADE is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNADE is implemented to work with GNAT, the GNU Ada compiler. --
-- --
-------------------------------------------------------------------------------
package body GNU.DB.SQLCLI.Environment_Attribute is
procedure Get_Env_Attr (EnvironmentHandle : in SQLHENV;
Attribute : in SQL_ENVIRONMENT_ATTRIBUTE;
Value : in SQLPOINTER;
Length : in out SQLINTEGER;
Data : in SQLSMALLINT;
ErrorCode : access SQLRETURN)
is
pragma Unreferenced (Data);
function GetEnvAttr (EnvironmentHandle : SQLHENV;
Env_Type : SQL_ENVIRONMENT_ATTRIBUTE;
ValuePtr : SQLPOINTER;
Buffer_Length : SQLINTEGER;
P_Length : access SQLINTEGER)
return SQLRETURN;
pragma Import ($CALLCONVENTION, GetEnvAttr, "SQLGetEnvAttr");
Len : aliased SQLINTEGER := Length;
RC : constant SQLRETURN := GetEnvAttr (EnvironmentHandle,
Attribute,
Value,
Len,
Len'Access);
begin
ErrorCode.all := RC;
if Is_SQL_Ok (RC) then
Length := Len;
end if;
end Get_Env_Attr;
procedure Set_Env_Attr (EnvironmentHandle : in SQLHENV;
Attribute : in SQL_ENVIRONMENT_ATTRIBUTE;
Value : in SQLPOINTER;
Length : in SQLINTEGER;
Data : in SQLSMALLINT;
ErrorCode : out SQLRETURN)
is
pragma Unreferenced (Data);
function SetEnvAttr (EnvironmentHandle : SQLHENV;
Attribute : SQL_ENVIRONMENT_ATTRIBUTE;
Value : SQLPOINTER;
StringLength : SQLINTEGER)
return SQLRETURN;
pragma Import ($CALLCONVENTION, SetEnvAttr, "SQLSetEnvAttr");
begin
ErrorCode := SetEnvAttr (EnvironmentHandle,
Attribute,
Value,
Length);
end Set_Env_Attr;
function SQLGetEnvAttr
(EnvironmentHandle : SQLHENV;
Attribute : SQL_ENVIRONMENT_ATTRIBUTE;
MaxLength : SQLSMALLINT := SQL_MAX_OPTION_STRING_LENGTH;
ErrorCode : access SQLRETURN)
return Environment_Attribute'Class is
use type Dispatch.Attr_Get_Func;
F : constant Dispatch.Attr_Get_Func := Dispatch.Get_Func (Attribute);
begin
if F = null then
Raise_SQL_Error ("SQLGetEnvAttr",
SQL_ENVIRONMENT_ATTRIBUTE'Image (Attribute) &
Attr_Not_Supported_Msg);
else
return F.all (EnvironmentHandle,
Attribute,
MaxLength,
0,
ErrorCode);
end if;
end SQLGetEnvAttr;
function SQLGetEnvAttr
(EnvironmentHandle : SQLHENV;
Attribute : SQL_ENVIRONMENT_ATTRIBUTE;
MaxLength : SQLSMALLINT := SQL_MAX_OPTION_STRING_LENGTH)
return Environment_Attribute'Class is
RC : aliased SQLRETURN;
Result : constant Environment_Attribute'Class :=
SQLGetEnvAttr (EnvironmentHandle, Attribute, MaxLength, RC'Access);
begin
Check_SQL_Error (RC => RC,
ProcedureName => "SQLGetEnvAttr",
HandleType => SQL_HANDLE_ENV,
Handle => EnvironmentHandle);
return Result;
end SQLGetEnvAttr;
function SQLSetEnvAttr
(EnvironmentHandle : in SQLHENV;
AttrRec : in Environment_Attribute'Class) return SQLRETURN
is
use type Dispatch.Attr_Set_Proc;
F : constant Dispatch.Attr_Set_Proc :=
Dispatch.Set_Proc (AttrRec.Attribute);
RC : SQLRETURN;
begin
if F = null then
Raise_SQL_Error
("SQLSetEnvAttr",
SQL_ENVIRONMENT_ATTRIBUTE'Image (AttrRec.Attribute) &
Attr_Not_Supported_Msg);
else
F.all (EnvironmentHandle, AttrRec, 0, RC);
end if;
return RC;
end SQLSetEnvAttr;
procedure SQLSetEnvAttr
(EnvironmentHandle : in SQLHENV;
AttrRec : in Environment_Attribute'Class) is
RC : constant SQLRETURN := SQLSetEnvAttr (EnvironmentHandle, AttrRec);
begin
Check_SQL_Error (RC => RC,
ProcedureName => "SQLSetEnvAttr",
HandleType => SQL_HANDLE_ENV,
Handle => EnvironmentHandle);
end SQLSetEnvAttr;
begin
EA_Boolean.Register (SQL_ATTR_OUTPUT_NTS);
end GNU.DB.SQLCLI.Environment_Attribute;
|