/usr/share/ada/adainclude/gnadeodbc/gnu-db-sqlcli-desc.adb is in libgnadeodbc2-dev 1.6.2-9.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | pragma Source_Reference (1, "dbi/odbc/gnu-db-sqlcli-desc.gpb");
-------------------------------------------------------------------------------
-- --
-- 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. --
-- --
-------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Ada.Strings.Fixed;
with Ada.Strings.Wide_Fixed;
package body GNU.DB.SQLCLI.Desc is
procedure Register_String_Attributes;
procedure SQLSetDescRec (DescriptorHandle : in SQLHDESC;
RecNumber : in SQLSMALLINT;
SQLType : in SQL_DATA_TYPE;
DateTime_SubType : in SQL_DATETIME_SUBCODE;
Length : in SQLINTEGER;
Precision : in SQLSMALLINT;
Scale : in SQLSMALLINT;
Data : in SQLPOINTER;
StringLength : out SQLINTEGER;
Indicator : out SQLINTEGER;
RC : out SQLRETURN) is
function SetDescRec (DescriptorHandle : SQLHDESC;
RecNumber : SQLSMALLINT;
SQLType : SQL_DATA_TYPE;
DateTime_SubType : SQL_DATETIME_SUBCODE;
Length : SQLINTEGER;
Precision : SQLSMALLINT;
Scale : SQLSMALLINT;
Data : SQLPOINTER;
StringLength : access SQLINTEGER;
Indicator : access SQLINTEGER)
return SQLRETURN;
pragma Import (C, SetDescRec, "SQLSetDescRec");
SL : aliased SQLINTEGER;
IC : aliased SQLINTEGER;
ER : SQLRETURN;
begin
ER := SetDescRec (DescriptorHandle,
RecNumber,
SQLType,
DateTime_SubType,
Length,
Precision,
Scale,
Data,
SL'Access,
IC'Access);
RC := ER;
if Is_SQL_Ok (ER) then
StringLength := SL;
Indicator := IC;
end if;
end SQLSetDescRec;
procedure SQLSetDescRec (DescriptorHandle : in SQLHDESC;
RecNumber : in SQLSMALLINT;
SQLType : in SQL_DATA_TYPE;
DateTime_SubType : in SQL_DATETIME_SUBCODE;
Length : in SQLINTEGER;
Precision : in SQLSMALLINT;
Scale : in SQLSMALLINT;
Data : in SQLPOINTER;
StringLength : out SQLINTEGER;
Indicator : out SQLINTEGER)
is
RC : SQLRETURN;
begin
SQLSetDescRec (DescriptorHandle,
RecNumber,
SQLType,
DateTime_SubType,
Length,
Precision,
Scale,
Data,
StringLength,
Indicator,
RC);
Check_SQL_Error (RC => RC,
ProcedureName => "SQLSetDescRec",
HandleType => SQL_HANDLE_DESC,
Handle => DescriptorHandle);
end SQLSetDescRec;
procedure SQLGetDescRec (DescriptorHandle : in SQLHDESC;
RecNumber : in SQLSMALLINT;
Name : out String;
StringLength : out SQLSMALLINT;
SQLType : out SQL_DATA_TYPE;
DateTime_SubType : out SQL_DATETIME_SUBCODE;
Length : out SQLINTEGER;
Precision : out SQLSMALLINT;
Scale : out SQLSMALLINT;
Nullable : out SQL_NULLABLE_INFO;
RC : out SQLRETURN) is
use Ada.Strings.Fixed;
function GetDescRec (DescriptorHandle : SQLHDESC;
RecNumber : SQLSMALLINT;
pName : PTR_SQLCHAR;
BufferLength : SQLSMALLINT;
pStringLength : access SQLSMALLINT;
pType : access SQL_DATA_TYPE;
pSubType : access SQL_DATETIME_SUBCODE;
pLength : access SQLINTEGER;
pPrecision : access SQLSMALLINT;
pScale : access SQLSMALLINT;
pNullable : access SQL_NULLABLE_INFO)
return SQLRETURN;
pragma Import (C, GetDescRec, "SQLGetDescRec");
function Cvt_Type is new
Ada.Unchecked_Conversion (SQL_DATA_TYPE, SQLSMALLINT);
function Cvt_SubType is new
Ada.Unchecked_Conversion (SQL_DATETIME_SUBCODE, SQLSMALLINT);
function Cvt_NI is new
Ada.Unchecked_Conversion (SQL_NULLABLE_INFO, SQLSMALLINT);
StrLen : aliased SQLSMALLINT := SQLSMALLINT (Name'Length);
pType : aliased SQL_DATA_TYPE := SQL_DATA_TYPE'First;
pSubType : aliased SQL_DATETIME_SUBCODE := SQL_DATETIME_SUBCODE'First;
pLength : aliased SQLINTEGER := 0;
pPrecision : aliased SQLSMALLINT := 0;
pScale : aliased SQLSMALLINT := 0;
pNullable : aliased SQL_NULLABLE_INFO := SQL_NULLABLE_INFO'First;
ProcName : constant String := "SQLGetDescRec";
IFill : Positive;
EC : constant SQLRETURN := GetDescRec (DescriptorHandle,
RecNumber,
To_PTR_SQLCHAR (Name'Address),
StrLen,
StrLen'Access,
pType'Access,
pSubType'Access,
pLength'Access,
pPrecision'Access,
pScale'Access,
pNullable'Access);
begin
RC := EC;
if Is_SQL_Ok (EC) then
if not pType'Valid then
Raise_Invalid_Enum (ProcedureName => ProcName,
EnumName => "SQL_DATA_TYPE",
EnumValue =>
SQLSMALLINT'Image (Cvt_Type (pType)));
elsif not pSubType'Valid then
Raise_Invalid_Enum (ProcedureName => ProcName,
EnumName => "SQL_DATETIME_SUBCODE",
EnumValue =>
SQLSMALLINT'Image (Cvt_SubType (pSubType)));
elsif not pNullable'Valid then
Raise_Invalid_Enum (ProcedureName => ProcName,
EnumName => "SQL_NULLABLE_INFO",
EnumValue =>
SQLSMALLINT'Image (Cvt_NI (pNullable)));
else
StringLength := StrLen;
SQLType := pType;
DateTime_SubType := pSubType;
Length := pLength;
Precision := pPrecision;
Scale := pScale;
Nullable := pNullable;
if StrLen > 0 and then StrLen < Name'Length then
IFill := Name'Length - Positive (StrLen);
Name ((Name'First + Positive (StrLen)) .. Name'Last) :=
IFill * ' ';
end if;
end if;
end if;
end SQLGetDescRec;
procedure SQLGetDescRec (DescriptorHandle : in SQLHDESC;
RecNumber : in SQLSMALLINT;
Name : out String;
StringLength : out SQLSMALLINT;
SQLType : out SQL_DATA_TYPE;
DateTime_SubType : out SQL_DATETIME_SUBCODE;
Length : out SQLINTEGER;
Precision : out SQLSMALLINT;
Scale : out SQLSMALLINT;
Nullable : out SQL_NULLABLE_INFO)
is
RC : SQLRETURN;
begin
SQLGetDescRec (DescriptorHandle, RecNumber, Name, StringLength,
SQLType, DateTime_SubType, Length,
Precision, Scale, Nullable, RC);
Check_SQL_Error (RC => RC,
ProcedureName => "SQLGetDescRec",
HandleType => SQL_HANDLE_DESC,
Handle => DescriptorHandle);
end SQLGetDescRec;
procedure SQLGetDescRec (DescriptorHandle : in SQLHDESC;
RecNumber : in SQLSMALLINT;
Name : out Wide_String;
StringLength : out SQLSMALLINT;
SQLType : out SQL_DATA_TYPE;
DateTime_SubType : out SQL_DATETIME_SUBCODE;
Length : out SQLINTEGER;
Precision : out SQLSMALLINT;
Scale : out SQLSMALLINT;
Nullable : out SQL_NULLABLE_INFO;
RC : out SQLRETURN) is
use Ada.Strings.Wide_Fixed;
function GetDescRec (DescriptorHandle : SQLHDESC;
RecNumber : SQLSMALLINT;
pName : PTR_SQLTCHAR;
BufferLength : SQLSMALLINT;
pStringLength : access SQLSMALLINT;
pType : access SQL_DATA_TYPE;
pSubType : access SQL_DATETIME_SUBCODE;
pLength : access SQLINTEGER;
pPrecision : access SQLSMALLINT;
pScale : access SQLSMALLINT;
pNullable : access SQL_NULLABLE_INFO)
return SQLRETURN;
pragma Import (C, GetDescRec, "SQLGetDescRecW");
function Cvt_Type is new
Ada.Unchecked_Conversion (SQL_DATA_TYPE, SQLSMALLINT);
function Cvt_SubType is new
Ada.Unchecked_Conversion (SQL_DATETIME_SUBCODE, SQLSMALLINT);
function Cvt_NI is new
Ada.Unchecked_Conversion (SQL_NULLABLE_INFO, SQLSMALLINT);
StrLen : aliased SQLSMALLINT := SQLSMALLINT (Name'Length);
pType : aliased SQL_DATA_TYPE := SQL_DATA_TYPE'First;
pSubType : aliased SQL_DATETIME_SUBCODE := SQL_DATETIME_SUBCODE'First;
pLength : aliased SQLINTEGER := 0;
pPrecision : aliased SQLSMALLINT := 0;
pScale : aliased SQLSMALLINT := 0;
pNullable : aliased SQL_NULLABLE_INFO := SQL_NULLABLE_INFO'First;
ProcName : constant String := "SQLGetDescRec";
IFill : Positive;
EC : constant SQLRETURN := GetDescRec (DescriptorHandle,
RecNumber,
To_PTR_SQLTCHAR (Name'Address),
StrLen,
StrLen'Access,
pType'Access,
pSubType'Access,
pLength'Access,
pPrecision'Access,
pScale'Access,
pNullable'Access);
begin
RC := EC;
if Is_SQL_Ok (EC) then
if not pType'Valid then
Raise_Invalid_Enum (ProcedureName => ProcName,
EnumName => "SQL_DATA_TYPE",
EnumValue =>
SQLSMALLINT'Image (Cvt_Type (pType)));
elsif not pSubType'Valid then
Raise_Invalid_Enum (ProcedureName => ProcName,
EnumName => "SQL_DATETIME_SUBCODE",
EnumValue =>
SQLSMALLINT'Image (Cvt_SubType (pSubType)));
elsif not pNullable'Valid then
Raise_Invalid_Enum (ProcedureName => ProcName,
EnumName => "SQL_NULLABLE_INFO",
EnumValue =>
SQLSMALLINT'Image (Cvt_NI (pNullable)));
else
StringLength := StrLen;
SQLType := pType;
DateTime_SubType := pSubType;
Length := pLength;
Precision := pPrecision;
Scale := pScale;
Nullable := pNullable;
if StrLen > 0 and then StrLen < Name'Length then
IFill := Name'Length - Positive (StrLen);
Name ((Name'First + Positive (StrLen)) .. Name'Last) :=
IFill * Wide_Character'(' ');
end if;
end if;
end if;
end SQLGetDescRec;
procedure SQLGetDescRec (DescriptorHandle : in SQLHDESC;
RecNumber : in SQLSMALLINT;
Name : out Wide_String;
StringLength : out SQLSMALLINT;
SQLType : out SQL_DATA_TYPE;
DateTime_SubType : out SQL_DATETIME_SUBCODE;
Length : out SQLINTEGER;
Precision : out SQLSMALLINT;
Scale : out SQLSMALLINT;
Nullable : out SQL_NULLABLE_INFO)
is
RC : SQLRETURN;
begin
SQLGetDescRec (DescriptorHandle, RecNumber, Name, StringLength,
SQLType, DateTime_SubType, Length,
Precision, Scale, Nullable, RC);
Check_SQL_Error (RC => RC,
ProcedureName => "SQLGetDescRec",
HandleType => SQL_HANDLE_DESC,
Handle => DescriptorHandle);
end SQLGetDescRec;
procedure Get_Desc_Field (DescriptorHandle : in SQLHDESC;
Attribute : in SQL_DESC_FIELD_TYPE;
Value : in SQLPOINTER;
Length : in out SQLINTEGER;
Data : in SQLSMALLINT;
ErrorCode : access SQLRETURN)
is
function GetDescField (DescriptorHandle : SQLHDESC;
RecNumber : SQLSMALLINT;
FieldIdentifier : SQL_DESC_FIELD_TYPE;
Value : SQLPOINTER;
BufferLength : SQLINTEGER;
pStringLength : access SQLINTEGER)
return SQLRETURN;
pragma Import (C, GetDescField, "SQLGetDescField");
function GetDescFieldW (DescriptorHandle : SQLHDESC;
RecNumber : SQLSMALLINT;
FieldIdentifier : SQL_DESC_FIELD_TYPE;
Value : SQLPOINTER;
BufferLength : SQLINTEGER;
pStringLength : access SQLINTEGER)
return SQLRETURN;
pragma Import (C, GetDescFieldW, "SQLGetDescFieldW");
RC : SQLRETURN;
Len : aliased SQLINTEGER := Length;
begin
if Unicode_Attr_Flag then
RC := GetDescFieldW (DescriptorHandle, Data, Attribute, Value, Len,
Len'Access);
else
RC := GetDescField (DescriptorHandle, Data, Attribute, Value, Len,
Len'Access);
end if;
ErrorCode.all := RC;
if Is_SQL_Ok (RC) then
Length := Len;
end if;
end Get_Desc_Field;
function SetDescField (DescriptorHandle : SQLHDESC;
RecNumber : SQLSMALLINT;
FieldIdentifier : SQL_DESC_FIELD_TYPE;
Value : SQLPOINTER;
BufferLength : SQLINTEGER)
return SQLRETURN;
pragma Import (C, SetDescField, "SQLSetDescField");
procedure Set_Desc_Field (DescriptorHandle : in SQLHDESC;
Attribute : in SQL_DESC_FIELD_TYPE;
Value : in SQLPOINTER;
Length : in SQLINTEGER;
Data : in SQLSMALLINT;
ErrorCode : out SQLRETURN)
is
function SetDescFieldW (DescriptorHandle : SQLHDESC;
RecNumber : SQLSMALLINT;
FieldIdentifier : SQL_DESC_FIELD_TYPE;
Value : SQLPOINTER;
BufferLength : SQLINTEGER)
return SQLRETURN;
pragma Import (C, SetDescFieldW, "SQLSetDescFieldW");
RC : SQLRETURN;
begin
if Unicode_Attr_Flag then
RC := SetDescFieldW (DescriptorHandle,
Data, Attribute, Value, Length);
else
RC := SetDescField (DescriptorHandle,
Data, Attribute, Value, Length);
end if;
ErrorCode := RC;
end Set_Desc_Field;
procedure SQLGetDescField (DescriptorHandle : in SQLHDESC;
RecNumber : in SQLSMALLINT;
FieldIdentifier : in SQL_DESC_FIELD_TYPE;
Data : in SQLPOINTER;
Length : in SQLINTEGER;
StringLength : out SQLINTEGER;
RC : out SQLRETURN) is
function GetDescField (DescriptorHandle : SQLHDESC;
RecNumber : SQLSMALLINT;
FieldIdentifier : SQL_DESC_FIELD_TYPE;
Value : SQLPOINTER;
BufferLength : SQLINTEGER;
pStringLength : access SQLINTEGER)
return SQLRETURN;
pragma Import (C, GetDescField, "SQLGetDescField");
Len : aliased SQLINTEGER;
EC : constant SQLRETURN := GetDescField (DescriptorHandle,
RecNumber,
FieldIdentifier,
Data,
Length,
Len'Access);
begin
RC := EC;
if Is_SQL_Ok (EC) then
StringLength := Len;
end if;
end SQLGetDescField;
procedure SQLGetDescField (DescriptorHandle : in SQLHDESC;
RecNumber : in SQLSMALLINT;
FieldIdentifier : in SQL_DESC_FIELD_TYPE;
Data : in SQLPOINTER;
Length : in SQLINTEGER;
StringLength : out SQLINTEGER)
is
RC : SQLRETURN;
begin
SQLGetDescField (DescriptorHandle, RecNumber, FieldIdentifier,
Data, Length, StringLength, RC);
Check_SQL_Error (RC => RC,
ProcedureName => "SQLGetDescField",
HandleType => SQL_HANDLE_DESC,
Handle => DescriptorHandle);
end SQLGetDescField;
function SQLSetDescField (DescriptorHandle : SQLHDESC;
RecNumber : SQLSMALLINT;
FieldIdentifier : SQL_DESC_FIELD_TYPE;
Data : SQLPOINTER;
Length : SQLINTEGER)
return SQLRETURN
is
RC : constant SQLRETURN := SetDescField (DescriptorHandle,
RecNumber,
FieldIdentifier,
Data,
Length);
begin
return RC;
end SQLSetDescField;
procedure SQLSetDescField (DescriptorHandle : SQLHDESC;
RecNumber : SQLSMALLINT;
FieldIdentifier : SQL_DESC_FIELD_TYPE;
Data : SQLPOINTER;
Length : SQLINTEGER)
is
RC : constant SQLRETURN := SQLSetDescField (DescriptorHandle,
RecNumber,
FieldIdentifier,
Data,
Length);
begin
Check_SQL_Error (RC => RC,
ProcedureName => "SQLSetDescField",
HandleType => SQL_HANDLE_DESC,
Handle => DescriptorHandle);
end SQLSetDescField;
procedure SQLColAttribute (StatementHandle : in SQLHSTMT;
ColumnNumber : in SQLUSMALLINT;
FieldIdentifier : in SQL_DESC_FIELD_TYPE;
CharacterAttribute : out String;
NumericAttribute : out SQLINTEGER;
RC : out SQLRETURN) is
-- This version doesn't raise an exception but returns a SQLRETURN
use Ada.Strings.Fixed;
function ColAttribute (StatementHandle : SQLHSTMT;
ColumnNumber : SQLUSMALLINT;
FieldIdentifier : SQL_DESC_FIELD_TYPE;
CharacterAttribute : SQLPOINTER;
BufferLength : SQLSMALLINT;
pStringLength : access SQLSMALLINT;
NumericAttribute : access SQLINTEGER)
return SQLRETURN;
pragma Import (C, ColAttribute, "SQLColAttribute");
StringLength : aliased SQLSMALLINT;
IFill : Integer;
NA : aliased SQLINTEGER := 0;
begin
RC := ColAttribute (StatementHandle,
ColumnNumber,
FieldIdentifier,
To_SQLPOINTER (CharacterAttribute'Address),
SQLSMALLINT (CharacterAttribute'Length),
StringLength'Access,
NA'Access);
if Is_SQL_Ok (RC) then
NumericAttribute := NA;
IFill := CharacterAttribute'Length - Integer (StringLength);
if IFill > 0 then
CharacterAttribute ((CharacterAttribute'First +
Integer (StringLength))
.. CharacterAttribute'Last) :=
IFill * ' ';
end if;
end if;
end SQLColAttribute;
procedure SQLColAttribute (StatementHandle : in SQLHSTMT;
ColumnNumber : in SQLUSMALLINT;
FieldIdentifier : in SQL_DESC_FIELD_TYPE;
CharacterAttribute : out String;
NumericAttribute : out SQLINTEGER) is
RC : SQLRETURN;
begin
SQLColAttribute (StatementHandle, ColumnNumber, FieldIdentifier,
CharacterAttribute, NumericAttribute, RC);
Check_SQL_Error (RC => RC,
ProcedureName => "SQLColAttribute",
HandleType => SQL_HANDLE_STMT,
Handle => StatementHandle);
end SQLColAttribute;
procedure SQLColAttribute (StatementHandle : in SQLHSTMT;
ColumnNumber : in SQLUSMALLINT;
FieldIdentifier : in SQL_DESC_FIELD_TYPE;
CharacterAttribute : out Wide_String;
NumericAttribute : out SQLINTEGER;
RC : out SQLRETURN) is
use Ada.Strings.Wide_Fixed;
function ColAttribute (StatementHandle : SQLHSTMT;
ColumnNumber : SQLUSMALLINT;
FieldIdentifier : SQL_DESC_FIELD_TYPE;
CharacterAttribute : SQLPOINTER;
BufferLength : SQLSMALLINT;
pStringLength : access SQLSMALLINT;
NumericAttribute : access SQLINTEGER)
return SQLRETURN;
pragma Import (C, ColAttribute, "SQLColAttributeW");
StringLength : aliased SQLSMALLINT;
IFill : Integer;
NA : aliased SQLINTEGER := 0;
begin
RC := ColAttribute (StatementHandle,
ColumnNumber,
FieldIdentifier,
To_SQLPOINTER (CharacterAttribute'Address),
SQLSMALLINT (CharacterAttribute'Length),
StringLength'Access,
NA'Access);
if Is_SQL_Ok (RC) then
NumericAttribute := NA;
IFill := CharacterAttribute'Length - Integer (StringLength);
if IFill > 0 then
CharacterAttribute ((CharacterAttribute'First +
Integer(StringLength))
.. CharacterAttribute'Last) :=
IFill * Wide_Character'(' ');
end if;
end if;
end SQLColAttribute;
procedure SQLColAttribute (StatementHandle : in SQLHSTMT;
ColumnNumber : in SQLUSMALLINT;
FieldIdentifier : in SQL_DESC_FIELD_TYPE;
CharacterAttribute : out Wide_String;
NumericAttribute : out SQLINTEGER) is
RC : SQLRETURN;
begin
SQLColAttribute (StatementHandle, ColumnNumber, FieldIdentifier,
CharacterAttribute, NumericAttribute, RC);
Check_SQL_Error (RC => RC,
ProcedureName => "SQLColAttribute",
HandleType => SQL_HANDLE_STMT,
Handle => StatementHandle);
end SQLColAttribute;
procedure Register_String_Attributes
is
begin
if Unicode_Attr_Flag then
DF_WString.Register (SQL_DESC_BASE_COLUMN_NAME);
DF_WString.Register (SQL_DESC_BASE_TABLE_NAME);
DF_WString.Register (SQL_DESC_CATALOG_NAME);
DF_WString.Register (SQL_DESC_LABEL);
DF_WString.Register (SQL_DESC_LITERAL_PREFIX);
DF_WString.Register (SQL_DESC_LITERAL_SUFFIX);
DF_WString.Register (SQL_DESC_LOCAL_TYPE_NAME);
DF_WString.Register (SQL_DESC_NAME);
DF_WString.Register (SQL_DESC_SCHEMA_NAME);
DF_WString.Register (SQL_DESC_TABLE_NAME);
DF_WString.Register (SQL_DESC_TYPE_NAME);
else
DF_String.Register (SQL_DESC_BASE_COLUMN_NAME);
DF_String.Register (SQL_DESC_BASE_TABLE_NAME);
DF_String.Register (SQL_DESC_CATALOG_NAME);
DF_String.Register (SQL_DESC_LABEL);
DF_String.Register (SQL_DESC_LITERAL_PREFIX);
DF_String.Register (SQL_DESC_LITERAL_SUFFIX);
DF_String.Register (SQL_DESC_LOCAL_TYPE_NAME);
DF_String.Register (SQL_DESC_NAME);
DF_String.Register (SQL_DESC_SCHEMA_NAME);
DF_String.Register (SQL_DESC_TABLE_NAME);
DF_String.Register (SQL_DESC_TYPE_NAME);
end if;
end Register_String_Attributes;
begin
DF_SmallInt.Register (SQL_DESC_TYPE);
DF_SmallInt.Register (SQL_DESC_COUNT);
DF_SmallInt.Register (SQL_DESC_CONCISE_TYPE);
DF_SmallInt.Register (SQL_DESC_FIXED_PREC_SCALE);
DF_SmallInt.Register (SQL_DESC_PRECISION);
DF_SmallInt.Register (SQL_DESC_SCALE);
DF_SmallInt.Register (SQL_DESC_MAXIMUM_SCALE);
DF_SmallInt.Register (SQL_DESC_MINIMUM_SCALE);
DF_Int.Register (SQL_DESC_BIND_TYPE);
DF_Int.Register (SQL_DESC_DATETIME_INTERVAL_PRECISION);
DF_Int.Register (SQL_DESC_DISPLAY_SIZE);
DF_Int.Register (SQL_DESC_NUM_PREC_RADIX);
DF_Int.Register (SQL_DESC_OCTET_LENGTH);
DF_Unsigned.Register (SQL_DESC_ARRAY_SIZE);
DF_Unsigned.Register (SQL_DESC_LENGTH);
DF_Boolean.Register (SQL_DESC_AUTO_UNIQUE_VALUE);
DF_Boolean.Register (SQL_DESC_CASE_SENSITIVE);
DF_SBoolean.Register (SQL_DESC_ROWVER);
DF_SBoolean.Register (SQL_DESC_UNSIGNED);
-- Array attributes
Dsp_Desc_Array_Status.Register (SQL_DESC_ARRAY_STATUS_PTR);
Dsp_Bind_Offsets.Register (SQL_DESC_BIND_OFFSET_PTR);
-- Pointer attributes
Dsp_Rows_Processed.Register (SQL_DESC_ROWS_PROCESSED_PTR);
Dsp_Data_Ptr.Register (SQL_DESC_DATA_PTR);
Dsp_Int_Pointer.Register (SQL_DESC_INDICATOR_PTR);
Dsp_Int_Pointer.Register (SQL_DESC_OCTET_LENGTH_PTR);
Register_String_Attributes;
Register_Initializer (Register_String_Attributes'Access);
end GNU.DB.SQLCLI.Desc;
|