Home > Back-end >  How to call in Delphi SQL stored procedure????? Database of curriculum design, haven't learned
How to call in Delphi SQL stored procedure????? Database of curriculum design, haven't learned

Time:09-20

SQL server in the stored procedure
- add products stored procedure
The Create proc up_insert_proc
@ product char (20),
@ product name char (100),
@ unit price money,
@ specifications float,
@ inventory int
As
The begin
If the exists (select * from products where product=# @ #)
The begin
The begin
Print 'the product already exists, has the same data, direct return value
End
The begin
Update product set inventory=@ stocks + stocks where product=# @ #
Print 'update the product information, have the primary key of the same data, update processing
End
End
The else
The begin
Insert into products (product number, product name, price, specifications, inventory) values (@ product Numbers, @ product name, @ monovalent, @ specifications, @ inventories)
Print 'add product success - there is no the same data, insert processing
End
End
Go


Delphi call a stored procedure code
Procedure TForm3. Button1Click (Sender: TObject);
Var
Ret: integer;
The begin
With ADOStoredProc1 do
The begin
The Close;
ProcedureName:='up_inset_proc';
The Parameters. The Clear;
The Parameters. Refresh;
The Parameters. ParamByName (' @ product Numbers). The Value:=Edit3. Text;
The Parameters. ParamByName (' @ product name). The Value:=Edit4) text;
The Parameters. ParamByName (' @ unit price). The Value:=Edit5. Text;
The Parameters. ParamByName (' @ 'specifications). Value:=Edit6. Text;
The Parameters. ParamByName (' @ inventories). The Value:=Edit7. Text;
ExecProc;
Ret:=the Parameters ParamByName (' @ return_value). The Value;
end;
end;







CodePudding user response:

Procedure TForm3. Button1Click (Sender: TObject);
Var
Ret: integer;
The begin
With ADOStoredProc1 do
The begin
The Close;
ProcedureName:='up_inset_proc';
The Parameters. The Clear;
The Parameters. Refresh;
The Parameters. The Params [0]. Value:=Edit3. Text;
The Parameters. The Params [1]. The Value:=Edit4) text;
The Parameters. The Params [2]. The Value:=Edit5. Text;
The Parameters. The Params [3]. The Value:=Edit6. Text;
The Parameters. The Params [4]. The Value:=Edit7. Text;
ExecProc;
Ret:=Parameters. Params [5]. The Value;
end;
end;

CodePudding user response:

The parameters of the parameter @ product number is not found, you just defined in SQL, not defined in D, so I couldn't find, by reading the parameter of the subscript to find,

CodePudding user response:

The building Lord error message is very clear, @ product name is not found,

CodePudding user response:

Found no parameter @ product number was not found, whether the parameter is not defined
  • Related