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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
dguevara
Newbie


Joined: 08 Oct 2008
Posts: 9

PostPosted: Fri Oct 02, 2009 6:49 pm   

Database stuff
 
So i have an equipment database with a couple of fields

name = text saved in ansi
stats = text

Im trying to query the database using

#query
#find

but there is so little documentation on this that I keep failing to do so, whenever I fail a query it creates this filter view with nothing on it, I have to manually go to the DatabaseEditor and remove the filter.

Could anyone give me some proper examples on how to query a database
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Fri Oct 02, 2009 8:16 pm   
 
What exactly are you trying to query? How is your database set up? What are the #FIND and #QUERY commands you are trying to use. I'm going to assume you read the #QUERY and #FIND documentation. Did you also look at Programming the Database. Are you making sure that the database is loaded and the database window open before you try and query?

Unless absolutely necessary I would not try to query against the ANSI version of the name. The escape characters and ansi color codes will be frustratingly difficult to query properly. If you must store them (I'm assuming you want to maintain color properties) then I would add another field to store the name with ansi data and query against that.
_________________
Asati di tempari!
Reply with quote
dguevara
Newbie


Joined: 08 Oct 2008
Posts: 9

PostPosted: Fri Oct 02, 2009 8:27 pm   
 
My database is reduced to 2 columns
name
proc

value inside proc is "proc" or ""



#dbload du
$querystring = %concat("&proc ='","proc","'")
#show $querystring
#show %query($querystring)
#show %query("&proc ='proc'")

none of these show me anything, or get my database window sorted



my ultimate goal is just to query the database for a unique name, but was using this to test out the functions.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sat Oct 03, 2009 9:25 am   
 
The %query and to some degree the #QUERY are older commands that have some quirks from zMUD maintained for compatibility. One of these is the requirement of quotes for their expression inputs since they are processed as strings. (I'll admit my memory for the reason is a bit rusty, but the net effect is the same) There is a complete Database module rewrite planned for the not too distant future.

That said this code should get you closer to what you want to do.

Code:
$querystring = %concat(%char(34),"&name ='","proc","'", %char(34))
#show $querystring
#echo ----------
#query $querystring
#echo ----------
#show %query($querystring)
#echo ----------
#show %query("&name = proc")


%char(34) tells the is the " character that I add to the beginning and end of the string. When I did the sample database both of my fields were of type Text.

You're results should look something like this

Code:
"&name ='proc'"
----------
0     proc         Hello
1     cow          Rabiit
2     pink         crow

----------
0du|1du|2du
----------
0du
_________________
Asati di tempari!
Reply with quote
dguevara
Newbie


Joined: 08 Oct 2008
Posts: 9

PostPosted: Mon Oct 05, 2009 7:28 pm   
 
thanks a lot for the reply, I am a bit confused on how this work still

Shouldnt that code only show items that equal proc on the column name?

Im looking for something similar to using a filter on a colum that contains only a certain string.

column name equals/contains "proc"
Reply with quote
umdbandit
Wanderer


Joined: 31 Oct 2004
Posts: 94

PostPosted: Tue Oct 06, 2009 3:29 pm   
 
Quote:
There is a complete Database module rewrite planned for the not too distant future.


...droool...

I've put off all my development using databases until this is out... I am very very excited.
_________________
Rufus- Winner of Stuff
Reply with quote
Moo
Apprentice


Joined: 10 Apr 2009
Posts: 145

PostPosted: Sat Jun 12, 2010 9:45 am   
 
Tech wrote:

Your results should look something like this

It seems to me only the last query works correctly, and the ones using $querystring don't..
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion 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