Jump to content
  • 0

SQL Warning: "Too many columns"


Exportforce

Question


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  09/05/13
  • Last Seen:  

[Warning]: script:query_sql: Too many columns, discarding last 2 columns.

I googled a bit and found out, that this just counts my queries and tells me how much of these fetched values I did not take into variables.

Since they won't be used as variables but only, in that script, for sql itself, this warning seems useless to me.

So is there a way to "block" this warning ? In php you can just add @ infront of the line that never may spread an error/warning.

Is there something here too ?

Link to comment
Share on other sites

12 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  181
  • Reputation:   53
  • Joined:  04/07/13
  • Last Seen:  

The problem is you're selecting more columns than you assign to variables.

For example

query_sql("SELECT `account_id`, `name` FROM `char`", .@ids, .@names$);

would not produce a warning, but

query_sql("SELECT `account_id`, `name` FROM `char`", .@ids);

will produce a warning as the number of variables does not match the number of columns selected.

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Hmm, I think you can just recompile your server and select " Release " instead of Debug, if your using Visual++. In my experience, it got rid of all Debug/Warning notices, and only presented me with actual ' Errors '.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  09/05/13
  • Last Seen:  

No, this warning comes in the debug console when the SQL is running.

All in all that warning is good and for other scripts really wanted (even better if it would read the exact line and/or the sql which is having this problem).

Just here not ,since I don't need to use those variables ingame directly since I just do a check if 2 variables exist, if yes -> script does something else.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

I see. Wish I could help further, but sadly, I don't think it's one that can be fixed without knowing exactly how the db is set up. Also, for curiosities sake, how many columns are in your a single entry in that db?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

perhap you can show your script .... ? 

you can do like this ..

if( query_sql( "SELECT 1 FROM `table` WHERE `column`='xyz'",.@foo ) ){
   mes "Query Success";
}else{
   mes "Query Failed.";
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  09/05/13
  • Last Seen:  

DeadlySilence, read my own text ;) I know that.

But I do not need any variables where I do my coding from the SQL. Thats why I asked if there is a way, like in PHP with @, to have one line where I know that this will produce a warning that is not wanted because it is intended, to block those warnings from that line. ;)

 

But if not, I seem to just to fill in a never used variable... :/ useless server impact.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

this is how the current query_sql work .... 

if you want to remove that warning ..you have to either create you own custom query_sql .. or simply disable it from showing you these warning message in the source part.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Just here not ,since I don't need to use those variables ingame directly since I just do a check if 2 variables exist, if yes -> script does something else.

1. make query_sql put the variable(s) you don't need in .@dummy

2. if your script really does NOT need those variables, then rewrite the script to use query_sql() return values

if (query_sql("SELECT 1, 1 FROM table WHERE `column1`='value1' AND `column2`='value2'", .@dummy, .@dummy)) {
     // do this
}
(you can make query_sql save more than 1 column in the same variable name; it will overwrite previous values)
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  09/05/13
  • Last Seen:  

@Brian

 

Yeah, thats what I am doing atm. Hope that saving in a variable, doesn't consume much. Since it will happen up to 500-1000 times a second if my server should get bigger ^^

Thanks for the replies :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  44
  • Reputation:   5
  • Joined:  12/06/11
  • Last Seen:  

500-1000 sql request in 1 second when your server is up ? oO

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Maybe there's a more efficient way than 100s of SQL queries per second. XD

Could you describe what you want the script to do?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  09/05/13
  • Last Seen:  

I don't want to put that open, to keep it unique. :)

(Yeah I know "selfish"... Sorry)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...