且构网

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

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

更新时间:2021-11-11 21:59:27

您想对 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.