DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: user restriction

  1. #1
    Join Date
    Nov 2001
    Posts
    29
    Hi,

    I want to get the result using a select with 2 conditions like this

    if user = 'X' then

    select * from abc
    where

    if user='Y' then

    select * from abc
    where

    here I want to put the two conditions in a single query Is it possible, How ?. Can you please help me.

    Thanks.
    balraj

  2. #2
    Join Date
    Jun 2001
    Location
    Helsinki. Finland
    Posts
    3,938
    Is user a column in the abc table?

  3. #3
    Join Date
    Nov 2001
    Posts
    29

    user restriction

    Hi,

    No, user is not a column in abc table. User is the current user thru which the user is connected.

    thanks.
    balraj

  4. #4
    Join Date
    Jun 2001
    Location
    Helsinki. Finland
    Posts
    3,938

    Re: user restriction

    I did the following. Is it what you are aiming at (I assume you are user called BOSS)?

    create table ABC (text varchar2(10), day date);
    insert into ABC values('SATDY',sysdate);
    insert into ABC values('GIGIOOL',sysdate-1);
    insert into ABC values('GOOOL',sysdate-2);
    create user X identified by X;
    create user Y identified by Y;
    grant connect, resource to X;
    grant connect, resource to Y;
    grant select on ABC to X;
    grant select on ABC to Y;

    SQL> select * from boss.abc
    2 where 'X' = (select username from user_users)
    3 union all
    4 select * from boss.abc
    5 where 'Y' = (select username from user_users);

    TEXT DAY
    ---------- ---------
    SATDY 17-DEC-01
    GIGIOOL 16-DEC-01
    GOOOL 15-DEC-01

    Elapsed: 00:00:00.20
    SQL>

  5. #5
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439

    Re: Re: user restriction

    Julian, you've lost me here. With your setup, what is your select statement trying to do?
    Originally posted by julian
    SQL> select * from boss.abc
    2 where 'X' = (select username from user_users)
    3 union all
    4 select * from boss.abc
    5 where 'Y' = (select username from user_users);
    To reduce confusion, wouldn't it be more readable to put the above like:
    SQL> select * from boss.abc
    2 where 'X' = USER
    3 union all
    4 select * from boss.abc
    5 where 'Y' = USER;

    But this is not my point. What I don't understand is how does your select differ from a simple (appart for confusing the original poster ):

    SQL> select * from boss.abc;

    And I don't think this is what hnetscape is looking for. In fact, I think a simple use of DECODE/CASE in a WHERE clause will cover his needs, but he would have to explain in more datail what he is trying to acchieve.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  6. #6
    Join Date
    Jun 2001
    Location
    Helsinki. Finland
    Posts
    3,938

    Re: Re: Re: user restriction

    I assume that he has different where clauses on his select statements. That is how it deffers. But if he has the same where clause, then I don't see much the point of the question, it is a bit unclear to me.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width