开发者

sql parser(change parsing method)

I have one select:

select * from table1 where col1=10;

and another select:

select * from table1 where col1=11;

Sql parser parses them as different sqls.. I want to make SQL PARSER parse the statement once and just change the parameter in the where clause..Can I do that? Do have any idea ? please share it with me.. thanks a lot.

P.S: I am selecting:

select * from v$sql
where parsing_user_id=55 (my user id)

and see that new row is inserted when i run first query and another row is inserted when i run second query.If i run first or second query one more time now new row is inserted(mean开发者_StackOverflows that sql parser doesn't parse it once more)


You need to use bind variables in some form. If you're doing this in SQL*Plus, for example, you could do:

var myval number;

exec :myval := 10;
select * from table1 where col1 = :myval;

exec :myval := 11;
select * from table1 where col1 = :myval;

If you're calling from somewhere else there are slightly different mechanisms so you might need to be a bit more specific.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