MySQL Forums
Forum List  »  Connector/ODBC

MySQL Connector/ODBC: unixODBC: Pass Env Variable to INITSTMT
Posted by: LaVallee Brian
Date: January 10, 2018 02:47AM

Is it possible to pass a *nix environment variable to initstmt?

I want to pass a client variable, like $HOSTNAME to a MySQL session variable.

initstmt = SET @myhost = 'unique.host.tld'; -- not desired
initstmt = SET @myhost = $HOSTNAME; -- does not work
initstmt = SET @myhost = {$HOSTNAME}; -- does not work
initstmt = SET @myhost = $(HOSTNAME); -- does not work

There are hundreds hosts, manually setting each one is not desired,

In the end, it will be used in a stored procedure, below should provide some insight.

mysql> SET @myhost = 'unique.host.tld';
mysql> SELECT * FROM table WHERE hostname = @myhost; -- used as sp
mysql> CREATE VIEW host_view AS CALL sp_host(@myhost); -- app can not use call
mysql> SELECT * FROM host_view;

Any help would be appreciated!


Thanks,
Brian LaVallee

Options: ReplyQuote


Subject
Written By
Posted
MySQL Connector/ODBC: unixODBC: Pass Env Variable to INITSTMT
January 10, 2018 02:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.