Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    7

    Unanswered: putting username in a select statement

    How do I put a username in a select statement?

    ie..

    SELECT owner FROM all_constraints
    WHERE owner=&&user;

    Thanks!

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: putting username in a select statement

    SELECT owner FROM all_constraints
    WHERE owner=user;

    (USER is a system function.)

    Or more simply:

    SELECT owner FROM user_constraints;

    Presumably you really intend to select something other than OWNER from the view, otherwise the select is pointless!

  3. #3
    Join Date
    Jan 2004
    Location
    India
    Posts
    191
    Hi ,
    Question is not clear.

    Is it ur looking for following:

    1* Select * from all_constraint where owner=&username
    SQL> /
    Enter value for username: xyz

    or

    Select * from all_constraints where owner =(select user from dual);


    Thanks,
    Pagnint
    (No need to search web before posting new question)

  4. #4
    Join Date
    Jan 2004
    Location
    India
    Posts
    191
    I am sorry.... great andrewst is very correct

    Dont select user from dual;
    you can directly write as "owner=user"

    Thanks,
    Pagnint
    (No need to search web before posting new question)

  5. #5
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Originally posted by paginit
    Hi ,
    Question is not clear.

    Is it ur looking for following:

    1* Select * from all_constraint where owner=&username
    SQL> /
    Enter value for username: xyz

    or

    Select * from all_constraints where owner =(select user from dual);


    Thanks,
    Ah yes, I hadn't realised that that was probably what was meant - but you need to add the quotes when using substitution variables:

    select * from all_constraints where owner='&username';

    (And there is no need to select user from dual in the second version, just "where owner = user")

Posting Permissions

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