comp.lang.ada
 help / color / mirror / Atom feed
* GNATCOM Exception
@ 2002-10-25  8:05 Anders Wirzenius
  0 siblings, 0 replies; only message in thread
From: Anders Wirzenius @ 2002-10-25  8:05 UTC (permalink / raw)


I have a peculiar GNATCOM behaviour when I try to use the function Execute
on an Oracle database

I get an exception with message "Bad variable type" when executing the
following statements:

declare
   SQL_Update_User_Data : Constant GWindows.GString :=
To_GString_From_String (
   "UPDATE EMPLOYEE " &
      "SET " &
      "EMP_ACCDOM_ID='" & This_ACCDOM & "', " &
      "EMP_MAIL='" & This_Mail & "', " &
      "EMP_UPDATE_BY=" & User_ID & ", " &
      "EMP_UPDATE_DATE=TO_DATE('" & HD.User.Today & "','dd.MM.YYYY') " &
      "WHERE EMP_ID = " & This_Row & " " &
      "AND TO_CHAR(emp_timestmp,'dd.mm.yyyy hh24:Mi:ss') = '" & Time_Stamp &
"'"
      );
begin
   Rows_Updated := Execute(DB_Control.Database, SQL_Update_User_Data);

The database record is updated, but I get the error message.
I manage to avoid the exception if I display a message box prior to the
Execute:

   Message_Box ("Update this record",
      "Update this record",
      Icon => Information_Icon);
   Rows_Updated := ...

How can I get rid of the error message in another way?

Anders



Below the code of the whole procedure:

      --
      -- Update the current record from bindings
      --
      procedure Update_Employee (
         Window : in out GWindows.Base.Base_Window_Type'Class
         ) is
         This_Row    : Constant String := Field_Value (DB_Control.Recordset,
"EMP_ID");
         Time_Stamp  : Constant String := Field_Value (DB_Control.Recordset,
"TIMESTMP");
         Last_Name   : Constant String := Text(Last_Name_Start);
         This_ACCDOM : Constant String := Text(EMP_ACCDOM_ID);
         This_Mail   : Constant String := Text(EMP_MAIL);
         User        : Constant String := HD.User.Get_User_Name;
         User_ID     : Constant String := HD.User.Get_User_Empp_ID(User);
         Rows_Updated: Natural := 0;
         SQL_Update_User_Data : Constant GWindows.GString :=
To_GString_From_String (
            "UPDATE EMPLOYEE " &
               "SET " &
               "EMP_ACCDOM_ID='" & This_ACCDOM & "', " &
               "EMP_MAIL='" & This_Mail & "', " &
               "EMP_UPDATE_BY=" & User_ID & ", " &
               "EMP_UPDATE_DATE=TO_DATE('" & HD.User.Today &
"','dd.MM.YYYY') " &
               "WHERE EMP_ID = " & This_Row & " " &
               "AND TO_CHAR(emp_timestmp,'dd.mm.yyyy hh24:Mi:ss') = '" &
Time_Stamp & "'"
               );
      begin
         -- Message_Box ("Update this record",
         --    "Update this record",
         --    Icon => Information_Icon);

         --
         -- Make an attempt to update the record.
         --
         Rows_Updated := Execute(DB_Control.Database, SQL_Update_User_Data);
         -- Message_Box ("Update attempted",
         --    "An attempt to update the row was made",
         --    Icon => Information_Icon);
         Requery_This_Record(Window, This_Row);

         --
         -- Ask user to redo if a concurrent update was made for the record.
         -- The Time_Stamp must be unchanged since entering this procedure.
         --
         if Rows_Updated = 0 then
            Message_Box ("Update Failed",
            "A concurrent update was made in the database, please redo your
update.",
            Icon => Information_Icon);
            Set_Selection(Last_Name_Start,1,Last_Name'Length);
            Replace_Selection(Last_Name_Start,Text(EMP_LAST_NAME));
            Requery_This_Record(Window, This_Row);
         end if;
      exception
         when others =>
            Message_Box ("Error",
                         To_GString_From_String
(GNATCOM.IErrorInfo.Get_IErrorInfo),
                         Icon => Error_Icon);
            Requery_This_Record(Window, This_Row);
      end Update_Employee;






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-25  8:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-25  8:05 GNATCOM Exception Anders Wirzenius

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox