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

Looping in Stored Procedure - forum topic by maheshkanni

$
0
0
Hi,


 I am new to teradata SPs n trying to write a loop.

 Below is the sample code, I want to assign QUERIES to variables SQLTXT1,SQLTXT2,SQLTXT3 ... and run with SYSEXECSQL. so I can run any no. of queries
 in loop and want to leave loop if SQL_ERR_CODE <> 0 .

 SET Count=0

 SET SQLTXT1='DELETE FROM '||DBNAME||'.TABLE';
 SET SQLTXT2='INSERT INTO '||DBNAME||'.TABLE SELECT * FROM '||DBNAME||.TABLE1''
SET SQLTXT3='QUERY.....'
..
..
..


  
 L1: LOOP

 Q1: BEGIN

 DECLARE EXIT HANDLER FOR SQLEXCEPTION

 SET COUNT=COUNT+1;
 SET SQLTXT='SQLTXT:COUNT';
 CALL DBC.SYSEXECSQL(:SQLTXT)

 END Q1;

 GET DIAGNOSTICS EXCEPTION 1 ERRMSG = MESSAGE_TEXT;
  
 IF COUNT=2 OR SQL_ERR_CDE<>0
 THEN
 LEAVE L1;
 END IF;
 END LOOP L1;


I am not able to assign a query from SQLTXT1,2,3 ... to SQLTXT variable. I am doing like this to capture log for every query I run in SP.

Please help me on this. 
 

 Best Regards,
 Mahesh

 

Forums: 

Need to update a column values into NULL if the value contains a non numeric values. - forum topic by Chiranjeevi_Vande

$
0
0

Hi Team,
I have a situation like the column is defined as char and it contain non numeric values as well. I wanted to update those values into NULL. 
EX. My column contains below data
a123h
1fhh
123
hdh2hfh4
Requred output:
NULL
NULL
123
NULL
Can you please suggest how to do this.

Forums: 

Restore Failed : table id doesn't match for DBS. - response (1) by Fred

$
0
0

To use RESTORE, leave the original table alone; if you want a backup of the contents, make a new backup table.
If you create a new target table, you must (re)GRANT any the access rights held on the original, and use COPY command instead of RESTORE.

Teradata best practices - checktable and scandisk - forum topic by zct0357

$
0
0

Last year we upgraded from TD12.0 to TD14.10.  In the past, Teradata recommended running checktable and scandisk at regular intervals (quarterly?) as a best practice.  I know many improvements have been made since TD12.0.  Does Teradata have a “Best Practices” document for TD14.10 that has recommendations for running checktable and scandisk (and other utilities) on a scheduled basis?

Forums: 

Merge Script is Taking alot of Time - response (1) by mohsin.yazdanie

$
0
0

As per my analysis, SI and 8.5 TB table size is causing the issue.
But still recommendation will be appreciated.

How to convert the flat procedure to set logic? - response (2) by dnoeth

$
0
0

What's your Teradata release?
Can you show some actual data?
This seems to simply create rows for each month/quarter/etc based on a startdate.
You should be able to do this either using a CROSS JOIN or EXPAND ON. 

Analyzing DBQL - response (1) by padhia

$
0
0

I haven't figured out a simpler way either. If you know some basic coding, you might try parsing XML explain and look at locking information at the begining of explain for more accurate answers. But otherwise this question is in the same league as some other questions you'd think should be easy to answer. For example,

  • How do you figure out activitycount from DBQL if your statement type isn't SELECT and you don't have stepinfo enabled?
  • How do you figure out what views directly dependent on a table or another view?

For the create table, I think that's because PE can't find the new object name in DD (obviously) and hence it doesn't end up in DBQL.
There are many nice tools in Teradata to get details you need, but I haven't found many that answer above questions.

How to get ununsed column list from table. - forum topic by raghu1124

$
0
0

Hi,
 
I am trying to find  ununused columns list from a table that are not being  accessed by anyone since it is created.
 

Forums: 

Volatile table for EXTUSER - forum topic by jnevill

$
0
0

Is it possible for a user logging in through EXTUSER (using LDAP) to create a volatile table? If not, is there any reasonable substitution or workaround where a user could create a temp table that would drop when the session disconnects?

Forums: 

How to get ununsed column list from table. - response (1) by raghu1124

$
0
0

There is a table - DBC.ObjectUsage for object count  but I don't see any data in it.   Is there any other DBC table that stores  columns in a table that are accessed  using select queries?
I  don't know much  on Teradata administration , any help would be  bery much appreciated.

Need to update a column values into NULL if the value contains a non numeric values. - response (1) by dnoeth

$
0
0

