Re:Querying Teradata and SQL Server - Tutorial 1: The SELECT Statement

Ma*** about 3 years ago

The alignment is all messed up in the comments. Sorry about that. BTW, its a VIEW select and not a TABLE
Add comment

Comments (7)

Ra*** about 2 years ago

@Mahe I could not identify any issue with your query directly.

Is your connection using the same credential as you were using in SQL Assistant?

Ma*** about 3 years ago

Hello, I am having trouble using JPA to run Teradata queries. I am able to run the generated query in SQL Assistant but not from JPA. Below is the exception. com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=UY_DEV_DATA.EQ_EV_H, DRIVER=3.62.56 select equipevent0_.EQ_IN as EQ_INIT_1_13_, equipevent0_.EV_DT as EVENT_DT2_13_, equipevent0_.EV_TM as EVENT_TM3_13_, equipevent0_.EV_TYPE as EVENT_TY4_13_, equipevent0_.WB_N as WB_SN5_13_, equipevent0_.CI_NA_19 as CITY_NAM6_13_, equipevent0_.LO_EY as LOAD_EMP7_13_, equipevent0_.R_BL_TM_RD as RPT_BLK_8_13_, equipevent0_.SP as SPLC9_13_, equipevent0_.ST_PR_IN as STATE_P10_13_, equipevent0_.TR_B_N as TRANS_W11_13_ from UY_DEV_DATA.EQ_EV_H equipevent0_ where equipevent0_.EQ_IN = 'ABCD123456' and equipevent0_.WB_N = '654654' The query runs successfully in SQL Assist and the schema.table is valid too. Can you please help ? Thanks, Mahe

Ma*** about 3 years ago

The alignment is all messed up in the comments. Sorry about that. BTW, its a VIEW select and not a TABLE

Ma*** about 3 years ago

Hello, I am having trouble using JPA to run Teradata queries. I am able to run the generated query in SQL Assistant but not from JPA. Below is the exception. com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=UY_DEV_DATA.EQ_EV_H, DRIVER=3.62.56 select equipevent0_.EQ_IN as EQ_INIT_1_13_, equipevent0_.EV_DT as EVENT_DT2_13_, equipevent0_.EV_TM as EVENT_TM3_13_, equipevent0_.EV_TYPE as EVENT_TY4_13_, equipevent0_.WB_N as WB_SN5_13_, equipevent0_.CI_NA_19 as CITY_NAM6_13_, equipevent0_.LO_EY as LOAD_EMP7_13_, equipevent0_.R_BL_TM_RD as RPT_BLK_8_13_, equipevent0_.SP as SPLC9_13_, equipevent0_.ST_PR_IN as STATE_P10_13_, equipevent0_.TR_B_N as TRANS_W11_13_ from UY_DEV_DATA.EQ_EV_H equipevent0_ where equipevent0_.EQ_IN = 'ABCD123456' and equipevent0_.WB_N = '654654' The query runs successfully in SQL Assist and the schema.table is valid too. Can you please help ? Thanks, Mahe

Ra*** about 3 years ago

@Eduardo Silva I am not sure whether I understand it correctly. There is non RIGHT function, so you have to use SUBSTR, for example, substr('nombre_columna', CHARACTER_LENGTH(nombre_columna)-2,3)

Edua*** about 3 years ago

Buenas tardes. En SQL utilizo el rigjht('nombre_columna',3) para rescatar una cierta cantidad de caracteres de una columna. Que sentencia deberia usar en TERADATA?

Edua*** about 3 years ago

Buenas tardes. En SQL utilizo el rigjht('nombre_columna',3) para rescatar una cierta cantidad de caracteres de una columna. Que sentencia deberia usar en TERADATA?

Ra*** about 4 years ago

@Martin Thanks for the correction Martin. The right query should be: SELECT Emp.EmployeeID, Emp.EmployeeName, LEN(EmployeeName) AS EmployeeNameLength, SUBSTRING(EmployeeName FROM 1 FOR 1) AS EmployeeNameInitials, CAST((Emp.JobGrade (FORMAT '9')) AS VARCHAR(1)) || ' - ' || CAST((Emp.Salary (FORMAT '9(3),999.99')) AS VARCHAR(13)) AS EmployeeJobGradeAndSalary FROM Employee Emp;

Ma*** about 4 years ago

In part Character function, the second teradata query is wrong. UBSTRING(EmployeeName FROM 1 FOR 1) AS EmployeeNameLength, will give you in EmployeeNameLength column employee initials, the same like in EmployeeNameInitials

Ma*** about 4 years ago

In part Character function, the second teradata query is wrong. UBSTRING(EmployeeName FROM 1 FOR 1) AS EmployeeNameLength, will give you in EmployeeNameLength column employee initials, the same like in EmployeeNameInitials