Quantcast
Channel: Teradata Forums - Database
Viewing all 14773 articles
Browse latest View live

Volatile table creation issue within Stored procedure - forum topic by Nikhil_Teradata

$
0
0

Hi, 
 
I have below code

REPLACE PROCEDURE Personal.test_code()
BEGIN


CREATE MULTISET  VOLATILE TABLE Test_Temp  (URL VARCHAR(1000), EXTR VARCHAR(50))
ON COMMIT PRESERVE ROWS;

INSERT INTO Test_Temp (URL)
VALUES ('http://www.ABC.com/event/0022330');

SELECT * FROM Test_Temp;

INSERT INTO Test_Temp (EXTR)
SELECT SUBSTRING (Test_Temp.URL FROM 3 FOR 4);

SELECT * FROM Test_Temp;

END;

I get below messages when I run.

 [5526] SPL5000:W(L13), E(3807):Object 'Test_Temp' does not exist.

 [5526] SPL1045:E(L15), Invalid or missing INTO clause.

 [5526] SPL5000:W(L18), E(3807):Object 'Test_Temp' does not exist.

 [5526] SPL1045:E(L20), Invalid or missing INTO clause.

 

I do not understand why the messages. I have used almost exact code to create and operate on the volatile table and that does not give any issues at all.

 

-Nik
 

Forums: 

Volatile table creation issue within Stored procedure - response (1) by Nikhil_Teradata

$
0
0

A bit further analysis showed that the actual error is 
[5526] SPL1045:E(L15), Invalid or missing INTO clause.
Do I have to create a table on DB(not volatile) and save the contents there? Does TD not allow to use select on Volatile table within a stored procedure?
 

How to get PPI/PI/SI usecount - response (3) by teradatauser2

$
0
0

Hi Dieter,
I am analysing a situation wherein i need to decide changing PI of a table. There is one column (xyz) that i checked in ColumnUseCountV. I see that xyz is used 845 times. But how do we know if this was used in the select or where/join clause ? This is the columns on which PI is being suggested and i need i see if this is really being used in join conditions 
--Samir

Few questions on PPI - forum topic by syam1406

$
0
0

Hi,
We are working on extending the PPI ranges in our tables,so i am working on automated script.For this i need to capture following information
1. Can i get partition range  & partition column information from any sytem tables?
DBC.PartitioningconstraintsVX is having textual information but not the limits or partitioning column sepaartely
2.Is there a performance hit copying data from default partition(1 day partition)  in staging table to some valid partition in target table (or) both staging and target to be partitioned for same range? plz provide a brief reason  
3. I am planning to use following syntax to extend my partiton. In the following syntax what is the significance of using "PRIMARY INDEX"? the query is working with/with out having PRIMARY INDEX
ALTER table <TABLE_NAME > MODIFY
PRIMARY INDEX
ADD RANGE BETWEEN DATE '2016-01-01' AND DATE '2025-01-01' EACH INTERVAL '1' DAY;
Any other precautions we need to take to perfom this task?
Your suggestions are much appreciated.

Forums: 

Collect stats taking long time - response (9) by Srichakra

Tperf calculation for my system - forum topic by gskaushik

$
0
0

Hi,
 
Good morning.
We have a 5650H system for which I want tyo understanf onm how to calculate the TPERF value.
Browsing over all the posts, I came to know that we can calculate the TPERF using the below query
 
When calculated, I got a value of 18k but as per my understanding having 5100M as 1.0 , I thought I would be getting some value ranging from 1-100.
 
Kindly do correct if there were any mistakes in the query

LOCK ROW FOR ACCESS
SEL MAX(TPERF)/1000 FROM (
SELECT
THEDATE,
THETIME,
SUM(CPUUEXEC) CPUUEXEC,
SUM(CPUUSERV) CPUUSERV,
SUM(CPUIOWAIT) CPUIOWAIT,
SUM(CPUIDLE) CPUIDLE,
(SUM(CPUUEXEC)+SUM(CPUUSERV)+SUM(CPUIOWAIT)+SUM(CPUIDLE)) TPERF
FROM DBC.RESUSAGESPMA
WHERE THEDATE = DATE
GROUP BY 1,2)DT;

regards,
Subramanian kaushik Gurumorthy

Forums: 

query CPU cycle on different series of Teradata node - response (1) by meet_as

$
0
0

Hi Teradata experts,
Please reply. I need this information.
Regards,
Ajit
 
 

Converions of timestamp to FORMAT 'MM/DD/YYYYBHH:MI:SS' - response (8) by Langaliya.Nirav

$
0
0

how to convert string like Wed Jun 10 10:43:14 2015 to Date or timestamp format?


Convert string into date - response (13) by Langaliya.Nirav

$
0
0

how to convert string like Wed Jun 10 10:43:14 2015 to Date or timestamp format?

Dynamic calling of stored procedure. - forum topic by maheshkanni

$
0
0

Hi All,
I have a requirement that I need to call SP dynamically.
E.g:
Replace Procedure DB.StoredProcedure1(IN SP_NAME VARCHAR(30),IN DB_NAME VARCHAR(15),IN TBL_NAME VARHCAR(30))
BEGIN
 
