teradata

Executing multi - statement query in one session

半城伤御伤魂 提交于 2019-12-10 12:05:16
问题 I have asked this question and wanted to edit it , however StackOverflow for some reason did not allow me to edit . So here is the edited version For example a query : create volatile table testTable as (select * from ... blah blah) ; select top 10 * from testTable ; drop table testTable ; It executes perfect in sql assistance as one session. I am sure it is possible to execute it in Java in one session. Goal : need to execute it in one session similar to sql assistant so that it is possible

How to use variables in Teradata SQL Macros

我的未来我决定 提交于 2019-12-10 11:54:13
问题 I'm wanting to use variables inside my macro SQL on Teradata. I thought I could do something like the following: REPLACE MACRO DbName.MyMacro ( MacroNm VARCHAR(50) ) AS ( /* Variable to store last time the macro was run */ DECLARE V_LAST_RUN_DATE TIMESTAMP; /* Get last run date and store in V_LAST_RUN_DATE */ SELECT LastDate INTO V_LAST_RUN_DATE FROM DbName.RunLog WHERE MacroNm = :MacroNm; /* Update the last run date to now and save the old date in history */ EXECUTE MACRO DbName

How to replace all nonnumeric values?

前提是你 提交于 2019-12-10 10:34:56
问题 This is TERADATA (not SQL Server, not Oracle ) I have a column of phone numbers: (312)9879878 (298)989-9878 430-394-2934 394s9048ds987 .......... I need to clean this column into 3129879878 2989899878 4303942934 3949048987 .......... So that only numbers should stay. All other letters, special characters, hyphens ... should be removed. How can I do this? 回答1: Which release of TD is running at your site? If it's 14 or you got the oTranslate UDF installed you can simply do an old trick nesting

R: JDBC() not finding Java drivers path when connecting to Teradata

China☆狼群 提交于 2019-12-10 10:04:08
问题 I'm trying to connect to Teradata through RStudio, but for some reason JDBC function has problems recognizing the path where Java drivers sit. See the code below: library(RODBC) library(RJDBC) library(rJava) # both Java drivers definitely exist file.exists('/Users/KULMAK/Documents/TeraJDBC__indep_indep.16.10.00.03/tdgssconfig.jar') [1] TRUE file.exists('/Users/KULMAK/Documents/TeraJDBC__indep_indep.16.10.00.03/terajdbc4.jar') [1] TRUE But when I paste those paths in JDBC call... # allow more

Connecting to Teradata using Python

血红的双手。 提交于 2019-12-10 00:14:49
问题 I am trying to connect to teradata server and load a dataframe into a table using python. Here is my code - import sqlalchemy engine = sqlalchemy.create_engine("teradata://username:passwor@hostname:port/") f3.to_sql(con=engine, name='sample', if_exists='replace', schema = 'schema_name') But I am getting the following error - InterfaceError: (teradata.api.InterfaceError) ('DRIVER_NOT_FOUND', "No driver found for 'Teradata'. Available drivers: SQL Server,SQL Server Native Client 11.0,ODBC

Python PyTd teradata Query Into Pandas DataFrame

余生长醉 提交于 2019-12-10 00:04:58
问题 I'm using the PyTd teradata module to query data from Teradata and want to read it into a Pandas DataFrame import teradata import pandas as pd # teradata connection udaExec = teradata.UdaExec(appName="Example", version="1.0", logConsole=False) session = udaExec.connect(method="odbc", system="", username="", password="") # Create empty dataframe with column names query = session.execute("SELECT TOP 1 * FROM table") cols = [str(d[0]) for d in query.description] df = pd.DataFrame(columns=cols) #

Writing a data frame to a Teradata table using RJDBC

不羁的心 提交于 2019-12-08 21:55:49
问题 After establishing a connection as explained here, I tried to write a very simple data frame ( trythis , shown below) to a table called gh_test_20141105 in a database called p_cia_t . First, I tried > conn <- getTdConnection(vdm='vivaldi') > dbWriteTable(conn=conn,name=tbl,value=trythis) Error in .verify.JDBC.result(s, "Unable to execute JDBC prepared statement ", : Unable to execute JDBC prepared statement INSERT INTO p_cia_t.gh_test_20141005 VALUES(?,?,?,?) ([Teradata Database] [TeraJDBC 14

Date Function in Teradata

天涯浪子 提交于 2019-12-08 20:02:37
Is there a function in Teradata, that "makes" a date by giving day, month any year as parameters? SO if I have integer parameters p1_day, p2_month, and p3_year (which are, by the way, attributes), is there a function like date_function (p1_day, p2_month, and p3_year) -> for example '2013-12-11' In TD13.10+ you can create a simple SQL UDF: -- (year, month, day) to date, "invalid date" error if no valid date REPLACE FUNCTION ymd_to_date(y INTEGER, m INTEGER, d INTEGER) RETURNS DATE SPECIFIC ymd_to_date RETURNS NULL ON NULL INPUT CONTAINS SQL DETERMINISTIC COLLATION INVOKER INLINE TYPE 1 RETURN (

Significance of --connection-manager in Sqoop

感情迁移 提交于 2019-12-08 19:58:33
I have written sqoop script to import data from Teradata to Hive. `sqoop import \ --connect $JDBC_URL \ --driver com.teradata.jdbc.TeraDriver \ --username $Username \ --password $Password \ --table $TD_Table \ --hive-import \ --hive-overwrite \ --hive-drop-import-delims \ --hive-table $Hive_Database.$Hive_Staging_Table \ --split-by $Split_Col \ -m $Mapper_Number` Above script gives warning as --connection-manager). Sqoop is going to fall back to org.apache.sqoop.manager.GenericJdbcManager. But when i used --connection-manager with above script my --hive-drop-import-delims and --hive-overwrite

Query database through Excel VBA

点点圈 提交于 2019-12-08 11:33:25
问题 I am a beginner in Excel VBA. I want to query data from Teradata database and give the output into the rows of an excel sheet. When i write the below code: Private Sub CommandButton1_Click() Dim conn As Connection Dim rec1 As Recordset Dim thisSql As String Set conn = New Connection conn.Open "Driver=Teradata; DBCName=" & DBCName & ";UID=" & UID & ";PWD=" & PWD thisSql = "simple select qyery here" With .QueryTables.Add(Connection:=conn, Destination:=.Range("A1")) .Sql = thisSql .Name = "data"