Oh, I checked the function. There are some syntax errors. Right code
listed below:
CREATE OR REPLACE FUNCTION cr_tbls_by_staid() RETURNS INTEGER AS
$$
DECLAREstid INTEGER;q TEXT;
BEGINFOR stid IN SELECT staid FROM mytest LOOP q:= 'CREATE TABLE "s' || staid || '" (staid varchar(50), val real,
dt date);'; RAISE NOTICE 'query is: %', q; --for debug EXECUTE q;END LOOP;RETURN 1;
END;
$$ LANGUAGE plpgsql;
Also I forget to change first column definition in last CREATE TABLE
query. Edited variant is, for sure:
CREATE TABLE sta_descs (staid INTEGER, val real, dt date) WITHOUT OIDS;
--
Best regards. Yuri.
mailto: yuragal@gmail.com