Scripting/Squirrel/Functions/GetSQLNextRow: Difference between revisions
Jump to navigation
Jump to search
This wiki is using an old backup from 2020
Some information may be old/missing
No edit summary |
m (Cleanup example code) |
||
(One intermediate revision by one other user not shown) | |||
Line 11: | Line 11: | ||
<source lang="squirrel"> | <source lang="squirrel"> | ||
function GetAlias( uniqueid ) | function GetAlias(uniqueid) { | ||
// Select all the rows that has the same uniqueid as the entered value. | |||
local query = QuerySQL(sdb, "SELECT namecolumn FROM tablename WHERE uniqueidcolumn = '" + uniqueid + "'"); | |||
// Store the first name. | |||
local string = GetSQLColumnData(query, 0); | |||
== | // Get the second name when the loop starts and continue getting the next row after that until no rows are left. | ||
while (GetSQLNextRow(query)) { | |||
string += ", " + GetSQLColumnData(query, 0); | |||
} | |||
string += "."; | |||
// Return the string containing the aliases. | |||
return string; | |||
} | |||
</source> | |||
== Related Functions == | == Related Functions == |
Latest revision as of 10:13, 26 April 2019
Calling GetSQLNextRow switches from the current row in a query to the next row, which allows you to read from that row with GetSQLColumnData.
Syntax
function GetSQLNextRow( query )
Arguments
- Query - A reference to the query that was previously executed.
Example
function GetAlias(uniqueid) {
// Select all the rows that has the same uniqueid as the entered value.
local query = QuerySQL(sdb, "SELECT namecolumn FROM tablename WHERE uniqueidcolumn = '" + uniqueid + "'");
// Store the first name.
local string = GetSQLColumnData(query, 0);
// Get the second name when the loop starts and continue getting the next row after that until no rows are left.
while (GetSQLNextRow(query)) {
string += ", " + GetSQLColumnData(query, 0);
}
string += ".";
// Return the string containing the aliases.
return string;
}