When using the attached script in psql, the temp variables disappear as far as \distv shows, but running the script a second time fails.
To reproduce, save the following script as bug.sql, then start psql on an test database. \i bug.sql \distv -- no relations should be shown \i bug.sql -- this will fail. However, if you run psql again, you can \i bug.sql successfully. It will only fail if run twice in the same script. cheers -mark -- Hardy Boys: too easy. Nancy Drew: too hard! - Fry
CREATE TABLE foo ( foo_idx SERIAL PRIMARY KEY, foo INTEGER ) ; CREATE TABLE bar ( bar_idx SERIAL PRIMARY KEY, foo_idx INTEGER REFERENCES foo, bar INTEGER ) ; INSERT INTO foo ( foo ) VALUES ( 111 ) ; INSERT INTO foo ( foo ) VALUES ( 222 ) ; INSERT INTO foo ( foo ) VALUES ( 333 ) ; BEGIN WORK ; SELECT foo_idx INTO TEMP v_idx FROM foo WHERE foo.foo = 222 ; INSERT INTO bar ( foo_idx, bar ) VALUES ( v_idx.foo_idx, 888 ) ; END WORK ; DROP TABLE foo ; DROP SEQUENCE foo_foo_idx_seq ; DROP TABLE bar ; DROP SEQUENCE bar_bar_idx_seq ;
---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster