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 
 
SCO/RCO: cannot retrieve object

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



Joined: 05 Mar 2010
Posts: 47

PostPosted: Mon Jun 27, 2011 8:44    Post subject: SCO/RCO: cannot retrieve object Reply with quote

Hi there,

I'm having some problems retrieving stored objects from a MySQL table with RCO. SCO seems to store the object in the table though, I can see it while browsing the table with MySQL Query Browser. I'm using a simplified system wich stores/retrieves a npc, looping through it's inventory to retrieve items. I thought about trying FETCHMODE, but I'm under Windows, alas...

The functions:

void SetPersistentObject(string sKey, object oObject)
{
string sSQL = "INSERT INTO bankobj(cdkey, storer) VALUES('" + sKey + "', %s) ON DUPLICATE KEY UPDATE storer=%s";
SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL);
StoreCampaignObject("NWNX", "-", oObject);
}

object GetPersistentObject(object oPC, object oOwner)
{
string sKey = GetPCPublicCDKey(oPC);
string sSQL = "SELECT storer FROM bankobj WHERE cdkey='" + sKey + "'";
SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL);
if(!GetIsObjectValid(oOwner)) oOwner = oPC;
return RetrieveCampaignObject("NWNX", "-", GetLocation(oOwner), oOwner);
}

my odbc log file:

o Got request (scorco): SELECT storer FROM bankobj WHERE cdkey='Q7KUVYJJ'
o Got request (scorco): INSERT INTO bankobj(cdkey, storer) VALUES('Q7KUVYJJ', ~s) ON DUPLICATE KEY UPDATE storer=~s
! SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '˜«ZàÒi' at line 1
o Got request (scorco): SELECT storer FROM bankobj WHERE cdkey='Q7KUVYJJ'
o Got request (scorco): INSERT INTO bankobj(cdkey, storer) VALUES('Q7KUVYJJ', ~s) ON DUPLICATE KEY UPDATE storer=~s
! SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '˜«ZàÒi' at line 1

I feel like this must be very simple, sorry if it is, and thank you very much for taking the time to read this!

Kato
Back to top
View user's profile Send private message Send e-mail
Kato



Joined: 05 Mar 2010
Posts: 47

PostPosted: Tue Jul 05, 2011 16:49    Post subject: Reply with quote

well, I guess I'll have to find out... I'll report my results when I do.

Kato
Back to top
View user's profile Send private message Send e-mail
Kato



Joined: 05 Mar 2010
Posts: 47

PostPosted: Sun Jul 17, 2011 22:56    Post subject: Reply with quote

Okay, FYI, it simply was the ON DUPLICATE KEY UPDATE part wich caused the problem. Many thanks to Virusman for the info. Smile
Back to top
View user's profile Send private message Send e-mail
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