Jump to content

SQL Changes


icedsun

Recommended Posts

I've recently returned from a long coding absence (haven't been active since dp2). I've been trying to get some of my old scripts updated for 1.0.3 and have been having trouble with some basic SQL stuff. It seems that there were some changes between the dp2 version and 1.0.3. The executeSQLDropTable function now works correctly. The executeSQLQuery also seems to be working correctly now, and the 512 character limit has been increased. Both are wonderful! However, the trouble I'm running into now is that in dp2, I could do this:

local itemVis = executeSQLSelect("objectVisuals","shape,size,texture,fixins","id='taco'")
outputConsole("The taco's shape is "..itemVis[1][b][1][/b])
outputConsole("The taco's size is "..itemVis[1][b][2][/b])
--and so on and so on...

Whereas now in 1.0.3 the syntax has to follow this:

local itemVis = executeSQLSelect("objectVisuals","shape,size,texture,fixins","id='taco'")
outputConsole("The taco's shape is "..itemVis[1][b].shape[/b])
outputConsole("The taco's size is "..itemVis[1][b].size[/b])
--and so on and so on...

Was I just using improper syntax when I did it the old way? Just curious if anyone has any experience with this... Thanks.

Link to comment

I've recently returned from a long coding absence (haven't been active since dp2). I've been trying to get some of my old scripts updated for 1.0.3 and have been having trouble with some basic SQL stuff. It seems that there were some changes between the dp2 version and 1.0.3. The executeSQLDropTable function now works correctly. The executeSQLQuery also seems to be working correctly now, and the 512 character limit has been increased. Both are wonderful! However, the trouble I'm running into now is that in dp2, I could do this:

local itemVis = executeSQLSelect("objectVisuals","shape,size,texture,fixins","id='taco'")outputConsole("The taco's shape is "..itemVis[1][b][1][/b])outputConsole("The taco's size is "..itemVis[1][b][2][/b])--and so on and so on...

Whereas now in 1.0.3 the syntax has to follow this:

local itemVis = executeSQLSelect("objectVisuals","shape,size,texture,fixins","id='taco'")outputConsole("The taco's shape is "..itemVis[1][b].shape[/b])outputConsole("The taco's size is "..itemVis[1][b].size[/b])--and so on and so on...

Was I just using improper syntax when I did it the old way? Just curious if anyone has any experience with this... Thanks.

Link to comment

I don't think it's actually required as such, but the new method is certainly better in my opinion. No need to be sure you got the returned table contents in the correct order. Both syntaxes are correct.

One other change to note however, if a query would return no data, it used to return either false or nil. (I forgot which) Now it returns an empty table. Not sure what the logic was behind that change, but just be aware of it.

Link to comment

I don't think it's actually required as such, but the new method is certainly better in my opinion. No need to be sure you got the returned table contents in the correct order. Both syntaxes are correct.

One other change to note however, if a query would return no data, it used to return either false or nil. (I forgot which) Now it returns an empty table. Not sure what the logic was behind that change, but just be aware of it.

Link to comment

Hmm, well if it is proper syntax, then I'll have to do a bugreport because it seems as though it's not supported anymore. Here's an example script to see: (if i'm just screwing something up let me know!!!)

executeSQLCreateTable("mytable","id INT,type TEXT,xloc REAL")
executeSQLInsert("mytable","'101','vehicle','482.456'")
local out = executeSQLSelect("mytable","*")
outputServerLog("Regular: "..tostring(out))
outputServerLog("ColName: "..tostring(out[1].id))
outputServerLog("ColNum: "...tostring(out[1][1]))

outputs this:

Regular: table: 01BA3C88

ColName: 101

ColNum: nil

It's sometimes really useful to iterate through when they're returned numerically, but I'm sure it's possible to do through the actual names as well. But, like I said, if it's supposed to perform both ways, it doesn't seem to be.

Link to comment

Hmm, well if it is proper syntax, then I'll have to do a bugreport because it seems as though it's not supported anymore. Here's an example script to see: (if i'm just screwing something up let me know!!!)

executeSQLCreateTable("mytable","id INT,type TEXT,xloc REAL")executeSQLInsert("mytable","'101','vehicle','482.456'")local out = executeSQLSelect("mytable","*")outputServerLog("Regular: "..tostring(out))outputServerLog("ColName: "..tostring(out[1].id))outputServerLog("ColNum: "...tostring(out[1][1]))

outputs this:

Regular: table: 01BA3C88

ColName: 101

ColNum: nil

It's sometimes really useful to iterate through when they're returned numerically, but I'm sure it's possible to do through the actual names as well. But, like I said, if it's supposed to perform both ways, it doesn't seem to be.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...