TD14 supports TO_NUMBER which returns NULL if the conversion fails:
select to_number(col)

Variables in TD? - forum topic by Nikhil_Teradata

$
0
0

Hi,
I am a TD newcomer and still figuring out details. 
I came across below piece of code that caught my attention.

REPLACE PROCEDURE ABC (IN dbname VARCHAR(30),IN spname VARCHAR(100), IN batchDt DATE ) 
BEGIN

DECLARE tProcDb VARCHAR(30) ;
DECLARE tProcNm VARCHAR(100);
DECLARE tmsg_id, hc1count INTEGER ;
DECLARE sqlmsg VARCHAR(1000);
DECLARE hHex CHAR(2);
DECLARE hAscii, hrepl CHAR(1);

SET tProcDb = dbname;
SET tProcNm = spname;

Are these tProcDb, tProcNm variables? Is this a way to declare and use variables? 
I tried to do this in a separate window.

DECLARE url VARCHAR(1000);
DECLARE id VARCHAR(100);

SET url = 'http://www.ABC.com/CDE/00004537173DA4D4'
SET id = SUBSTRING (url, 5,20))
SELECT id

I got message: The query is invalid.
What am I missing in this picture?

Forums: 

How to get ununsed column list from table. - response (2) by VeluNatarajan

$
0
0

Raghu,
Enable DBQL Object Usage to track all object level activity
Refer Teradata document for more details:http://www.info.teradata.com/HTMLPubs/DB_TTU_14_10/index.html#page/Database_Management/B035_1093_112A/1093Chap16.038.15.html
Collect Qrylog for couple of weeks and take your analysis on Table/Index/View/Column usage from DBC.ObjectUsage.
Thanks!!
 
 

Variables in TD? - response (1) by Fred

$
0
0

You can define and use variables inside a stored procedure definition. You can't do that inline in regular Teradata SQL.

Merge Script is Taking alot of Time - response (2) by Fred

$
0
0

How skewed is the distribution of NUSI values? How critical is the NUSI for query?
Could a single-table JI be used instead? (Maybe sparse JI, omitting the highly skewed values?)


How to convert the flat procedure to set logic? - response (4) by vincent_dd

$
0
0

Thanks Dieter. 

Teradata release is 14.10.04.04

Actual data is like this: 

What I have - 

Order_ID Effective_Date Term

819559512 1/30/2015 1

 

And what I want is to add a column like 'Renew Date' -

Order_ID Effective_Date Term Renew_Date

819559512 1/30/2015 1 2/30/2015

819559512 1/30/2015 1 3/30/2015

819559512 1/30/2015 1 4/30/2015

819559512 1/30/2015 1 5/30/2015

819559512 1/30/2015 1 6/30/2015

 

Now I'm using above logic to insert into a table. It's working but the performance is quite low.

Sorry I'm still new to TD, so can you please be more specific on the solution?

 

Thanks,

Vincent

Need to update a column values into NULL if the value contains a non numeric values. - response (2) by Chiranjeevi_Vande

$
0
0

Hi Dhoeth,
Thanks for writing. 
I tried TO_NUMBER , but it returned values like <error> instead of null. Then, I tried below function and is working fine.

UPDATE TABLENAME SET COL1=NULL WHERE REGEXP_REPLACE(COL1,[A-Za-z]*','',1,0,'i') <> COL1 ;
 

 

Various UPDATE Scenarios - response (2) by TDW

$
0
0

Repost.
Any ideas would be appreciated.
Thanks and God Bless,
Genesius

Need to update a column values into NULL if the value contains a non numeric values. - response (3) by manib0907

$
0
0

UPDATE TABLENAME SET COL1=NULL WHERE REGEXP_SIMILAR(TRIM(COL1),'^[0-9]+') <> 1
Can you try this?
Cheers,
Mani

TO_DATE in "IN" clause - forum topic by tdreturn

$
0
0

All,
We are trying to use TO_DATE in a IN clause and the syntax checker does not seem to like it. Here are some examples:
This works:

SELECT *

FROM (MEDC_C1prof "CD")

WHERE "CD".PAYMENT_DATE IN (TO_DATE('2014-11-01', 'YYYY-MM-DD'))

 

This DOES NOT work (as soon as you add another date)

SELECT *

FROM (MEDC_C1prof "CD")

WHERE "CD".PAYMENT_DATE IN (TO_DATE('2014-11-01', 'YYYY-MM-DD'), TO_DATE('2014-11-15', 'YYYY-MM-DD'))

 

I can get around this using OR but am trying to avoid that. Let me know. 

 

 

 

 

 

Forums: 
Viewing all 14773 articles
Browse latest View live


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