Skip to content

SQLGetMessage - cSQLStatement

Get informational messages (if any).

Type: Function
Return Data Type: String

Parameters

Parameter Type Description
iMessageNum Integer Message number

Syntax

Function SQLGetMessage Integer iMessageNum Returns String

Call Example

Get SQLGetMessage iMessageNum to StringVariable

Description

Some statements generate additional informational messages. These messages are stored when the statements execute. You can get the messages by calling SQLGetMessage. To determine the number of messages you can use the statement attribute SQLSTMTATTRIB_NUMMESSAGES (see SQLStmtAttribute).

Sample

The example below (for SQL Server) executes the statement "RESTORE VERIFYONLY"

Procedure RestoreVerify
    Handle hoSQL
    Handle hdbc
    Handle hstmt
    String sMessage
    Integer iNumMessages
    Integer iCount

    Get Create U_cSQLHandleManager To hoSQL
    If (hoSQL <> 0) Begin
        Get SQLConnect Of hoSQL "MSSQLDRV" ;
            "SERVER=(local);Trusted_Connection=yes;DATABASE=Sample" ;
                To hdbc
        If (hdbc <> 0) Begin
            Get SQLOpen Of hdbc To hstmt
            If (hstmt <> 0) Begin
                Send SQLExecDirect Of hstmt ;
                    "Restore verifyonly from disk = 'C:\BCKUP\SampleBckup' with File = 1"
                Get SQLStmtAttribute of hstmt ;
                    SQLSTMTATTRIB_NUMMESSAGES To iNumMessages
                For iCount From 1 To iNumMessages
                    Get SQLGetMessage Of hstmt iCount To sMessage
                    Showln "Message = " ;
                        (RemoveComponentIdentifier(hstmt, sMessage))
                Loop
                Send SQLClose Of hstmt
            End
            Send SQLDisconnect Of hdbc
        End
        Send Destroy Of hoSQL
    End
End_Procedure // RestoreVerify

Return Value

Returns informational message (if any).