parent
441cacf70f
commit
8d1a7db6ea
1 changed files with 12 additions and 4 deletions
|
|
@ -441,8 +441,12 @@ proc getValue*(db: DbConn, query: SqlQuery,
|
||||||
## executes the query and returns the first column of the first row of the
|
## executes the query and returns the first column of the first row of the
|
||||||
## result dataset. Returns "" if the dataset contains no rows or the database
|
## result dataset. Returns "" if the dataset contains no rows or the database
|
||||||
## value is NULL.
|
## value is NULL.
|
||||||
var x = pqgetvalue(setupQuery(db, query, args), 0, 0)
|
var res = setupQuery(db, query, args)
|
||||||
result = if isNil(x): "" else: $x
|
if pqntuples(res) > 0:
|
||||||
|
var x = pqgetvalue(res, 0, 0)
|
||||||
|
result = if isNil(x): "" else: $x
|
||||||
|
else:
|
||||||
|
result = ""
|
||||||
|
|
||||||
proc getValue*(db: DbConn, stmtName: SqlPrepared,
|
proc getValue*(db: DbConn, stmtName: SqlPrepared,
|
||||||
args: varargs[string, `$`]): string {.
|
args: varargs[string, `$`]): string {.
|
||||||
|
|
@ -450,8 +454,12 @@ proc getValue*(db: DbConn, stmtName: SqlPrepared,
|
||||||
## executes the query and returns the first column of the first row of the
|
## executes the query and returns the first column of the first row of the
|
||||||
## result dataset. Returns "" if the dataset contains no rows or the database
|
## result dataset. Returns "" if the dataset contains no rows or the database
|
||||||
## value is NULL.
|
## value is NULL.
|
||||||
var x = pqgetvalue(setupQuery(db, stmtName, args), 0, 0)
|
var res = setupQuery(db, stmtName, args)
|
||||||
result = if isNil(x): "" else: $x
|
if pqntuples(res) > 0:
|
||||||
|
var x = pqgetvalue(res, 0, 0)
|
||||||
|
result = if isNil(x): "" else: $x
|
||||||
|
else:
|
||||||
|
result = ""
|
||||||
|
|
||||||
proc tryInsertID*(db: DbConn, query: SqlQuery,
|
proc tryInsertID*(db: DbConn, query: SqlQuery,
|
||||||
args: varargs[string, `$`]): int64 {.
|
args: varargs[string, `$`]): int64 {.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue