I've been trying to build my SQL statements using TEXT...ENDTEXT to create simplier to read statements and to protect from SQL injection. I have found that I can't use THISFORM in the text content but can use variables. I have looked up the help and it basically says that the textlines can consist of:
I am assuming that it doesn't consider thisform.xxxx as a variable hence the following code fails:
but if I store the value into a variable it does work:
I assume then that if I have values in a field in a table then can I just reference them with the fieldname?
I think it would probably be best to set all the variables first in a list outside the TEXT command to ensure the correct value is being picked up. Just seems a waste the microsoft didn't see form properties as something people may want to pass into a TEXT...ENDTEXT command. Be interesting to see what other people do to with regards using TEXT...ENDTEXT to create SQL commands.
Thanks,
Mark.
Mark Davies
Warwickshire County Council
Parameters
TextLines
Specifies text to send to the current output device. TextLines can consist of text, memory variables, array elements, expressions, functions, or any combination of these.
I am assuming that it doesn't consider thisform.xxxx as a variable hence the following code fails:
Code:
TEXT TO m.lcsql noshow
SELECT *
FROM client
WHERE clientref = <<ALLTRIM(thisform.cclientref)>>
ENDTEXT
but if I store the value into a variable it does work:
Code:
cClientRef = <<ALLTRIM(thisform.cclientref)>>
TEXT TO m.lcsql noshow
SELECT *
FROM client
WHERE clientref = ?cClientRef
ENDTEXT
I assume then that if I have values in a field in a table then can I just reference them with the fieldname?
I think it would probably be best to set all the variables first in a list outside the TEXT command to ensure the correct value is being picked up. Just seems a waste the microsoft didn't see form properties as something people may want to pass into a TEXT...ENDTEXT command. Be interesting to see what other people do to with regards using TEXT...ENDTEXT to create SQL commands.
Thanks,
Mark.
Mark Davies
Warwickshire County Council