rtslink.com
Home / RTSlink DLL / More on Tally Integration / SQL-DELETE

Using SQL-DELETE to delete Master records in Tally Software


RTSlink DLL v1.9 provides a new function SQLDelete() that allows you to use SQL-DELETE statements to delete records in Tally Software.

Master records in Tally software are uniquely identified  based on the Master-Name itself. Hence, to  delete any Master record in Tally Software, you need to specify the Table-Name and the Key-field-value.

Syntax:-
SQLDelete( <strTableName> , <strKeyfieldValue> );

Example:-
SQLDelete("Ledger","Advertisement Expenses");

Remarks:-
a) The above statement deletes the Ledger "Advertisement Expenses"
b) Other valid Table names are "Group", "Ledger", "StockGroup", "Unit", "Godown", "StockCategory"  "StockItem", "CostCentre", "CostCategory" etc.


Using SQL-DELETE to Vouchers in Tally Software


To uniquely identify any Voucher in Tally, you need to provide the following information:-

a) Voucher Date
b) Voucher Type
c) Voucher Number (or Voucher Reference or any other Voucher-field)

Syntax:-
SQLDelete("Voucher", <strKeyValue>);

Example:-
SQLDelete("Voucher","Date='01-04-2007'  VoucherTypeName='Payment'  TagName='VoucherNumber'  TagValue='1'");

Remarks:-
The above statement deletes Voucher having VoucherNumber as 1 Date as 01-04-2007 and VoucherType as Payment.


C Declaration for SQLDelete() function


FunctionName  :-    SQLDelete()
C declaration    :-    int __stdcall SQLDelete(LPSTR strTableName, LPSTR strKeyValue);
Return Value    :-    Returns 0 on success, otherwise error-code.


Using SQLDelete() in VFP


A sample VFP (Visual Foxpro 6) program is given underneath to illustrate the use of SQLDelete() function

Visual Foxpro Code:-
Declare Integer SQLDelete in RTSlink.dll String,String
Declare String GetLastErrorMessage in RTSLink.dll
Declare Integer Open in RTSlink.dll

Private nResult, cErrorMsg

Do while .t.
    *Connect to the Tally software. Returns zero if successful
 
  nResult=Open()

    if nResult=0 
        *Assuming that a Ledger called Advertisement Expenses EXISTS in your company
        nResult=SQLDelete ("Ledger","Advertisement Expenses")

        IF nResult != 0
            cErrorMsg=GetLastErrorMessage()

            *You may provide an Error-handling routine here
 
          =MessageBox(cErrorMsg,0,"Error")
        else
            * =====TO DO ======
            *Use XML DOM to Retreive the Tally response from RESPONSE.LOG file
        Endif
    Else
        *If Tally software is NOT running
        cErrorMsg=GetLastErrorMessage()

        *You may provide an Error-handling routine here
        =MessageBox(cErrorMsg,0,"Error")
    Endif
    exit
Enddo

*Unload the DLL from memory
Clear DLLs


Tags:

Tally Integration, Tally Software
Tally is a registered trademark of Tally Solutions FZ LLC.

Valid HTML 4.01 Transitional