Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get current user???

4,197 views
Skip to first unread message

tjm...@my-deja.com

unread,
Nov 24, 1999, 3:00:00 AM11/24/99
to
Hi!

On DB2 how do I query for the current user?

ON Oracle it's "select user from dual;"

Thanx!


Sent via Deja.com http://www.deja.com/
Before you buy.

tjm...@my-deja.com

unread,
Nov 24, 1999, 3:00:00 AM11/24/99
to
Hi Agin let me add to this!

On DB2 how do I query for the current user?
ON Oracle it's "select user from dual;"


Also how do I get a list of users:
ON Oracle it's "select * from dba_users"

Mark Arnold

unread,
Nov 24, 1999, 3:00:00 AM11/24/99
to
On DB2/OS390 anyway, "select current sqlid from sysibm.sysdummy1"
or (in program code) "SET :var-name = current sqlid"

all users? I don't know if that can be done...

HTH,
Mark Arnold

In article <81gj9u$k70$1...@nnrp1.deja.com>,

Juan Lanus

unread,
Nov 24, 1999, 3:00:00 AM11/24/99
to
Hi

In DB2 the current user id is "USER"
For example:
CREATE TABLE foo
bar AS CHAR(8) NOT NULL DEFAULT USER;
or also
UPDATE ping SET u = USER WHERE you want to
which is the same as
VALUES(USER)

As of the users list, I have no idea. I'd try to obtain it from the
operating system.

Regards

Juan Lanus


tjm...@my-deja.com wrote:
>
> Hi!


>
> On DB2 how do I query for the current user?
>
> ON Oracle it's "select user from dual;"
>

Blair Kenneth Adamache

unread,
Nov 24, 1999, 3:00:00 AM11/24/99
to
db2 values user

tjm...@my-deja.com

unread,
Nov 25, 1999, 3:00:00 AM11/25/99
to
Thanks for the reply...
But what do you mean by:
"db2 values user"

That's not a clp command and certainly doesn't execute
as a sql statement...

I use ODBC and need to return the USER from a query somehow.
I see from the other post I could create a table and insert the user in
it then select the user and then delete the table but there has to be an
easier faster way doesn't there?!?!

Anyways thanks a lot for your help!

In article <383BFD15...@ca.ibm.com>,

tjm...@my-deja.com

unread,
Nov 25, 1999, 3:00:00 AM11/25/99
to
Brilliant !
Thanks
I guess sysdummy1 is like dummy in oracle whihc is what I was looking
for..

You can also return a function this way right?

select myfunct() from sysibm.sysdummy1

Thanks

In article <81h235$v6s$1...@nnrp1.deja.com>,


Mark Arnold <mark_...@excite.com> wrote:
> On DB2/OS390 anyway, "select current sqlid from sysibm.sysdummy1"
> or (in program code) "SET :var-name = current sqlid"
>
> all users? I don't know if that can be done...
>
> HTH,
> Mark Arnold
>
> In article <81gj9u$k70$1...@nnrp1.deja.com>,
> tjm...@my-deja.com wrote:
> > Hi Agin let me add to this!
> >

> > On DB2 how do I query for the current user?
> > ON Oracle it's "select user from dual;"
> >

> > Also how do I get a list of users:

> > ON Oracle it's "select * from dba_users"

Blair Kenneth Adamache

unread,
Nov 25, 1999, 3:00:00 AM11/25/99
to
It is a clp statement. You can also select "USER":

select user from sysibm.sysdummy1

(SYSIBM.SYSDUMMY1 is a 1 row table supplied with DB2, like DUAL in Oracle.)

tjm...@my-deja.com wrote:

> Thanks for the reply...
> But what do you mean by:
> "db2 values user"
>
> That's not a clp command and certainly doesn't execute
> as a sql statement...
>
> I use ODBC and need to return the USER from a query somehow.
> I see from the other post I could create a table and insert the user in
> it then select the user and then delete the table but there has to be an
> easier faster way doesn't there?!?!
>
> Anyways thanks a lot for your help!
>
> In article <383BFD15...@ca.ibm.com>,
> adam...@nopamca.ibm.com wrote:
> > db2 values user
> >
> > tjm...@my-deja.com wrote:
> >
> > > Hi!
> > >

> > > On DB2 how do I query for the current user?
> > >
> > > ON Oracle it's "select user from dual;"
> > >

Phil Castle

unread,
Nov 26, 1999, 3:00:00 AM11/26/99
to
well it is actually a valid statement in udb so should execute in the clp.
Should work OK in ODBC (I use it).
Alternatively you could say "select user from some_table" (though you will
get as many rows returned as there are rows in some_table unless you have a
Where clause to restrict it to 1 row). The values statement was added to db2
to allow you to return the value of internal variable which isn't associated
with a particular table (similarly you can say "values current date" and so
forth).

As for your previous question, there's no way to get a list of "all users"
as you can in Oracle. With DB2, security is more integrated with the
operating system (eg. Unix,NT) than it is with Oracle. Users do not get
defined to DB2, instead any valid Unix/NT user can sign onto the DB2 system
(as long as they have Connect authority).

Phil Castle.

Alfred Moos

unread,
Nov 26, 1999, 3:00:00 AM11/26/99
to tjm...@my-deja.com

SELECT user from Tablename>.

Use the special register in the select-list.

Regards
Alfred

tjm...@my-deja.com schrieb:

> Hi Agin let me add to this!
>

> On DB2 how do I query for the current user?
> ON Oracle it's "select user from dual;"
>

> Also how do I get a list of users:

> ON Oracle it's "select * from dba_users"


>
> Thanx!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

--
Viele Grüße
Alfred Moos

--

Fachhochschule Heidelberg - University of Applied Sciences
http://www.fh-heidelberg.de/fb/info/mitarb/moos.htm
Neu: Europäischer Computer-Führerschein (ECDL):
http://www.fh-heidelberg.de/public/moos/ecdl.htm

the itcontractor

unread,
Nov 26, 1999, 3:00:00 AM11/26/99
to

tjm...@my-deja.com wrote:

> Hi!


>
> On DB2 how do I query for the current user?
>
> ON Oracle it's "select user from dual;"
>

Marc Baime

unread,
Nov 29, 1999, 3:00:00 AM11/29/99
to
Disclaimer: don't know if this stuff works on the mainframe this is for UDB
on intel/UNIX. Mainframe catalog is a bit different.

> On DB2 how do I query for the current user?
> ON Oracle it's "select user from dual;"

In db2 run the command (from a command window) db2 "values(user)" to get the
current user.


>
>
> Also how do I get a list of users:

> ON Oracle it's "select * from dba_users"

It depends upon what you want here:
To get a list of active users running applications against the database do a
"db2 list applications' command..among other things, this will return the
authid of all users currently rnning applications

To get a list of users authorized to use the database use the command:
"db2 select grantee from syscat.dbauth"...to see what authorities the users
have just do a "db2 select * from syscat.dbauth"

You can also easily check authorities from the control center.

Regards...Marc Baime

mah

unread,
Nov 30, 1999, 3:00:00 AM11/30/99
to
ON DB2 it's "values(USER)"
or "select USER from sysibm.sysdummy1"

the itcontractor wrote:

> tjm...@my-deja.com wrote:
>
> > Hi!


> >
> > On DB2 how do I query for the current user?
> >
> > ON Oracle it's "select user from dual;"
> >

0 new messages