Difference between revisions of "SqlStep"

From NWN Lexicon
Jump to: navigation, search
(corrected function return type)
Line 2: Line 2:
 
Executes the given query and fetches a row.
 
Executes the given query and fetches a row.
 
<nwscript>
 
<nwscript>
void SqlStep(
+
int SqlStep(
 
     sqlquery sqlQuery
 
     sqlquery sqlQuery
 
);
 
);

Revision as of 18:09, 18 January 2021

Nwnee logo.jpg Note: This article documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.

Executes the given query and fetches a row.

int SqlStep(
    sqlquery sqlQuery
);

Parameters

sqlQuery
An already prepared SQL query

Description

Executes the given query and fetches a row; returning TRUE if row data was made available; FALSE otherwise. Note that this will return FALSE even if the query ran successfully but did not return data.

You need to call SqlPrepareQueryCampaign or SqlPrepareQueryObject and potentially SqlBind* functions before calling this.

Remarks

This is required to execute any SQL query, even if there is no "true data" to retrieve, such as when creating a table. Use SqlGetError to retrieve any issues running the query.

Version

This function was added in 1.80.8193.14 of NWN:EE.

Example

    sqlquery n = SqlPrepareQueryObject(GetFirstPC(), "select widget from widgets;");
    while (SqlStep(n))
    {
        SendMessageToPC(GetFirstPC(), "Found widget: " + SqlGetString(n, 0));
    }

See Also

functions:

SqlPrepareQueryCampaign SqlPrepareQueryObject SqlBindInt SqlBindFloat SqlBindString SqlBindVector SqlBindObject