File : oci-thick-string_bounded.adb
with OCI.Lib,OCI.Thread;
--with text_io;use text_io;
package body OCI.Thick.string_Bounded is
use lib;
function Get_Value(Var : Variable'Class) return String is
begin
if Is_Null(Var) then
raise NULL_VALUE;
else
return C.To_Ada(Var.Value);
end if;
end;
procedure Set_Value(Var : in out Variable; Value : String) is
Len : String_Size;
begin
Var.Indicator := 0;
if Value'Length>Var.Length then
raise Constraint_Error;
end if;
C.To_C(Value,Var.Value,Len);
end;
use type sb4;
procedure Bind(Stmt : Statement; Value : in out Variable; Name : String) is
rc : sword := OCIBindByName (
stmtp => OCIStmt(Stmt.Handle),
bindpp => Value.Bind'Access,
errhp => Thread.Error,
placeholder => C.To_C(Name),
placeh_len => Name'Length,
valuep => Value.Value'Address,
value_sz => Value.Value'Length,
dty => SQLT_STR,
indp => Value.Indicator'Access);
begin
Check_Error(rc);
end Bind;
procedure Bind(Stmt : Statement; Value : in out Variable; Position : Positive) is
rc : sword := OCIBindByPos (
stmtp => OCIStmt(Stmt.Handle),
bindpp => Value.Bind'Access,
errhp => Thread.Error,
Position => ub4(Position),
valuep => Value.Value'Address,
value_sz => Value.Value'Length,
dty => SQLT_STR,
indp => Value.Indicator'Access);
begin
Check_Error(rc);
end Bind;
procedure Define(Stmt : Statement; Value : in out Variable; Position : Positive) is
rc : sword := OCIDefineByPos (
stmtp => OCIStmt(Stmt.Handle),
defnpp => Value.Define'Access,
errhp => Thread.Error,
position => ub4(Position),
value => Value.Value'Address,
value_sz => Value.Value'Length,
dty => SQLT_STR,
indp => Value.Indicator'Access);
begin
Check_Error(rc);
end Define;
end OCI.Thick.string_Bounded;