Re: What is wrong here?

From: "Stijn Vanroye" <s(dot)vanroye(at)farcourier(dot)com>
To: "Tumurbaatar S(dot)" <tumurbaatar(at)datacom(dot)mn>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: What is wrong here?
Date: 2004-04-22 10:08:09
Message-ID: 71E201BE5E881C46811BA160694C5FCB0FA935@fs1000.farcourier.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

My guess is that the user has no (insert) rights on the table Customers.
Try something like this for your table:
GRANT [your options] ON TABLE Customers TO SomeCustomer; (or to everyone if that's easyer)
where your options best includes SELECT and INSERT

Regards,

Stijn Vanroye

> The following function returns this error:
>
> pg_query(): Query failed: ERROR: permission denied for
> relation customers
> CONTEXT: PL/pgSQL function "newprofile" line 8 at SQL statement
>
> What is wrong here?
>
>
> CREATE SEQUENCE CustomerID;
> CREATE TABLE Customers
> (
> CustomerID INTEGER NOT NULL DEFAULT nextval('CustomerID'),
> IsActive BOOLEAN NOT NULL DEFAULT TRUE,
> Email VARCHAR(64) NOT NULL CHECK (Email = substring(Email from
> '^(dot)+(at)(dot)+\(dot)(dot)+$')),
> Password VARCHAR(15) NOT NULL CHECK (Password =
> substring(Password from
> '^[0-9_A-Za-z]{5,15}$')),
> FullName VARCHAR(50) NOT NULL,
> Address VARCHAR(100) NOT NULL,
> Phone VARCHAR(15) NOT NULL,
> Created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
> Accessed TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
>
> PRIMARY KEY (CustomerID),
> UNIQUE (Email)
> );
>
> CREATE FUNCTION NewProfile(VARCHAR, VARCHAR, VARCHAR,
> VARCHAR, VARCHAR)
> RETURNS INTEGER AS '
> DECLARE
> aEmail ALIAS FOR $1;
> aPassword ALIAS FOR $2;
> aName ALIAS FOR $3;
> aAddr ALIAS FOR $4;
> aPhone ALIAS FOR $5;
> BEGIN
> INSERT INTO Customers(Email, Password, FullName, Address, Phone)
> VALUES(lower(aEmail), aPassword, aName, aAddr, aPhone);
> RETURN currval(''CustomerID'');
> END;
> ' LANGUAGE plpgsql;
>
> GRANT EXECUTE ON FUNCTION NewProfile(VARCHAR, VARCHAR,
> VARCHAR, VARCHAR,
> VARCHAR) TO SomeCustomer;
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>

Browse pgsql-general by date

  From Date Subject
Next Message Priem, Alexander 2004-04-22 10:15:15 Re: Unicode problem ???
Previous Message Tumurbaatar S. 2004-04-22 09:29:38 What is wrong here?