Title kind of says it all, here is a sample query:

BEGIN
    DECLARE LOCAL TEMPORARY TABLE tmp(id INTEGER, val VARCHAR(20));
    SELECT * FROM sys.syscolumns WHERE tname = 'tmp';
END;

Any ideas?

asked 14 Mar, 08:14

Valdas's gravatar image

Valdas
347141828
accept rate: 83%

edited 14 Mar, 09:20

Volker%20Barth's gravatar image

Volker Barth
38.9k351532800


I found a workaround:

BEGIN
    DECLARE LOCAL TEMPORARY TABLE tmp(id INTEGER, val VARCHAR(20));
    SELECT * FROM sa_describe_query('select * from tmp');
END;
permanent link

answered 14 Mar, 09:20

Valdas's gravatar image

Valdas
347141828
accept rate: 83%

edited 25 Mar, 05:29

Nice, I just wanted to mentioned another answer - with exactly that solution.

(14 Mar, 09:24) Volker Barth

AFAIK, you cannot, because by definition local temporary tables – in contrast to permanent tables and global temporary tables – are not contained in the system catalog.

Catalog queries like in your sample or builtin functions like the sa_get_table_definition() system procedure rely on the system catalog to provide information, so they won't offer information for local temporary tables.


FWIW, the table SYSTAB itself specifies that the column "table_type" is set to 4 in case of a "Local temporary table", so my assumption might be wrong.

permanent link

answered 14 Mar, 08:56

Volker%20Barth's gravatar image

Volker Barth
38.9k351532800
accept rate: 34%

edited 14 Mar, 09:17

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×25

question asked: 14 Mar, 08:14

question was seen: 236 times

last updated: 25 Mar, 05:29