0

Is it possible to query the current connection's data source name in teradata? I was hoping to use it to tailor some queries so that they could automatically update certain parts of said queries based on the connection information.

For example, a table in our test environment would have a different suffix than the same table in the production environment. The intent would be to use the same query in both environments, so it would need to be able to discern the current connection data in order to append the appropriate suffix to the table name.

I tried to get this from DBC.SessionInfoV in the LogonSource field, as per this answer, but there does not appear to be any pattern between the logon strings that discerns the test environment from the production one - it looks like the strings are simply random.

Here you can see what information I'm looking to actually pull into my query.

enter image description here

enter image description here

Marcucciboy2
  • 3,156
  • 3
  • 20
  • 38
  • Did you consider my servername UDF answer? Btw, yout shouldn't use those old deprecated non-V-views anymore, it's dbc.SessionInfo**V** – dnoeth Nov 08 '18 at 17:50
  • @dnoeth Thanks for the heads up on the deprecated views. Unfortunately, I `"don't have CREATE FUNCTION access to database SYSLIB"` – Marcucciboy2 Nov 08 '18 at 18:07
  • 1
    Ask your DBA to create it for you. Or ask him to give you `Create Function` rights in your user. Of course, the DBA will refuse your request immediatly, he usually grants that right only to a very limited number of admin/super users, because it's for any kind of UDF including C-UDFs and that's too risky. But it's safe when you got 0 perm space (like any normal end user), as SQL UDFs only consist of SQL source code and don't need perm (but C-UDF do). So `create function` on a user with perm space 0 effectively allows SQL-UDFs only :-) – dnoeth Nov 08 '18 at 18:24
  • @dnoeth haha okay I'll see if it ends up being viable, thanks for the suggestions! – Marcucciboy2 Nov 08 '18 at 18:47

0 Answers0