Call SP_NAME(DB_NAME,TBL_NAME); /* I need to call SP_NAME which is passed as param */
 
END;
If I run the below statement, It is giving Error: Stored Procedure SP_NAME doesnot exist.
Call DB.StoredProcedure1(StoredProcedure2,databasename,tablename);
This above statement should internally call StoredProcedure2 like
Call StoredProcedure2(databasename,tablename);
 
Kindly help.
 
Regards,
Mahesh
 

Forums: 

Performance Question - forum topic by Somdebroy

$
0
0

Hello,
We have one complex view (VIEWA) created on TABLE1 (~2BIL transactional data), TABLE2 (~5K dimensional data), TABLE3 (~6K dimensional data), TABLE4 (~5K dimensional data)) and returning ~900Mil data for my data warehouse. After all the filters suggested by business, VIEWA returns past 9 years + present year data. Now, if I do a "SELECT * FROM VIEWA;", then it takes about 1 hour and 30 mins to show me all data. If I run a "SELECT *" on each of the tables, then they actually show me results within 2 mins since we have collected stats on them and we have join indices on them.
Now, users want to check one period (can be read as fiscal month as well -- lets say there are 13 fiscal months in a year) data through ad-hoc BO report created by them. Here, users want to see "01" period of "2015" year. I have one more view (VIEWB) which contains 3 columns to get the corresponding period information. VIEWB has only 2013, 2014, 2015 periods listed.
Columns in VIEWA: FISCAL_END_DATE, DIM_1_ATTR, DIM_2_ATTR, DIM_3_ATTR, ....., DIM_40_ATTR, TOTAL_SALES_AMOUNT
Columns in VIEWB: FISCAL_END_DATE, YR_ID, PRD_ID
When BO pulls both these objects, the underlying query gets created as (QUERY1):
SELECT * FROM VIEWA A, VIEWB B
WHERE A.FISCAL_END_DATE = B.FISCAL_END_DATE
AND B.YR_ID = '2015' AND B.PRD_ID='01';
This query runs for hours. I tried writing this query in below different ways and they also took hours to execute (QUERY2, QUERY3, QUERY4).
SELECT * FROM VIEWA A,
(SELECT FISCAL_END_DATE FROM VIEWB WHERE YR_ID = '2015' AND PRD_ID='01') B
WHERE A.FISCAL_END_DATE = B.FISCAL_END_DATE;
 
SELECT * FROM VIEWA AS A
WHERE EXISTS (SELECT B.FISCAL_END_DATE FROM VIEWB AS B
WHERE A.FISCAL_END_DATE = B.FISCAL_END_DATE AND B.YR_ID = '2015' AND B.PRD_ID='01');
 
SELECT * FROM VIEWA A
INNER JOIN VIEWB B
ON A.FISCAL_END_DATE = B.FISCAL_END_DATE
WHERE B.YR_ID = '2015'
AND B.PRD_ID='01';
When I write the query in this below way, the query returns data in 8 mins (QUERY5).
SELECT * FROM VIEWA A
WHERE A.FISCAL_END_DATE = ( SELECT B.FISCAL_END_DATE FROM VIEWA B WHERE
B.YR_ID = '2015' AND B.PRD_ID='01');
Now, ad-hoc reports in BO isn't allowing ad-hoc queries to run in them. So, our BO team isn't able to customize the query as QUERY5.
So, the users are anxious to know why QUERY1 takes so long time whereas QUERY5 runs in 8 mins. We are researching on this and haven't found an answer yet. Can someone please help to find the answer? Thanks in advance!
 

Forums: 

Performance Question - response (1) by VandeBergB

$
0
0

Somdebroy,
Can you post the ddl of the underlying tables and some explains? 
The explains will help determine if your join indexes are being used by the optimizer, which is where i would start.
There are several options that could improve your performance, including some horizontal partitioning, expecially on the repeated predicate fields, yr_id and prd_id.  Are your JI"s partitioned on these fields as well?
Cheers!
 

Converions of timestamp to FORMAT 'MM/DD/YYYYBHH:MI:SS' - response (9) by dnoeth

$
0
0

Hi Nirav,
Teradata doesn't seem to like the time in between month and year.
But you can utilize TO_DATE or TO_TIMESTAMP:

TO_DATE(s, 'dy mon dd hh:mi:ss YYYY')

 

Volatile table creation issue within Stored procedure - response (2) by dnoeth

$
0
0

Hi Nik,
you can't select from any kind of table in a Stored Proc. 
You need to use cursor-syntax:

DECLARE c CURSOR WITH RETURN ONLY FOR
SELECT * FROM Test_Zemp;

OPEN c;

http://www.info.teradata.com/htmlpubs/DB_TTU_15_00/index.html#page/SQL_Reference/B035_1148_015K/ch05.140.53.html

Dynamic calling of stored procedure. - response (1) by dnoeth

$
0
0

Hi Mahesh,
there's no way to do what you want in a procedure.
The only workaround is

 CASE SP_NAME
    WHEN 'StoredProcedure1' THEN CALL StoredProcedure1(DB_NAME,TBL_NAME);
    WHEN 'StoredProcedure2' THEN CALL StoredProcedure2(DB_NAME,TBL_NAME);
   ...
