0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SQLのバインド変数について

Posted at

:CompanyCd のようなバインド変数は、SELECT句では使用できない。

【例】:Subで自由に列指定しようとした場合

失敗例
SELECT CompanyCd,
 EmployeeNo,
 :SubCd
FROM EmpMaster
WHERE salary > 50000
 AND :SubCd = 'A10' 

上記例ではEmpMasterテーブルに同一のコード保持カラムがあればそのままSQL文を使いまわせるという考えだが、エラーとなる。

自分は仕方なく列ごとにSQL文を作りましたが、
これを実現できるような書き方を知っている方がいたらご教授いただきたいです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?