Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Tabele tymczasowe
who?
post
Post #1





Grupa: Zarejestrowani
Postów: 47
Pomógł: 0
Dołączył: 4.05.2005

Ostrzeżenie: (0%)
-----


Witam ponownie:)
Jak to jest z tymi tabelami tymczasowymi w postgresie, bo zacząłem sie tym bawić, ale nie bardzo kumam co i jak. Problem jest taki, że tworzę taką tabelę w funkcji, przeprowadzam na tabeli kilka opracji i zwracam później zawartość tej tabeli przez funkcję. Wydawało mi się logiczne, że jak wychodzę z funkcji, to tabela powinna się usunąć, ale kiedy drugi raz wywołuje tę funckję, to wywala błąd, że taka tabela już istnieje. Wyczytałem, że tabela tymczasowa pozostaje na czas trwania sesji, ale przecież jak chce w czasie trwania jednej sesji kilka razy wywołać tę funkcję (a niestety mam taką konieczność), to mam error. Czy ktoś bardziej zorientowany w temacie może mi to wyjaśnić jak stosować te tabele, bo dla mnie to jest trochę bez sensu.

POZDRAWIAM
who?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
MStaniszczak
post
Post #2





Grupa: Zarejestrowani
Postów: 71
Pomógł: 1
Dołączył: 3.10.2004

Ostrzeżenie: (0%)
-----


Polecam czasami zajrzeć do manuala;-)

Cytat
TEMPORARY or TEMP

    If specified, the table is created as a temporary table. Temporary tables are automatically dropped at the end of a session, or optionally at the end of the current transaction (see ON COMMIT below). Existing permanent tables with the same name are not visible to the current session while the temporary table exists, unless they are referenced with schema-qualified names. Any indexes created on a temporary table are automatically temporary as well.

    Optionally, GLOBAL or LOCAL can be written before TEMPORARY or TEMP. This makes no difference in PostgreSQL, but see Compatibility.

...

ON COMMIT

    The behavior of temporary tables at the end of a transaction block can be controlled using ON COMMIT. The three options are:

    PRESERVE ROWS

        No special action is taken at the ends of transactions. This is the default behavior.
    DELETE ROWS

        All rows in the temporary table will be deleted at the end of each transaction block. Essentially, an automatic TRUNCATE is done at each commit.
    DROP

        The temporary table will be dropped at the end of the current transaction block.


http://www.postgresql.org/docs/8.0/interac...reatetable.html

Pozdrawiam
Marcin Staniszczak
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.10.2025 - 01:57