Subject insert from select in psql
Author Nagy Szilveszter
Hi all,


i have a table A which contains user introduced data.

I have an identical structured table B.

I want to append all data from A into B at each end of month, and empty table A so it will be small and fast for operations...and from table B i do the reportings.


In PSQL i cannot use something like this:

INSERT INTO A SELECT * FROM B;

It gives this error:

An error was found in the application program input parameters for the SQL statement.
Dynamic SQL Error.
SQL error code = -804.
Count of read-write columns does not equal count of values.


Of course this is a restriction, because i cannot guarantee for my stored procedure that the tables will always have the same structure.

The only way it works is to list all fields in the insert statement (INSERT INTO A VALUES (F1, F2, ...) SELECT F1, F2, ... FROM B;) but i'd like to have a simple way if it exists (because the table contains too many fields and they might change in the future - the only sure thing is that both tables will always have the same structure)

Do you have a better way?


Thanks,
Szilvi

[Non-text portions of this message have been removed]