Page 1 of 1

[Solved] Base Mysql get username + hostname

Posted: Wed Apr 28, 2010 5:26 pm
by ponlerd
Hi, is there a way that i can get the username and hostname in a macro?
I want to stamp the user@hostname on some records.
For the username i can get it from
Form.ActiveConnection.Parent.User (if i remember it right.)

But for the hostname , i couldn't find it anywhere on the xRay.
Thanks!

Re: Base Mysql get username + hostname

Posted: Thu Apr 29, 2010 2:51 am
by rudolfo
You use MySQL in your title and the format user@hostname sounds like MySQL as well.
So my advice is: "Ask the database for this information:"

Code: Select all

mysql> select user();
+----------------+
| user()         |
+----------------+
| rolf@localhost |
+----------------+
If I do the same inside a query in Base on my Windows machine connected to a MySQL database on a Linux Box I get: rolf@grappa.ristaurante.local as the resulting record.
Actually this is information about the client side of the connection. But as you say you need to stamp it, the client machine makes much more sense than the host name with the mysql server.

update this_table set changed_by = user() where ....

And see the Mysql manual in case you need other types of session data.

Re: Base Mysql get username + hostname

Posted: Fri Apr 30, 2010 4:25 am
by ponlerd
Thanks , works great!