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
chloeizzy
Newbie


Joined: 14 Mar 2021
Posts: 2

PostPosted: Sun Mar 14, 2021 5:15 pm   

Retrieve data from sql
 
Beginner with SQL, and sql in cmud.
I'm able to fill an sql database with unique mob info but am having a lot of difficulty accessing the info from records.

Attempting to query with the following alias mobfind

Code:
row = %sql(mob_database, %concat("SELECT * FROM mob_database where name= '"%param(0)"'"))
#while (!@row.Eof()) {sql_info = @row.Text("name" "zone", "room", "level")
#say Mobinfo: @row.Text("name", "zone", "room", "level")
#call @row.Next}


This just returns: Mobinfo: SELECT * FROM mob_database where name= 'Mob'
Its returning the "Mob" name field, but isn't returning any zone, room or level information. If I query just "mob" instead of "Mob" it gives a blank line, so I'm assuming its returning from the database.

Any help would be greatly appreciated.
Reply with quote
hpoonis2010
Apprentice


Joined: 18 Jun 2019
Posts: 188

PostPosted: Mon Mar 15, 2021 9:44 am   
 
I think (and Shalimar might agree) that using dbvars would be a better solution. The external database functions are poorly implemented and even more pitifully documented.
Reply with quote
Sutex-Kindred
Apprentice


Joined: 26 Aug 2009
Posts: 140

PostPosted: Wed Mar 17, 2021 6:04 am   
 
hpoonis2010 wrote:
I think (and Shalimar might agree) that using dbvars would be a better solution. The external database functions are poorly implemented and even more pitifully documented.


Read a few of your post and spent long periods away from mudding due to the frustrations of Cmud and multiple windows, a super session just does not work for me, numerous bug reports sent, never seen a bug update fix yet.

Which leads me to your post here and the database in CMUD. Before I fall down the rabbit hole of setting up a 'Database' of EQ Is dbvars the only possible way?.,

I also note in another post "SQL" used in CMUD is some otherworldly version that no other software can use or read? Anyone found a work around for that.?

And other thought is CMUDPro , which has better Database stuff?, now if you can import .pkg from "CMUD_3" into CMUDPro would it be worth it.?
_________________
Entropy rules
Reply with quote
hpoonis2010
Apprentice


Joined: 18 Jun 2019
Posts: 188

PostPosted: Wed Mar 17, 2021 9:40 am   
 
I was a little confused in the beginning with the dbvar usage. However, as I got into it, it is a more elegant solution and is probably much faster. The only caveat is that you would have to make your own search functions to output the data in some sql-like fashion (select name from all potions where effect=blah and level=amazing)...but then, if you are writing %sql type functions, you are doing it anyway.

Think of a dbvar as a 'big-data' type table. It is, in essence, 'unstructured' data with variable record lengths, and each 'cell' containing whatever data you care to put into it.

As for bug-reports and fixes...the 'developer' and his clan have a win-win: they are still taking money and do nothing in return for it. Why should they lift a finger to help? Your best solution is to stick with the cmud you have, not provide them with more money for a product that is more than a decade old with zero updates, and rely on folk like Shalimar to get you off of a sticky wicket. All the problems you will probably encounter will be related to window-handling. The product tries to be too clever in that windows can have their own settings, buttons, etc. but that really creates problems and exception errors beyond belief.

One recent session CMUD decided that whatever buttons were for the main session window should be replicated to all other windows and I had monster problems with (all of a sudden) 150 or more buttons spread across 10-11 windows.
Reply with quote
chloeizzy
Newbie


Joined: 14 Mar 2021
Posts: 2

PostPosted: Wed Mar 31, 2021 8:48 pm   Re: Retrieve data from sql
 
chloeizzy wrote:
Beginner with SQL, and sql in cmud.
I'm able to fill an sql database with unique mob info but am having a lot of difficulty accessing the info from records.

Attempting to query with the following alias mobfind

Code:
row = %sql(mob_database, %concat("SELECT * FROM mob_database where name= '"%param(0)"'"))
#while (!@row.Eof()) {sql_info = @row.Text("name" "zone", "room", "level")
#say Mobinfo: @row.Text("name", "zone", "room", "level")
#call @row.Next}


This just returns: Mobinfo: SELECT * FROM mob_database where name= 'Mob'
Its returning the "Mob" name field, but isn't returning any zone, room or level information. If I query just "mob" instead of "Mob" it gives a blank line, so I'm assuming its returning from the database.

Any help would be greatly appreciated.



I did get this to work for anyone that is interested.

I can't post the code it seems or the forum gives me an error and boots me but...
Instead of sql_info = @row.Text it started working with
Code:
#while (!@row.Eof()) {#addkey cp_newmob @row.Item("name") @row.Item("zone")|@row.Item("room")|@row.Item("level");#call @row.Next}


Now I'm trying to get the operator BETWEEN to work for level ranges. I either get an error for the database or cmud will hang.

Code:
AND level BETWEEN '"thislevel"' AND '"thatlevel"'")


This code after WHERE name = in the above query doesn't work at the basic level of calling plain numeric levels without %concat for assigned variables.

If anyone has experience with this or knowledgeable enough to say that we can't use the BETWEEN operator please let me know.
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