Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Using SQL procedures to control insert, update, delete

I have procedure in my database that control inserts, update, and deletes.
How do I preform inserts, updates and deletes from Delphi 5 with the procedures. Has anyone do it this way before?

Comments

  • hhcamiglahhcamigla Member Posts: 31
    First of all I want to know what kind of SQL server you are using
    if you are using MS SQL try this sample code.

    //in you database you have this procedure
    create Procedure UpdateTable( @cSearh char(5), @cValue Char(10)) as
    UPDATE ITMSLS SET ITM_DESC=@CVALUE WHERE ITM_CODE=@CSEARH


    //then try this coding in deplhi
    procedure TForm1.Button1Click( Sender );
    var cSearchKey,
    cNewValue : String;
    begin

    if ADOQuery1.Active then ADOQuery1.Close;
    ADOQuery1.SQL.Clear;
    ADOQuery1.SQL.Add('EXEC UPDATETABLE '+#39+cSearchKey+#39+','+#39+cNewValue+#39);
    ADOQuery1.ExecSQL;

    end;

    I hope this will help you

  • Jerry@WGJerry@WG Member Posts: 17
    I am using Pervasive.SQL (not by choice I'm stuck with it for now).
    It shouldn't really mater what SQL server I'm using. It should be able to work with any server and I need it to be portable.

    My first question was vague because I was in a hurry so I will be more specific now. My app has a query that pulls together data from several tables and display it for the users. The user needs to be able to edit this data and save it. Since it is a multi table query it can't be edited directly nor do I want them to be edited directly. The SQL procedures in the database ensure that the data is being correctly edited and logging changes to some field.

    So what I need to be able to do is use the procedure to update the data and keep the dataset in sync. I don't have ADO support. I can use TQuerys and TstoredProcs. I would use TUpdateSQL which looks like the best options, but it doesn't seem to allow for feedback from the procedures. Some fields have default values so when a new record is inserted I need the default values to appear in the dataset.

    I hope I all that makes sense.

    : First of all I want to know what kind of SQL server you are using
    : if you are using MS SQL try this sample code.
    :
    : //in you database you have this procedure
    : create Procedure UpdateTable( @cSearh char(5), @cValue Char(10)) as
    : UPDATE ITMSLS SET ITM_DESC=@CVALUE WHERE ITM_CODE=@CSEARH
    :
    :
    : //then try this coding in deplhi
    : procedure TForm1.Button1Click( Sender );
    : var cSearchKey,
    : cNewValue : String;
    : begin
    :
    : if ADOQuery1.Active then ADOQuery1.Close;
    : ADOQuery1.SQL.Clear;
    : ADOQuery1.SQL.Add('EXEC UPDATETABLE '+#39+cSearchKey+#39+','+#39+cNewValue+#39);
    : ADOQuery1.ExecSQL;
    :
    : end;
    :
    : I hope this will help you
    :
    :

  • Justin BibJustin Bib USAMember Posts: 0

    _ [ http://forcoder.org ] free video tutorials and ebooks about \ Swift C++ R Scratch PHP Ruby Java Visual Basic .NET Assembly JavaScript Python Visual Basic C Delphi Perl PL/SQL Objective-C Go MATLAB C# Scheme ABAP Kotlin Alice VBScript Rust Lua Bash FoxPro ML Transact-SQL Crystal D Hack Prolog Dart Apex Logo Erlang Lisp Clojure Julia Ada Fortran Scala F# SAS Awk COBOL LabVIEW \ ________

Sign In or Register to comment.