From: | "whytwelve13(at)yahoo(dot)com" <whytwelve13(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PgSQL not recognized |
Date: | 2006-11-14 20:28:33 |
Message-ID: | 1163536113.615077.38220@k70g2000cwa.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> Have you read the documentation for the creation of functions? And
> looked at the examples?
>
> http://www.postgresql.org/docs/8.1/static/plpgsql.html
Obviously not as good I should have. I missed the begin and the end,
adding those solved the problem. I am new to Postgres and it is quite
differently designed compared to what I have been using so far, I just
thought I could step right into it and do as I used to. Wrong. Even
minor things like the need for ; at the end of the statements can be
annoying until you find out what is the key. Reminds me of the old days
of switching from Basic to Pascal and C.
> In the latest release, in beta, you can DROP IF EXISTS. However, most
> people just execute the drop and ignore the error, less risk of race
> conditions.
I am using 8.1.5, which doesn't have IF EXISTS yet. Although, this is a
good addition to the language.
How do I ignore the error? The problem is that I would like to have a
set of drop/create statements executed at once and one drop failing
will abort the script execution. That is why I was searching for some
conditional execution statement within the query. Did you mean using
begin/exception for this or were you just talking about
one-statement-per-query execution and "forgetting" about any possible
exceptions?
Since you showed me how to properly use functions, it is not that hard
to make a function now that checks whether the table exists or not
(which I will probably do).
Nonetheless, can you use PL/PgSQL without building functions? This is
what I have been used to while using other SQL implementations. Not
related to the above problem - if a function can be built, then it can
accept the catalog, schema and table name and check whether the table
really exists using information_schema.tables. Just wondering, though,
is this something that Postgres is not designed for or am I missing
something that disallows me to run PL/PgSQL statements within "normal"
queries?
As I read through the documentation, I saw something like "PL/PgSQL is
installed automatically". Documentation seems huge (Postgres is itself
a huge system), though, I didn't have so much time to go through the
whole process. I am sure it is worth, but not when you only need it to
test something (which is the case here).
Thank you both for the help about this, it really matters to me!
From | Date | Subject | |
---|---|---|---|
Next Message | Rob Owen | 2006-11-14 20:44:47 | Re: Out of memory (Failed on request size 24) |
Previous Message | Tom Lane | 2006-11-14 20:07:43 | Re: Out of memory (Failed on request size 24) |