简体   繁体   中英

Variable Inside the Access Pass Through Query

I set a global variable in my program.

public this_is_global_var as integer

this_is_global_var=1

Then I use that variable inside my pass through query

Select * from oracle_table where id=this_is_global_var ;

But error shows "this_is_global_var: invalid identifier"

Please help.Thanks.

如果要在查询中使用变量,则必须将其编写为变量:

"SELECT * FROM oracle_table WHERE id = " & this_is_global_var

You can define placeholders for variable inside the query definition and replace it before execution.

qdfTemp.SQL = Replace(qdfMyQuery.SQL, "[this_is_global_var]", str(this_is_global_var))

and then execute temp query. Original query will be untouched.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM