Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data INSERT using stored procedure 1

Status
Not open for further replies.

reisende

Programmer
Mar 16, 2004
74
US
Hi everybody.

I have a stored procedure that doesn't appear to be working. Here's the juicy details.

I am trying to move data from a DBF file to an InterBase table with the following Delphi code:

Code:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
  prempl : string;
  last_name: string;
  first_name: string;
  clinic_id : string;
  pay_cycle : string;
  hourly : string;
begin
  db_prempl.First;

  while not db_prempl.Eof do
    begin
      prempl := db_premplprempl.AsString;
      last_name := db_prempllast.AsString;
      first_name := db_premplfirst.AsString;
      clinic_id := db_prempldeptid.AsString;
      pay_cycle := db_premplpaycycl.AsString;
      hourly := db_premplhourly.AsString;

      with IBStoredProc1 do
        begin
          ParamByName('PREMPL').AsString := prempl;
          ParamByName('LASTNAME').AsString := last_name;
          ParamByName('FIRSTNAME').AsString := first_name;
          ParamByName('CLINICID').AsString := clinic_id;
          ParamByName('PAYCYCLE').AsString := pay_cycle;
          ParamByName('HOURLY').AsString := hourly;
          ParamByName('HIREDATE').AsDate := db_premplhiredt.AsDateTime;

          ExecProc;
        end;
        
      db_prempl.Next;
    end;
  ShowMessage('Data Updated!');
end;

I've stepped through it and the loop runs correctly and it appears to execute the stored procedure. But when I check the table in IBConsole after running it there is no data!

Here is my stored procedure:

[tt]
CREATE PROCEDURE EMPL_DATA_MOVER
(
Prempl CHAR(9),
LastName CHAR(25),
FirstName CHAR(20),
ClinicId CHAR(6),
PayCycle CHAR(1),
Hourly CHAR(1),
HireDate DATE
)
AS
BEGIN
INSERT INTO MO_EMPL_INFO (PREMPL, EMPL_LAST, EMPL_FIRST, DEPT_ID, PAY_CYCLE, HOURLY, HIRE_DATE)
VALUES:)Prempl, :LastName, :FirstName, :ClinicId, :payCycle, :Hourly, :HireDate);
END^
[/tt]

I must admit this is my first time using a stored proc in Delphi, so if I'm missing something, please let me know.

Thanks.
 
Hi,

You should use an IBTransaction followed by a commit.

IBTransaction1.Commit;

rgds,
Ryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top