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 
 
SQL Server

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



Joined: 19 Nov 2006
Posts: 26

PostPosted: Sun Nov 19, 2006 17:45    Post subject: SQL Server Reply with quote

I am using SQL Server. The first thing I had to change the create table definition to.

SQLExecDirect("CREATE TABLE pwobjdata (player varchar(64) NOT NULL default '~',"+
"tag varchar(64) NOT NULL default '~',"+
"name varchar(64) NOT NULL default '~',"+
"val text,"+
"expire int default NULL,"+
"last datetime NOT NULL default CURRENT_TIMESTAMP,"+
"PRIMARY KEY (player,tag,name))");

This looks similar apart from the 'last' field which I changed from timestamp as default on timestamp is invalid. Also int(11) isinavlid so I changed this to int. Finally I changed blob to text not sure if this is right.

The first test in the sample mod worked fine the second one gives.

INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_0',~s,0)

~s is not valid for text so the insert fails. Can you tell me what I need to do.

Thanks =)
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sun Nov 19, 2006 19:47    Post subject: Reply with quote

Are you using the function in aps_demo ? Since the statement should be slightly different:

Code:
sSQL = "INSERT INTO " + sTable + " (player,tag,name,val,expire) VALUES" +
            "('" + sPlayer + "','" + sTag + "','" + sVarName + "',%s," + IntToString(iExpiration) + ")";


It should be %s, not ~s. I take it you are using the ODBC driver ?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
lostdreamz



Joined: 19 Nov 2006
Posts: 26

PostPosted: Sun Nov 19, 2006 19:51    Post subject: Reply with quote

Yes I havnt changed anything from the demo mod that is what gets printed out in the odbc log as the query that was sent to the database. It loks like the %s is being changed to ~s somehow. Not sure what to do.
Back to top
View user's profile Send private message
lostdreamz



Joined: 19 Nov 2006
Posts: 26

PostPosted: Sun Nov 19, 2006 20:30    Post subject: Reply with quote

Myabe this is just a problem with the ODBC plugin. I am not sure why or how but now the rows are populated with data. Unfortunately the get still fails since the size of the blob is > 1048576 bytes. I will try setting it to varchar(1048576)
Back to top
View user's profile Send private message
lostdreamz



Joined: 19 Nov 2006
Posts: 26

PostPosted: Sun Nov 19, 2006 21:12    Post subject: Reply with quote

o Got request (scorco): SELECT val FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: Critical error - object too large (>1048576 bytes).

! SQL Error: [Microsoft][ODBC SQL Server Driver][SQL Server]The size (1048576) given to the column 'val' exceeds the maximum allowed for any data type (8000).

arghh I am so cofused now tried setting this to varchar(8000) and now I dont get any rows again
Back to top
View user's profile Send private message
lostdreamz



Joined: 19 Nov 2006
Posts: 26

PostPosted: Sun Nov 19, 2006 21:32    Post subject: Reply with quote

The insert doesnt work unless you specify image datatype for val and if you do you get the size error. There must be a solution Confused
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Mon Nov 20, 2006 0:19    Post subject: Reply with quote

lostdreamz wrote:
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: Critical error - object too large (>1048576 bytes).

! SQL Error: [Microsoft][ODBC SQL Server Driver][SQL Server]The size (1048576) given to the column 'val' exceeds the maximum allowed for any data type (8000).

arghh I am so cofused now tried setting this to varchar(8000) and now I dont get any rows again


This is a known issue...SQLServer hardcoded cap.
use VARBINARY(8000) for your object. (varchar will truncate at the first #0 byte)

For the SQLServer plugin (when it gets written*) objects greater than 8000 bytes return a -1 (0xFFFFFFFF) for the data length. At this point the code needs to read the first page (8000bytes). The first few bytes of this will signify the real length of the data. <either 4 of 8, I'll have to check the doco again> before fetching the remaining data (page at a time).

*I'm assuming you're trying with NWN2

--and besides database support isn't enabled yet - wait for the 1.03 patch

Cheers
Gryphyn
Back to top
View user's profile Send private message
lostdreamz



Joined: 19 Nov 2006
Posts: 26

PostPosted: Mon Nov 20, 2006 0:27    Post subject: Reply with quote

Thank you I will try that. Actually I am trying this on my persistent world with NWN before creating a new persistent world on NWN 2. I reasoned if I got it working with NWN 1 first I would have more success with NWN 2.

I appreciate the fact that you do care for the people who use your software. Its nice to get such helpful replies. Is there any ETA for ODBC or SQLServer support for NWN 2.
Back to top
View user's profile Send private message
lostdreamz



Joined: 19 Nov 2006
Posts: 26

PostPosted: Mon Nov 20, 2006 0:37    Post subject: Reply with quote

Thank you, thank you, thank you so much

For anyone like me who uses SqlServer this is the create table statement that actually works for persistent objects.

SQLExecDirect("CREATE TABLE pwobjdata (player varchar(64) NOT NULL default '~',"+
"tag varchar(64) NOT NULL default '~',"+
"name varchar(64) NOT NULL default '~',"+
"val varbinary(8000),"+
"expire int default NULL,"+
"last datetime NOT NULL default CURRENT_TIMESTAMP,"+
"PRIMARY KEY (player,tag,name))");

Rebecca Casidy (owner - World of Desire PW)
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Mon Nov 20, 2006 1:42    Post subject: Reply with quote

lostdreamz wrote:
Thank you, thank you, thank you so much

For anyone like me who uses SqlServer this is the create table statement that actually works for persistent objects.

SQLExecDirect("CREATE TABLE pwobjdata (player varchar(64) NOT NULL default '~',"+
"tag varchar(64) NOT NULL default '~',"+
"name varchar(64) NOT NULL default '~',"+
"val varbinary(8000),"+
"expire int default NULL,"+
"last datetime NOT NULL default CURRENT_TIMESTAMP,"+
"PRIMARY KEY (player,tag,name))");

Rebecca Casidy (owner - World of Desire PW)


better yet make it "val varbinary(7700),"
this will reduce your read/write times (all the data fits into the same page)

Cheers
Gryphyn
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sat Apr 28, 2007 2:07    Post subject: Reply with quote

lostdreamz wrote:
Thank you I will try that. Actually I am trying this on my persistent world with NWN before creating a new persistent world on NWN 2. I reasoned if I got it working with NWN 1 first I would have more success with NWN 2.

I appreciate the fact that you do care for the people who use your software. Its nice to get such helpful replies. Is there any ETA for ODBC or SQLServer support for NWN 2.


Now! NWNX4 SQLServer plugin

Cheers
Gryphyn
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