END;

 


Dynamic calling of stored procedure. - response (2) by gskaushik

$
0
0

I think it can be done but not through sql
 
Step 1 We can get the stored procedure to be executed at run time in a file and do create a bteq file with call statement as below

.LOGON localtd/tduser, tdpass;
CALL sp_emp('Rufus', 12345);
.LOGOFF
.EXIT

Step 2 Then execute the bteq file to call the procedure.
 
Do check and revert if it is working ?
regards,
Subramanian kaushik Gurumoorthy

Cast CHAR - forum topic by sharatbalaji

$
0
0

SEL CAST('A'AS CHAR(10));
SEL CASE WHEN 1=1 THEN CAST('A' AS CHAR(10)) ELSE 'Y' END;
 
The first query gives 'A' followed by 9 spaces.
The Second query gives 'A' and no other spaces suffixed.
What is the reason for this difference in behaviour of cast function in CASE statement

Forums: 

Tperf calculation for my system - response (1) by gskaushik

$
0
0

Hi Anyone Would be able to help me out here .
Thanks in advance for your help.
regards,
Subramanian kaushik Gurumoorthy

Data migration between from Oracle to Teradata - forum topic by selvamr_2003

$
0
0

Hi,
I have two databases (around 10 schemas) with two different AIX box with 200TB data and need move the Teradata database. There were created three TD databases and we are not going to move 200TB data into TD and it subset of data has to move to TD(around 150TB).Please share your experience/knowledge/approach  huge data movement from oracle to Terdata.
 Both are different data center and two different locations within USA.
Applicate your response.
Thanks,
Selvam

Forums: 

TO_DATE with LIKE causing issues in Prepared statements using JDBC - forum topic by tdreturn

$
0
0

Facts:
We are using the JDBC 15.00.00.20 driver
Teradata Version: 14.10.03.03
 
Problem:
Looks like the combination of TO_DATE and LIKE is causing issues when using a JDBC driver and prepared statements. Here are the queries which are explain this. When we use the like clause by itself without the TO_DATE line, it works just fine. Seems like a combination of TO_DATE and LIKE (on different fields) in the WHERE is causing this which definitely seems like a huge bug and I would like to if anybody has run into this and has talked to Customer Support at TD and what has been their response - FIX coming soon? The work around we have employed is to CAST the field before using like even if it is defined as VARCHAR in the table. 
 
Query 1 works fine:
SELECT COUNT(*) CNT
FROM   (INFMT15_INFMT.MEDC_CPPROF "CP")  INNERJOIN  (INFMT15_INFMT.MEDC_D5PROF_ICD9_DIAG "D5")
       ON"CP".ICN_LINE_NO = "D5".ICN_LINE_NO
       AND"CP".PAYMENT_DATE = "D5".PAYMENT_DATE
       AND"CP".ICN = "D5".ICN
       AND"CP".ICN_VER = "D5".ICN_VER
WHERE  ("CP".PAYMENT_DATE BETWEEN TO_DATE(?, 'MM/DD/YYYY')
       AND TO_DATE(?, 'MM/DD/YYYY'));
 
Query 2 does not work fine:
SELECT COUNT(*) CNT
FROM   (INFMT15_INFMT.MEDC_CPPROF "CP")  INNERJOIN  (INFMT15_INFMT.MEDC_D5PROF_ICD9_DIAG "D5")
       ON"CP".ICN_LINE_NO = "D5".ICN_LINE_NO
       AND"CP".PAYMENT_DATE = "D5".PAYMENT_DATE
       AND"CP".ICN = "D5".ICN
       AND"CP".ICN_VER = "D5".ICN_VER
       WHERE  "CP".PAYMENT_DATE BETWEEN TO_DATE(?, 'MM/DD/YYYY')
       AND TO_DATE(?, 'MM/DD/YYYY')
              AND"CP".PRINCIPAL_DIAG LIKE ?
              ;
 
Error Received:
3536   UPPERCASE or CASESPECIFIC specified for non-CHAR data from the JDBC driver
 
Query 3 works fine (we had to cast the column used in the like clause):
SELECT COUNT(*) CNT
FROM   (INFMT15_INFMT.MEDC_CPPROF "CP")  INNERJOIN  (INFMT15_INFMT.MEDC_D5PROF_ICD9_DIAG "D5")
       ON"CP".ICN_LINE_NO = "D5".ICN_LINE_NO
       AND"CP".PAYMENT_DATE = "D5".PAYMENT_DATE
       AND"CP".ICN = "D5".ICN
       AND"CP".ICN_VER = "D5".ICN_VER
       WHERE  ("CP".PAYMENT_DATE BETWEEN TO_DATE(?, 'MM/DD/YYYY')
       AND TO_DATE(?, 'MM/DD/YYYY'))
              ANDCAST("CP".PRINCIPAL_DIAG ASVARCHAR(255)) LIKE ?
       ;
      
 
 

Forums: 
Viewing all 14773 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>