Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
gramdel
Newbie


Joined: 01 Oct 2010
Posts: 1

PostPosted: Fri Oct 01, 2010 1:00 pm   

3.29B sql weirdness
 
Ok. I have a strange problem with cmud and sql queries. Databases are sqlite.

I have a script that loops through list of mob names and calls for the following script to check if they are in the database.

Code:
#VAR query "SELECT * from mobs where name like '"%1"'"
#VAR mobqres %sql(mobs, @query)
#IF (@mobqres.Item("level")="") {#VAR tmpvar "not found"} {#VAR tmpvar "found"}
... do stuff...


The script itself works fine. But when i actually run the script it only gets results every second time. I run the scipt -> get the right results, run the script again -> i get no matches, run the script for the third time -> i get the results.

Can't really figure this out, not sure if it's a bug or if i'm doing something wrong. The database is always connected, but it doesn't matter if i close it between attempts. Any ideas?

Edit: I had the same issue with previous betas and one other script dealing with sql queries behaves similarly.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 01, 2010 4:47 pm   
 
I could not reproduce any problem with this. Here is a test script that uses the muds.db database included with CMUD so others can test it:

First, open the database:
Code:
#SQLDB muds

Next, create this alias:
Code:
<alias name="q" id="1">
  <value>#var query %concat("SELECT * from mudlist where title like '",%1,"%'")
#var res %sql(muds,@query)
#show @res.Item("title")</value>
</alias>

Now, this is a bit different than your script. First notice that I'm using %concat properly to create the query instead of using the implicit concat that you were doing. Then you'll notice I added the % character at the end of the query so I could look for muds that start with the given %1 string.

OK, with the above alias, I can now do this:
Code:
q aard
q acha

and it displays:

Aardwolf
Achaea, Dreams of Divine Lands

I can keep using the "q" alias and it keeps working. So I am not seeing any problem with it only working every other time. You'll need to investigate the script on your end to see how it is different.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net