この場合の動作はわかりません。私の理解では、無効なサブクエリを持つクエリはエラーになります。しかし、この例では、いくつかの行が返されます。壊れたサブセレクトのクエリはエラーになりますが、行を返します。
テストデータ:予想通り
create table test_values (tst_id number, tst_id2 number, tst_value varchar2(10));
create table test_lookup (tst_id number, tst_value varchar2(10));
insert into test_values(tst_id, tst_id2, tst_value) values (1, 2, 'a');
insert into test_values(tst_id, tst_id2, tst_value) values (1, 2, 'b');
insert into test_values(tst_id, tst_id2, tst_value) values (2, 2,'c');
insert into test_values(tst_id, tst_id2, tst_value) values (2, 2,'d');
insert into test_lookup(tst_id, tst_value) values (1, 'findMe');
commit;
作品:
select * from test_values where tst_id in (select tst_id from test_lookup where tst_value = 'findMe');
/*
TST_ID TST_ID2 TST_VALUE
---------- ---------- ----------
1 2 b
1 2 a
*/
select tst_id2 from test_lookup where tst_value = 'findMe';
--ORA-00904: "TST_ID2": invalid identifier
しかし、次のクエリは、また、 "test_values" から "test_id2" - カラムを取ることによって、明らかに、行を取得しています - サブクエリに記述されているように、また内側と外側の部品にエイリアスを使用していないのに、 "test_lookup"テーブルからではありません。非エイリアスの列がサブクエリには存在しませんが、外側のクエリに存在しない場合、Oracleはあなたが外部クエリからのコラムを参照していると仮定しているため
select * from test_values where tst_id in (select tst_id2 from test_lookup where tst_value = 'findMe');
/*
TST_ID TST_ID2 TST_VALUE
---------- ---------- ----------
2 2 c
2 2 d
*/
@vmachan OPは、create tableとinsert文を含む完全なテストケースを投稿しました。私はあなたのOPに彼らの質問に追加することを期待している追加情報がわからない! – Boneist
私は似たような質問をここに頼んだ。http://stackoverflow.com/questions/34774242/force-outer-select-to-fail-if-the-inner-select-contains-an-invalid-identifierあなたがこの行動を変える方法を尋ねているなら...それはできないようです。 –
これは適切な(しかしもっと長い)コードを使用し、すべてがうまいものです) – evilive