logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
CURRENT_TIMESTAMP not working for SQLite?

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
pethrowilo



Joined: 21 Dec 2014
Posts: 7
Location: China

PostPosted: Sun Dec 21, 2014 20:03    Post subject: CURRENT_TIMESTAMP not working for SQLite? Reply with quote


This was what I get, and:
Code:
CREATE TABLE server_main (
player varchar(64) NOT NULL default '~',
tag varchar(64) NOT NULL default '~',
name varchar(64) NOT NULL default '~',
val text,
expire int(11) default NULL,
last timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (player,tag,name)
)

This was what I trying to do.

Changing CURRENT_TIMESTAMP to (CURRENT_TIMESTAMP) would result nothing created.
So... must I switch to MySQL... Embarassed
Back to top
View user's profile Send private message
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Mon Dec 22, 2014 22:56    Post subject: Reply with quote

It honestly looks like you're inserting it as a string. IE:

Code:
INSERT INTO server_main (player,tag,name,val,expire,last)VALUE('player','tag','name','val','0','CURRENT_TIMESTAMP')


If you want it to insert the default value then exclude the column or run the above without the quotes around CURRENT_TIMESTAMP:

Code:
INSERT INTO server_main (player,tag,name,val,expire)VALUES('player','tag','name','val','0')

_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
pethrowilo



Joined: 21 Dec 2014
Posts: 7
Location: China

PostPosted: Tue Dec 23, 2014 19:39    Post subject: Reply with quote

Thank you for your reply Terra Very Happy

Yes I know it seems like that.
But in fact there were no quotes included around it.
It works fine in MySQL, but not so smoothly in SQLite

Code:
// Set oObject's persistent string variable sVarName to sValue
// Optional parameters:
// iExpiration: Number of days the persistent variable should be kept in database (default: 0=forever)
// sTable: Name of the table where variable should be stored (default: pwdata)
void SetPersistentString(object oObject, string sVarName, string sValue, int iExpiration = 0, string sTable = "pwdata");


I was using this function in aps_include to save some one-time mark to my database. This should be quite simple.
Table creation outside NWN would be alright, but in-game creation with
Code:
// Execute statement in sSQL
void SQLExecDirect(string sSQL);

works strangely.

I recall forgetting to call
Code:
// Setup placeholders for ODBC requests and responses
void SQLInit();

before table creation, would that affect SQLExecDirect()?

I am inserting time data manually now anyway.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group