C cnicolapc Active Member Licensed User Longtime User Sep 13, 2011 #1 Hi, I need to assign to a variable that has a wildcard value (any character and any number) how can I do?. eg: main.Cercacategorie = "%" & "*" & "%" (which is not correct) Thanks in advance Nicola
Hi, I need to assign to a variable that has a wildcard value (any character and any number) how can I do?. eg: main.Cercacategorie = "%" & "*" & "%" (which is not correct) Thanks in advance Nicola
K kickaha Well-Known Member Licensed User Longtime User Sep 13, 2011 #2 It is not clear what you are trying to do. Could you post a fuller explanation, and the code so that we can help? Upvote 0
It is not clear what you are trying to do. Could you post a fuller explanation, and the code so that we can help?
C cnicolapc Active Member Licensed User Longtime User Sep 13, 2011 #3 hi I created a variable to be used in a SQL statement like this. trivial example: Value = "dog" main.Cercacategorie = "%" & value & "%" Cursor1 SQL1.ExecQuery = ("SELECT cosa FROM articoli where categoria like '" & main.Cercacategorie & "' ORDER BY cosa") But I need that with a command variable is reset and allow you to view any character and any number so I have to replace "%" & value & "%" with what ? thank You Nicola Upvote 0
hi I created a variable to be used in a SQL statement like this. trivial example: Value = "dog" main.Cercacategorie = "%" & value & "%" Cursor1 SQL1.ExecQuery = ("SELECT cosa FROM articoli where categoria like '" & main.Cercacategorie & "' ORDER BY cosa") But I need that with a command variable is reset and allow you to view any character and any number so I have to replace "%" & value & "%" with what ? thank You Nicola
K kickaha Well-Known Member Licensed User Longtime User Sep 13, 2011 #4 Have a look at this page for details on wildcard characters. Upvote 0
C cnicolapc Active Member Licensed User Longtime User Sep 13, 2011 #5 hi, Thank you it was easy. main.Cercacategorie="%" Thank you Nicola Upvote 0
corwin42 Expert Licensed User Longtime User Sep 14, 2011 #6 cnicolapc said: Code: Copy Cursor1 SQL1.ExecQuery = ("SELECT cosa FROM articoli where categoria like '" & main.Cercacategorie & "' ORDER BY cosa") Click to expand... I often see that programmers concatenate their select statement string with variables like this. Be aware that this is not very good technique for the SQL engine. Every time you create a statement like this it is a completely NEW statement for the SQL engine so the statement has to be parsed again, a new execution plan has to be found and so on. A better way is to use ExecQuery2 like this: Code: Copy SQL1.ExecQuery2 = ("SELECT cosa FROM articoli where categoria like ? ORDER BY cosa", array as string(main.Cercacategorie)) So every time you call this statement the SQL engine recognizes that this is a statement called before and can use the cached execution plan. If you do many select statements like this then the performance will increase. Upvote 0
cnicolapc said: Code: Copy Cursor1 SQL1.ExecQuery = ("SELECT cosa FROM articoli where categoria like '" & main.Cercacategorie & "' ORDER BY cosa") Click to expand... I often see that programmers concatenate their select statement string with variables like this. Be aware that this is not very good technique for the SQL engine. Every time you create a statement like this it is a completely NEW statement for the SQL engine so the statement has to be parsed again, a new execution plan has to be found and so on. A better way is to use ExecQuery2 like this: Code: Copy SQL1.ExecQuery2 = ("SELECT cosa FROM articoli where categoria like ? ORDER BY cosa", array as string(main.Cercacategorie)) So every time you call this statement the SQL engine recognizes that this is a statement called before and can use the cached execution plan. If you do many select statements like this then the performance will increase.
C cnicolapc Active Member Licensed User Longtime User Sep 15, 2011 #7 hi, thank you for the valuable advice Nicola Upvote 0