Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have table like this:
TABLE:
LOAD * INLINE [
SERVER
'SERVERNAME1'
'SERVERNAME2'
...
];
and loop:
FOR i = 1 to NoOfRows('TABLE')
LET v_TABLE = Peek('SERVER', $(i), 'TABLE');
LET v_SPECIFICATION = FieldName(1, $(v_TABLE));
trace $(v_TABLE);
...
STATEMENTS
...
NEXT
If I reload it, nothing happen, although for cycle runs thousand times, because the result of Peek() funcion is always NULL, not the value from table. Is the syntax incorrect, or is there some other mistake?
Sorry, my question was wrong. In Peek() function the third parameter wasn't string, but a variable (I didnt know that this will be mistake) and after many tries, I found out two things:
in my QV version 11.20 I have to call functions with variable parameter e.g. v_SPECIFICATION, not $(v_SPECIFICATION) (but not variable $(i), why???)
and rows in tables are numbered from zero (sometimes, as well), so this works for me:
LET v_TABLE = Peek('SERVER', $(i) - 1, v_SPECIFICATION);
Its really strange for me, but learning by doing...
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I am trying to update a column cell in my database for that I am writing a single query and then
I get the error when I run my code:
Traceback (most recent call last):
File "K:\Project\Python\Campaign\Experiments\insert.py", line 9, in
cursor.execute(""" UPDATE facebook_profile SET
sqlite3.OperationalError: near "WHERE": syntax error
What am I missing? I am missing some syntax it is very difficult to find out where?
import sqlite3
connection = sqlite3.connect('miracle.db')
cursor = connection.cursor()
record_id = 1
profile_life_circle_value = 1
cursor.execute(""" UPDATE facebook_profile SET
profile_life_circle = :_fk_profile_life_circle,
WHERE oid =:oid""",
{
'profile_life_circle': profile_life_circle_value,
'oid': record_id
})
connection.commit()
connection.close()
It's not difficult to find out where the syntax error is. The syntax error message tells you:
near "WHERE"
It always tells you exactly the position in the query where the syntax parser got confused about your query. In this case, it wasn't expecting you to use WHERE in the place you used it.
So what did it see right before you used WHERE that made it expect something else?
UPDATE facebook_profile
SET profile_life_circle = :_fk_profile_life_circle, WHERE oid =:oid
^
You used a comma after your SET <column> = <expr> clause.
Use a comma after the <expr> if you are setting multiple columns. But don't put a comma after the last <expr> in the list of columns you are setting.
It's useful to learn to read syntax reference documentation, like the kind found here: https://www.sqlite.org/lang_update.html
This diagram indicates that you can assign multiple columns. Each assignment is separated from the previous assignment with a comma. But notice that given this syntax notation, there can be no comma after the last assignment.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
As far I as my experience tells me, boolean variables usually named in format - is/has+noun/adj/verb, e.g isValid, isButton, hasClickedLink
But say there is the case where we have some flag which straightly tells whether to do something, like for example, clean to indicate that cleanup function should be automatically called in the end.
How to name such a booleans? Same clean - is ambiguous, looks like a method name more, but naming it toClean is, I don't know, too weird. Or should I name it like callCleanup?
Thanks in advance!
In this case i usually append the word wanted, which makes cleanWanted. In general, for boolean variables I also prefer to always let the last word be an adjective. This makes it very clear that it represents a truth value. The is/has prefix is often superfluous, as in hasClickedLink which is more concisely communicated with linkClicked.
methods are usually one word adjectives with a capitol at the start
maybe create a method that sets the flag
for example
void Clean(){
clean = True;
}
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Everytime this program startup , the program runs after a server restart this error shows up:
startup:13: attempt to call nil
When i comment out that line of code the same happens to the line after that, and after that.
Until all those four lines are. (the round(math.floor) lines)
Then the program starts.
The four variables is needed in the program so it wont run well with them commented out.
If i now uncomment those lines the program starts perfectly and everything works.
Any reason what im doing wrong?
Functions must be defined before they are called (round is defined on line 72, but called on line 5). You can declare a function prior to defining it:
function program()
local round -- forward declaration
while true do
-- call function defined below
turbEnergy = round(math.floor(turbine.getEnergyStored())/100000,1)
-- function definition
function round(val, decimal)
end
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Can someone help me with declaring a Scalar Variable? I really don't understand the Scalar Variable declaration.
Below is the code that is causing my exception.
int customer_Id;
int.TryParse(customer_IDTextBox1.Text, out customer_Id);
string SQL = #"UPDATE Customer
SET Customer_Name = #customer_Name
WHERE Customer_ID = #customer_Id";
SqlCommand sqlCommand = new SqlCommand(SQL, sqlConnection);
sqlCommand.Parameters.AddWithValue("#customer_Name", customer_Name);
sqlConnection.Open();
sqlCommand.ExecuteNonQuery();
You only have the #customer_Name variable declared as a parameter.
Add the line
sqlCommand.Parameters.AddWithValue("#customer_Id", customer_Id);
under your current AddWithValue line.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I need to convert a SQL connection string into a String.Format line
The line that I need to convert is this:
WHERE full_name = #FullGraveNumber AND cemetery_id = #CemeteryID
Both thefull_name and cemetery_id are variables, but I have not idea how to construct the
String.Format line.
Seems you are looking for
Dim selectCommand = "SELECT * FROM mytable WHERE full_name = #FullGraveNumber AND cemetery_id = #CemeteryID"
Dim cmd = New SqlCommand(selectCommand, yourconnetion)
cmd.Parameters("#FullGraveNumber").Value = value1
cmd.Parameters("#CemeteryID").Value = value2
or
cmd.Parameters.AddWithValue("#FullGraveNumber", value)
First of all, ConnectionString is already a String with no parameters, it does not need to converted using String.Format. Usually stored in app.config, you feed it directly into SqlConnection object upon creation.
Part of the query that you have is also a String, but this time it may be substituted with parameters. However, please don't do so and use SQL parameters instead (see #huMpty's answer).
full_name and cemetery_id are SQL parameters, variables is something else.
My suggestion it to learn the terminology first, before you do any coding. No offense, it would benefit you a lot, because you would be able to ask a proper question. Proper question means a fast and qualified answer. Improper questions are usually closed. These are the rules of StackOverflow.