Teradata: How to query the data source's name











up vote
0
down vote

favorite












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










share|improve this question
























  • Did you consider my servername UDF answer? Btw, yout shouldn't use those old deprecated non-V-views anymore, it's dbc.SessionInfoV
    – dnoeth
    Nov 8 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 8 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 8 at 18:24












  • @dnoeth haha okay I'll see if it ends up being viable, thanks for the suggestions!
    – Marcucciboy2
    Nov 8 at 18:47















up vote
0
down vote

favorite












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










share|improve this question
























  • Did you consider my servername UDF answer? Btw, yout shouldn't use those old deprecated non-V-views anymore, it's dbc.SessionInfoV
    – dnoeth
    Nov 8 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 8 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 8 at 18:24












  • @dnoeth haha okay I'll see if it ends up being viable, thanks for the suggestions!
    – Marcucciboy2
    Nov 8 at 18:47













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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










share|improve this question















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







teradata






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 18:47

























asked Nov 8 at 17:30









Marcucciboy2

2,31621022




2,31621022












  • Did you consider my servername UDF answer? Btw, yout shouldn't use those old deprecated non-V-views anymore, it's dbc.SessionInfoV
    – dnoeth
    Nov 8 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 8 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 8 at 18:24












  • @dnoeth haha okay I'll see if it ends up being viable, thanks for the suggestions!
    – Marcucciboy2
    Nov 8 at 18:47


















  • Did you consider my servername UDF answer? Btw, yout shouldn't use those old deprecated non-V-views anymore, it's dbc.SessionInfoV
    – dnoeth
    Nov 8 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 8 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 8 at 18:24












  • @dnoeth haha okay I'll see if it ends up being viable, thanks for the suggestions!
    – Marcucciboy2
    Nov 8 at 18:47
















Did you consider my servername UDF answer? Btw, yout shouldn't use those old deprecated non-V-views anymore, it's dbc.SessionInfoV
– dnoeth
Nov 8 at 17:50






Did you consider my servername UDF answer? Btw, yout shouldn't use those old deprecated non-V-views anymore, it's dbc.SessionInfoV
– dnoeth
Nov 8 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 8 at 18:07




@dnoeth Thanks for the heads up on the deprecated views. Unfortunately, I "don't have CREATE FUNCTION access to database SYSLIB"
– Marcucciboy2
Nov 8 at 18:07




1




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 8 at 18:24






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 8 at 18:24














@dnoeth haha okay I'll see if it ends up being viable, thanks for the suggestions!
– Marcucciboy2
Nov 8 at 18:47




@dnoeth haha okay I'll see if it ends up being viable, thanks for the suggestions!
– Marcucciboy2
Nov 8 at 18:47

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53213188%2fteradata-how-to-query-the-data-sources-name%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53213188%2fteradata-how-to-query-the-data-sources-name%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()