monica1
29th April 2005, 14:29
Hello, I have a problem with query.extend.where(). I write this code:

user = logname$
query = "EXISTS(select caacp012.* " &
"from caacp012 " &
"where caacp012._index1 = {" & user & ", tfacp102.bref})"
query.extend.where(query)


The caacp012 table structure is:
caacp012.user
caacp012.bref
caacp012.dsca
with caacp012.user and caacp012.bref like index1

I want to do this but with query.extend.where():

main.table.io:
after.read:
select caacp012.*
from caacp012
where caacp012._index1 = {:user, :tfacp102.bref}
selectdo
selectemtpy
skip.io("")
endselect


Where is my problem? The query.extend.where doen't work.

Thank you in advance,

Andreas
29th April 2005, 15:05
Hello, I have a problem with query.extend.where(). I write this code:

user = logname$
query = "EXISTS(select caacp012.* " &
"from caacp012 " &
"where caacp012._index1 = {" & user & ", tfacp102.bref})"
query.extend.where(query)



have you tried with colons like this way:
query = "EXISTS(select caacp012.* " &
"from caacp012 " &
"where caacp012._index1 = {:" & user & ", :tfacp102.bref})"
query.extend.where(query)
It's described here (http://www.baanboard.com/programmers_manual_baanerp_help_functions_sql_query_extensions_overview)

Andreas

evesely
29th April 2005, 15:24
When your "where" clause gets filled it, the value of user gets inserted right after the '{' without quotation marks (like = {monica1, :tfacp102.bref}). So, the value of user looks like a variable (like = {"monica1", :tfacp102.bref}). Instead, try:
query = "EXISTS(select caacp012.* " &
"from caacp012 " &
"where caacp012._index1 = {" & chr$(34) & user & chr$(34) &
", :tfacp102.bref})"

The chr$(34) is the quotation mark character.

I hope that helps.

monica1
29th April 2005, 17:49
The Andrea's solution works. Only I change one thing:


query = "EXISTS (select caacp012.* " &
"from caacp012 " &
"where caacp012._index1 = {:user, :tfacp102.bref})"



Thank you