View previous topic :: View next topic |
Author |
Message |
lostdreamz
Joined: 19 Nov 2006 Posts: 26
|
Posted: Sun Nov 19, 2006 17:45 Post subject: SQL Server |
|
|
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 |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Sun Nov 19, 2006 19:47 Post subject: |
|
|
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 |
|
|
lostdreamz
Joined: 19 Nov 2006 Posts: 26
|
Posted: Sun Nov 19, 2006 19:51 Post subject: |
|
|
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 |
|
|
lostdreamz
Joined: 19 Nov 2006 Posts: 26
|
Posted: Sun Nov 19, 2006 20:30 Post subject: |
|
|
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 |
|
|
lostdreamz
Joined: 19 Nov 2006 Posts: 26
|
Posted: Sun Nov 19, 2006 21:12 Post subject: |
|
|
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 |
|
|
lostdreamz
Joined: 19 Nov 2006 Posts: 26
|
Posted: Sun Nov 19, 2006 21:32 Post subject: |
|
|
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 |
|
Back to top |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Mon Nov 20, 2006 0:19 Post subject: |
|
|
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 |
|
|
lostdreamz
Joined: 19 Nov 2006 Posts: 26
|
Posted: Mon Nov 20, 2006 0:27 Post subject: |
|
|
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 |
|
|
lostdreamz
Joined: 19 Nov 2006 Posts: 26
|
Posted: Mon Nov 20, 2006 0:37 Post subject: |
|
|
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 |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Mon Nov 20, 2006 1:42 Post subject: |
|
|
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 |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Sat Apr 28, 2007 2:07 Post subject: |
|
|
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 |
|
|
|