Subject | Re: Problem with if statement and user |
---|---|
Author | Adam |
Post date | 2006-01-31T06:02:06Z |
--- In firebird-support@yahoogroups.com, "William L. Thomson Jr."
<wlt@o...> wrote:
catch the insert exception and ignore it.
Firsty, what is USER. Is it a parameter? CURRENT_USER will give you
the user connected.
Secondly, I dont know if it matters or not, but I normally prefix any
variables in an IF statement with a :
Thirdly, put begin and end blocks around your if code to make sure it
is not something silly.
Fourthly, make sure nowhere else in the procedure contains an insert
into this table or into any other table that has triggers that cause
an insert into this table.
Fifthly, your comparison will be CaSE SenSITive! Is that your issue?
This is how I do similar logic.
IF (:CURRENT_USER <> 'SYSDBA') THEN
BEGIN
INSERT INTO ....
END
Adam
<wlt@o...> wrote:
>It may be a better approach to use the underlying permissions and
> I have a stored procedure that has an insert to a table I want to be
> excluded for a particular user. Partly because they do not have
> permissions to access that table at all. Also that the insert should
> take place for every user but the one.
>
> Now I have tried both in the stored procedure
>
> IF(USER<>'MYUSER') THEN
> INSERT ...
>
> IF(USER!='MYUSER') THEN
> INSERT ...
catch the insert exception and ignore it.
Firsty, what is USER. Is it a parameter? CURRENT_USER will give you
the user connected.
Secondly, I dont know if it matters or not, but I normally prefix any
variables in an IF statement with a :
Thirdly, put begin and end blocks around your if code to make sure it
is not something silly.
Fourthly, make sure nowhere else in the procedure contains an insert
into this table or into any other table that has triggers that cause
an insert into this table.
Fifthly, your comparison will be CaSE SenSITive! Is that your issue?
This is how I do similar logic.
IF (:CURRENT_USER <> 'SYSDBA') THEN
BEGIN
INSERT INTO ....
END
Adam