Reputation: 243
I am facing a problem regarding global temporary tables in Postgres Sql. If two procedures:
then if the procedure A is called first and after that procedure B is called then the temp table remains with the structure i.e. temp(id, name) defined in the procedure A and vice versa and the column "address" as defined in procedure B is not found.
Please help me to find a solution???
Upvotes: 0
Views: 1397
Reputation: 26464
Basically you have two options.
The first is to make your tables unique so that they don't hit the same ones. This would be preferred if you are using these to store longer-term session-specific data. These could be named uniquely.
A second is that you can create, use, and drop your tables inside the same stored procedure so that stored procedure A can be generally guaranteed that relation temp does not exist when starting and the same with stored procedure B.
Upvotes: 0
Reputation: 12998
If you really need to have explicit temporary tables, just create these with a unique name.
Anyway, the common approaches would be to handle it in SQL selects without explicit temporary tables, possibly extended by using with queries (common table expressions).
Upvotes: 1