ALM Site Administration API Type Library
RunQuery Method
Description
Runs the SQL statement on the project database and retrieves results.
Syntax
Visual Basic
Public Function RunQuery( _
   ByVal DomainName As String, _
   ByVal ProjectName As String, _
   ByVal SqlQuery As String, _
   ByVal MaxRecords As Long, _
   ByVal FromRecord As Long _
) As String
Parameters
DomainName
The domain name.
ProjectName
The project name.
SqlQuery
The SQL statement.
MaxRecords
The maximum number of records to return.
FromRecord

Return records from this record to the end of the record set.  For example, if FromRecord is 8, records 0 to 7 are not returned. All records from the ninth (index = 8) on are returned.

Return Type
On success, returns an XML string containing selected records according to the SQL statement. ColumnLables show all columns, numbers, and names. DataRows show all the rows that return results. For each row that returns results, only the columns containing data are returned.
Return Value Details

In both <ColumnLables> and <Rows>, the tag <_n> indicates the column number in the SQL results.

In <ColumnLables>, the text of the element is the name of the column.

In <Rows>, the text of the element is the value of the column.

Return Value Example
<RunQuery>
    <ColumnLables>
            <TDXItem>
                <_0>RQ_REQ_ID</_0>
                <_1>RQ_FATHER_ID</_1>
                <_2>RQ_ORDER_ID</_2>
                <_3>RQ_ISTEMPLATE</_3>
                <_4>RQ_REQ_COMMENT</_4>
                <_5>RQ_REQ_REVIEWED</_5>
                <_6>RQ_REQ_PATH</_6>
                <_7>RQ_REQ_STATUS</_7>
                <_8>RQ_REQ_PRIORITY</_8>
                <_9>RQ_REQ_TYPE</_9>
                <_10>RQ_REQ_PRODUCT</_10>
                <_11>RQ_REQ_NAME</_11>
                <_12>RQ_REQ_AUTHOR</_12>
                <_13>RQ_USER_01</_13>
                <_14>RQ_USER_02</_14>
                <_15>RQ_USER_03</_15>
                <_16>RQ_USER_04</_16>
                <_17>RQ_USER_05</_17>
                <_18>RQ_USER_06</_18>
                <_19>RQ_USER_07</_19>
                <_20>RQ_USER_08</_20>
                <_21>RQ_USER_09</_21>
                <_22>RQ_USER_10</_22>
                <_23>RQ_USER_11</_23>
                <_24>RQ_USER_12</_24>
                <_25>RQ_REQ_VER_STAMP</_25>
                <_26>RQ_ATTACHMENT</_26>
                <_27>RQ_REQ_DATE</_27>
                <_28>RQ_REQ_TIME</_28>
                <_29>RQ_NO_OF_SONS</_29>
                <_30>RQ_IS_FOLDER</_30>
                <_31>RQ_VTS</_31>
                <_32>RQ_USER_13</_32>
                <_33>RQ_USER_14</_33>
                <_34>RQ_USER_15</_34>
                <_35>RQ_USER_16</_35>
                <_36>RQ_USER_17</_36>
                <_37>RQ_USER_18</_37>
                <_38>RQ_USER_19</_38>
                <_39>RQ_USER_20</_39>
                <_40>RQ_USER_21</_40>
                <_41>RQ_USER_22</_41>
                <_42>RQ_USER_23</_42>
                <_43>RQ_USER_24</_43>
            </TDXItem>
    </ColumnLables>
    <Rows>
            <TDXItem>
                <_0>1</_0>
                <_1>-1</_1>
                <_2>1</_2>
                <_5>Not Reviewed</_5>
                <_6>AAA</_6>
                <_7>Not Covered</_7>
                <_8>3-High</_8>
                <_11>Requirement 1</_11>
                <_12>admin</_12>
                <_25>5</_25>
                <_27>8/26/2002</_27>
                <_28>09:32:27</_28>
                <_29>0</_29>
                <_30>Y</_30>
                <_31>2002-09-02 14:15:03</_31>
            </TDXItem>
            <TDXItem>
                <_0>2</_0>
                <_1>-1</_1>
                <_2>2</_2>
                <_5>Not Reviewed</_5>
                <_6>AAB</_6>
                <_7>Not Covered</_7>
                <_11>Requirement 2</_11>
                <_12>admin</_12>
                <_25>3</_25>
                <_27>9/2/2002</_27>
                <_28>14:13:42</_28>
                <_29>0</_29>
                <_30>N</_30>
                <_31>2002-09-02 14:13:57</_31>
                </TDXItem>
    </Rows>
</RunQuery>
Example
Private Sub RunQuery()

'The following Visual Basic example runs an SQL statement
' showing the first 25 row results.
    Dim sDomainName As String
    Dim sProjectName As String
    Dim sSql As String
    Dim sReply As String

    On Error GoTo err
    sDomainName = "MyDomain"
    sProjectName = "MyProject"
    sSql = "SELECT * FROM REQ"
   
    sReply = m_SAClient.RunQuery _
        (sDomainName, sProjectName, sSql, 25, 0)

    MsgBox sReply
    Exit Sub
err:
    MsgBox "Program failed:" + err.Description
End Sub
See Also