SQLITE Query Successful command line faile RR
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
SQLITE Query Successful command line faile RR
This query is successful from the command line but fails with revdberr. Any suggestions?
SELECT strftime('%s','now','localtime');
SELECT strftime('%s','now','localtime');
SQLite output.
SQLite version 3.6.19
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> SELECT datetime('now');
2009-10-30 20:26:17
sqlite> SELECT datetime('now', 'localtime');
2009-10-30 15:26:50
sqlite> SELECT strftime('%s','now','localtime');
1256916457
sqlite>
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> SELECT datetime('now');
2009-10-30 20:26:17
sqlite> SELECT datetime('now', 'localtime');
2009-10-30 15:26:50
sqlite> SELECT strftime('%s','now','localtime');
1256916457
sqlite>
Transcript.
on mouseUp
local _db
local _now
--
--In memory only no database file needed here
--
put revOpenDatabase("sqlite",,,,,,,) into _db
put revDataFromQuery(comma,return,"SELECT datetime('now');") into _now
revCloseDatabase _db
end mouseUp
local _db
local _now
--
--In memory only no database file needed here
--
put revOpenDatabase("sqlite",,,,,,,) into _db
put revDataFromQuery(comma,return,"SELECT datetime('now');") into _now
revCloseDatabase _db
end mouseUp
Kevin,
In
revOpenDatabase("sqlite",,,,,,,)
you have to specify not only the type of database, but also the database name or file path and possibly a user name and password.
Note that the command line version and the Revolution version do not interact in any way. The two have nothing to do with each other, except that both of them were compiled using the same library.
Best,
Mark
In
revOpenDatabase("sqlite",,,,,,,)
you have to specify not only the type of database, but also the database name or file path and possibly a user name and password.
Note that the command line version and the Revolution version do not interact in any way. The two have nothing to do with each other, except that both of them were compiled using the same library.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Example command line
C:\SQLite\sqlite-3_6_19>sqlite3.exe
SQLite version 3.6.19
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> SELECT datetime('now' 'utc');
SQL error: near "'utc'": syntax error
sqlite> SELECT datetime('now','utc');
2009-10-31 03:22:24
sqlite>
SQLite version 3.6.19
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> SELECT datetime('now' 'utc');
SQL error: near "'utc'": syntax error
sqlite> SELECT datetime('now','utc');
2009-10-31 03:22:24
sqlite>
Example RB Linux
Function LocalToUTC( ByVal As Date ) As Date
Dim oDb As New REALSQLDatabase
Dim iOffset As Integer
Dim oError As New Date
oError.TotalSeconds = 0
If False = oDb.Connect Then
Dim eNoTimeService As New RuntimeException
eNoTimeService.Message = "Missing SQL Time subsystem cannot initialize"
Raise eNoTimeService
End If
Dim sSQL As String
sSQL = "SELECT strftime(""%s&"", 'now', 'localtime') - strftime(""%s"", 'now')"
Dim oRs As Recordset
oRs = oDb.SQLSelect(sSQL)
If Nil <> oRs Then
iOffset = oRs.IdxField(1).IntegerValue
o.TotalSeconds = o.TotalSeconds - iOffset
Return o
End If
Return oError
End Function
Dim oDb As New REALSQLDatabase
Dim iOffset As Integer
Dim oError As New Date
oError.TotalSeconds = 0
If False = oDb.Connect Then
Dim eNoTimeService As New RuntimeException
eNoTimeService.Message = "Missing SQL Time subsystem cannot initialize"
Raise eNoTimeService
End If
Dim sSQL As String
sSQL = "SELECT strftime(""%s&"", 'now', 'localtime') - strftime(""%s"", 'now')"
Dim oRs As Recordset
oRs = oDb.SQLSelect(sSQL)
If Nil <> oRs Then
iOffset = oRs.IdxField(1).IntegerValue
o.TotalSeconds = o.TotalSeconds - iOffset
Return o
End If
Return oError
End Function
Kevin,
I'm sorry that you are unhappy with the solution I give you, but it is either that or nothing.
Best,
Mark
I'm sorry that you are unhappy with the solution I give you, but it is either that or nothing.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Past example using deatetime() query still fails.
This is from the example (SQLite Sampler.rev) only altered the SQL. Can create tables and insert data. Just cannot see to execute any SQLite date time functions.
on mouseUp
local _db
local _now
put revOpenDatabase("sqlite","AppReg3.db",,,,,,) into _db
put revDataFromQuery(comma,return,"SELECT datetime('now','utc');") into _now
revCloseDatabase _db
end mouseUp
on mouseUp
local _db
local _now
put revOpenDatabase("sqlite","AppReg3.db",,,,,,) into _db
put revDataFromQuery(comma,return,"SELECT datetime('now','utc');") into _now
revCloseDatabase _db
end mouseUp
Miss the small things
put revDataFromQuery(comma,return,"SELECT datetime('now');") into _now
Forgot the handle to the database.
Forgot the handle to the database.
The answer for those following...
on mouseUp
local _db
local _now
put revOpenDatabase("sqlite",,,,,,,) into _db
put revDataFromQuery(comma,return,_db,"SELECT datetime('now','utc');") into _now
revCloseDatabase _db
end mouseUp
local _db
local _now
put revOpenDatabase("sqlite",,,,,,,) into _db
put revDataFromQuery(comma,return,_db,"SELECT datetime('now','utc');") into _now
revCloseDatabase _db
end mouseUp