Oracle IN vs Exists difference?

simply put, EXISTS is usually used for checking whether rows that meet a criteria exist in another (or the same) table. your SQL using EXISTS would look like this: select * from emp e where exists(select * from emp e2 where e.empno = e2.empno and e2.ename in (‘smith’, ‘brown’, ‘john’, ‘johnson’)) so you can see … Read more

Is there an Oracle equivalent to SQL Server’s OUTPUT INSERTED.*?

Maybe I don’t understand the question, but wouldn’t this do it? (you must know what you want back) INSERT INTO some_table (…) VALUES (…) RETURNING some_column_a, some_column_b, some_column_c, … INTO :out_a, :out_b, :out_c, … @Vincent returning bulk collect into for multi-row insert works only in conjunction with forall (in another words if you insert from … Read more

Escaping single quote in PLSQL

I do this sort stuff a fair bit (usually generating insert/update statements). You just need to use the replace function to turn all the ‘ into ”. i.e. Change it to: str_comment:=’COMMENT ON COLUMN ‘||rec.table_name||’.’||rec.column_name ||’ IS ”’||REPLACE( rec.description,””,”””)||”’; ‘ ;