Function executeSql

  • Execute arbitrary LabKey SQL. For more information, see the LabKey SQL Reference.

    Examples

    Example, from the Reagent Request Confirmation Tutorial and Demo:

    // This snippet extracts a table of UserID, TotalRequests and
    // TotalQuantity from the "Reagent Requests" list.
    // Upon success, the writeTotals function (not included here) uses the
    // returned data object to display total requests and total quantities.

    LABKEY.Query.executeSql({
    containerPath: 'home/Study/demo/guestaccess',
    schemaName: 'lists',
    sql: 'SELECT "Reagent Requests".UserID AS UserID, \
    Count("Reagent Requests".UserID) AS TotalRequests, \
    Sum("Reagent Requests".Quantity) AS TotalQuantity \
    FROM "Reagent Requests" Group BY "Reagent Requests".UserID',
    success: writeTotals
    });

    Parameters

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

Generated using TypeDoc