-1

I want to create select Query in Postgresql. my code is

 select * into concat('production.',layer_name)  from concat('staging.',layer_name); 

but there is a problem

ERROR:  "concat" is not a known variable
LINE 20: select * into concat('production.'layer_name)  from concat('...

I can not understand why .

Can anybody help me?

4

1 回答 1

1

There is a concat() function in Postgres (since v.9.1). Useful for string concatenation possibly involving NULL values. But your syntax is just gibberish to the Postgres parser. It is generally not possible to use values (or return values from a function) as identifiers in plain SQL. You would need dynamic SQL in a plpgsql function for that.

But your example doesn't seem to need either. Do you want to copy rows from one table to another one? If so:

INSERT INTO production.layer_name
SELECT * FROM staging.layer_name
于 2013-10-29T22:27:10.323 回答