PL/SQL (MOSC)

MOSC Banner

temp table scope

edited Feb 1, 2012 1:25AM in PL/SQL (MOSC) 10 commentsAnswered ✓
Hi,
 the following code generates ora-942 error.

DECLARE
 v_cnt NUMBER;
BEGIN
  SELECT Count(*) INTO v_cnt FROM user_tables WHERE table_name = 'SEG';
  IF v_cnt = 0 THEN
    EXECUTE IMMEDIATE ('CREATE GLOBAL TEMPORARY TABLE seg (name VARCHAR2(30)) ON COMMIT DELETE ROWS');
  END IF;
  INSERT INTO seg SELECT segment_name FROM user_segments WHERE ROWNUM < 3;
  EXECUTE IMMEDIATE('drop table seg');
END;

The global temp table was created but it is invisible to the plsql block. Why?

Thanks,
Sha

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center