Re: Re: Please help me to take a look of the erros in my functions. Thanks.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: leaf_yxj <leaf_yxj(at)163(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: Please help me to take a look of the erros in my functions. Thanks.
Date: 2012-04-03 14:34:03
Message-ID: 6254.1333463643@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

leaf_yxj <leaf_yxj(at)163(dot)com> writes:
> ***********************************************************
> CREATE OR REPLACE FUNCTION truncate_t (IN tablename text)
> RETURNS VOID
> AS
> $$
> BEGIN
> EXECUTE 'TRUNCATE TABLE ' || quote_ident(tablename) || 'CASCADE;';

I think you need a space there:

EXECUTE 'TRUNCATE TABLE ' || quote_ident(tablename) || ' CASCADE;';

> EXCEPTION
> WHEN undefined_table THEN
> RAISE EXCEPTION 'Table "%" does not exists', tablename;

It's really a pretty bad idea to print your own message instead of using
the system's message. In this case, you would have figured out the
problem immediately if you'd seen the real error message, which was
presumably bleating about "t1cascade".

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Harkaway 2012-04-03 14:56:08 Unable to createlang
Previous Message leaf_yxj 2012-04-03 14:24:24 Re: Please help me to take a look of the erros in my functions. Thanks.