且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Oracle PL/SQL where子句中使用变量

更新时间:2021-06-26 22:13:43

您要如何处理SELECT返回的数据?如果您只想查看它,则根本不需要PL/SQL,只需在SQL Plus中执行此操作:

What do you want to do with the data that the SELECT returns? If you just want to see it you don't need PL/SQL at all, just do this in SQL Plus:

variable var number
exec :var := 1

select * from SomeTable where SomeField = :var;

或者在SQL Developer或Toad之类的工具中,只需执行以下操作:

Or in a tool like SQL Developer or Toad, just do this:

select * from SomeTable where SomeField = :var;

,它会提示您输入:var的值.

and it will prompt you to enter the value for :var.