CDC - response (3) by sgarlapa
Calling Power Shell Script from within Bteq script - forum topic by bp0308
Hello there,
I hava a Bteq script which does some conditin checking and if the first condition met , it should invoke a powershell script for sending out emails Or exit. I am running on windows.
I am getting error on the line where I am calling the power shell script.
I have something like below:
.if activitycount >0 then EXEC powershell.exe-ExecutionPolicy RemoteSigned- File filepath
.Exit
I've also tried .OS command, .OS Exec, .OS call, .OS ; none of them are working.
Any help would be greatly appreciated.
Thanks a lot
SELECT statement in FUNCTIONS - forum topic by veskojl
Hi Guys,
I need to create a function that reads its result from a table, so I need to use a SELECT statement to read the output. Something like that:
CREATE FUNCTION mydb.rate(a CHAR(3)) ...... RETURN SELECT b FROM mytable WHERE x = a;
I'm not sure if this syntax is allowed. Couldn't find similar example in the docs.
Stored procedure is also an option, but the problem is I need to call it INLINE like that:
SELECT 100*sp_(a) FROM sometable;
and I'm not sure if this achievable.
Any idea or advice is welcome!
Sequence number being resetted - response (2) by KVB
Thank you Youri.
Calling Power Shell Script from within Bteq script - response (1) by Raja_KT
Can you try with both OS and SYSTEM too like:
.SYSTEM 'cmd /c F:\your_directory\...\abc.exe';
Try with just one command , maybe like copy abc file to another directory.
Also try to run the os command independently, without TD script to verify it works. Step-by-step helps :).
Have a look at this link too.
http://www.info.teradata.com/HTMLPubs/DB_TTU_14_00/index.html#page/Load_and_Unload_Utilities/B035_2414_071A/2414ch03.014.55.html
Cheers,
ADD_MONTHS vs INTERVAL - response (2) by ankitislucky
In our case we are not getting last day of month as per below query:
SELECT ADD_MONTHS(CAST('2014-02-28' AS DATE ),-6);
OR
select ADD_MONTHS(DATE '2014-02-28',-6)
We are getting {8/28/2013} as the result. Is there any other function which gives us last day 6 months back i.e. {8/31/2013} as our output.
Teradata version details - forum topic by sridhare
HI,
Any single documentation of specific Arcitectural high level changes for Teradata Ver12,13,14
Support is Appreciated.
With Rgds
Sridhar
ADD_MONTHS vs INTERVAL - response (3) by Harpreet Singh
SELECT ADD_MONTHS(CAST('2014-02-28' AS DATE )- extract (day from CAST('2014-02-28' AS DATE )) ,-6);
date/time calculations - forum topic by fairy
How to calculate beginning of the day,end of the day,beginning of month,end of month. I want this along with time upto 3 places.
thanks
Creating a Cross Tab - forum topic by CCSlice
Essentially what I would like to do is summarize data that I have in a CTE in which a sample of the data is the following:
TEAM TYPE AGE AGE_BUCKET ROW_D
RED CASE 30 1. 0 -30 DAYS 1
BLUE CASE 32 2. 31 - 60 DAYS 1
GREEN WATCH 62 3. 61 - 90 DAYS 1
And the table continues on in like manner. For simplicity I have ommitted columns. How do I get counts by AGE_BUCKETS for the different teams and scenarios?
So the output looks like this:
TEAM 1. 0 - 30 DAYS 2. 31 - 60 DAYS 3. 61 - 90 DAYS 90 + DAYS TOTAL
RED 4 3 7 5 19
GREEN 3 5 6 1 15
And if I had criteria for the Teams for example count only the team for which TYpe is Case or just Watch then how would I go about doing this Teradata?
Thanks
Calling Power Shell Script from within Bteq script - response (2) by bp0308
Thanks Raja. Yes I checked the powershell script outside of Bteq and its working fine.
It's still not working when calling from the Bteq script.
I tried the following:
1) .if activitycount >0 then .os command C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'
2) .if activitycount >0 then .os C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'
3) .if activitycount >0 then .os EXEC C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'
4) .if activitycount >0 then .os system C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'
5) .if activitycount >0 then .os C:\windows\system32\windowspowershell\v1.0\powershell.exe
None of the above are working; saying "system call failed".
Have anyone done something similar, like invoking unix shell script from bteq script ?
Thanks,
Calling Power Shell Script from within Bteq script - response (3) by bp0308
Hi,
It worked !!
here is what worked for me:
.if activitycount >0 then .os CMD/c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy remotesigned -File E:\your_folder\..\yourscript.ps1
Thanks Raja !
need sql help.. - forum topic by skchintha
need sql help.. - response (1) by skchintha
hi,
i have sql with union all condition .this sql brings Previous year and last year data.
But i need difference of previous year and last year.
ex: i need difference of Count(distinct CARDNUMBER) as Shoppers - Count(distinct CARDNUMBER) as Shoppers .
Count(distinct CARDNUMBER) as Shoppers this is coming from second select statement i.e previous year and
Count(distinct CARDNUMBER) as Shoppers this is coming from first select statemetn i.e this year.
Please can any one give me correct syntax how to achieve it.
here the orginal sql:
Select YR, Cat, Shoppers, Trans, Price, Units, Cost, Adj
From
(
SELECT 'TY' as YR, CAT_SEGMENT as Cat, Count(distinct CARDNUMBER) as Shoppers, Sum(TRANSCOUNT) as Trans, Sum(EXTENDEDPRICE) as Price, Sum(UNITS) as Units, Sum(EXTENDEDCOST) as Cost,
Sum(ADJUSTMENTAMOUNT) as Adj
FROM xyz
Where
businessdate = '2014-01-21'
and state in ('AZ','CA','WA')
and INVLD_CARDNUM_FLG = 'N'
and TransCount is not Null
and TransCount <> 0
Group By 1, 2
UNION ALL
SELECT 'PY' as YR, PY_CAT_SEGMENT as Cat, Count(distinct CARDNUMBER) as Shoppers, Sum(PY_TRANSCOUNT) as Trans, Sum(PY_EXTENDEDPRICE) as Price, Sum(PY_UNITS) as Units, Sum(PY_COST) as Cost,
Sum(PY_ADJUSTMENTAMOUNT) as Adj
FROM xyz
Where
businessdate = '2014-01-21'
and state in ('AZ','CA','WA')
and INVLD_CARDNUM_FLG = 'N'
and PY_TRANSCOUNT is not Null
and PY_TRANSCOUNT <> 0
Group By 1, 2
) a
Teradata New Bie - forum topic by praveen Alapati
Hi Guru's,
I am New to Teradata,
can any one provide me some documents on terdata basics or Terdata User Guide manual
Thanks in Advance...
Teradata New Bie - response (1) by Raja_KT
Hi,
You can see here:
http://www.info.teradata.com/edownload.cfm?itemid=131540003
and there are more docs too.
Cheers,
need sql help.. - response (2) by teradatauser2
Select YR, Cat, Shoppers-Shoppers1, Trans, Price, Units, Cost, Adj
from
(
SELECT 'TY' as YR, CAT_SEGMENT as Cat, Count(distinct CARDNUMBER) as Shoppers, Sum(TRANSCOUNT) as Trans, Sum(EXTENDEDPRICE) as Price, Sum(UNITS) as Units, Sum(EXTENDEDCOST) as Cost,
Sum(ADJUSTMENTAMOUNT) as Adj
,
SELECT 'PY' as YR, PY_CAT_SEGMENT as Cat, Count(distinct CARDNUMBER) as Shoppers1, Sum(PY_TRANSCOUNT) as Trans, Sum(PY_EXTENDEDPRICE) as Price, Sum(PY_UNITS) as Units, Sum(PY_COST) as Cost,
Sum(PY_ADJUSTMENTAMOUNT) as Adj
FROM xyz
Where
businessdate = '2014-01-21'
and state in ('AZ','CA','WA')
and INVLD_CARDNUM_FLG = 'N'
and PY_TRANSCOUNT is not Null
and PY_TRANSCOUNT <> 0
Group By 1, 2
FROM xyz
Where
businessdate = '2014-01-21'
and state in ('AZ','CA','WA')
and INVLD_CARDNUM_FLG = 'N'
and TransCount is not Null
and TransCount <> 0
Group By 1, 2
) a
===
Can you try this. It will give you result as one record and then, you can find the difference in the outer query. I have not tested this, but you can give it a try and check. Also you can check something called as MDIFF - moving difference. This is a olap function that gives difference between values in different records.
Applying OLAP functions on hashrow applied column - forum topic by KVB
Hi
I am using TD13.I am calculating uniqueness fo rows usinhhashrow functions and i need to store that value as varchar in another table to apppky OLAP functions.Since hashrow being BYTE, does not allow any conversion.I got strucked at that poin.
Is there any other way fo using that to have it like a varchar column.
Transaction ABORTed due to Teradata table deadlock in Informatica - response (4) by abhi89i
Kanna,
Deadlock only happens when multiple rows with same PI index combinations are there in queue. Because INSERT values lock on a RowHash level. Same PI combination in multple records mean they will be involved for the same RowHash which puts the system in confusion which record to accept causing a Deadlock situation. So I will say, you are having duplicate records on PI index over all the sessions.
Do load serially and else follow Create View method as suggested by Irfan above.
Thanks,
AB
Need help with Unicode in DDL issue - response (14) by jnevill
sk186013: Is your step 1 something to be done on the server itself? I'd like to push this up to the folks with the access to implement. Is there any reason why this isn't already set to TRUE?
Unfortunately, setting my session character set to ASCII isn't going to fly. I need to see the data pulled back in utf8.
Please see the refernce code above where new_cust is new data, old_cust is yesterday data full outer joined based on cust_num and deriving the chane indicator (i - new record to insert, D - logical delete , U - update the changed details, N - no change)