Teradata Parallel Transporter TPT API - response (5) by MarkJBrayshaw
Null accepted in column defined as Not null - response (1) by CarlosAL
Hi:
'00'xC is not a Teradata NULL. You can insert '00'xC in a NOT NULL CHAR column.
oReplace is returning white spaces for the '00'xC (it does nor replace them at all) and the trim removes them. That's why you see 0 as result.
BTW: I don't think you can use NULL as a parameter in oReplace with the results that you expect.
HTH.
Cheers.
Carlos.
JOIN ACCESS ROWS - forum topic by Teradata_SA
How is the value for Join Acess Rows Calculated ?
I have attached the link to the teradata example here but cannot work out how they get to the value of 1,400,000.
http://www.info.teradata.com/HTMLPubs/DB_TTU_14_00/index.html#page/Database_Management/B035_1094_111A/ch06.047.069.html
Thanks Guys !
swapping values in a column oracle SQL plus - forum topic by arwa
hi.
I want to know how to swap two values in a column in oracle sql table in a single query.
suppose I have a table emp which has a column job.
In job there are values 'CLERK' and 'SALESMAN' and others as well.
I want to swap 'SALESMAN' and 'CLERK'.
I did it with three queries.
update emp set job='salesman' where job='SALESMAN';
update emp set job='SALESMAN' where job='CLERK';
update emp set job='CLERK' where job='salesman';
I want to know how to do it in a single query or any other professional way to do it, as I am a student.
thanks in anticipation
Dynamic DCL statement execution - forum topic by gskaushik
Hi ,
I am trying to create a procedure to grant role to the users based on the user id inputted.
but it is not working .
Kindly do help me in debugging the same
Teradata Version - 13.10
Procedure code -
REPLACE PROCEDURE RL(
IN UID VARCHAR(10))
BEGIN
GRANT "VWSROLE","RPTROLE" TO UID ;
END;
I am new to writing SP for Teradata , do guide me on the same
regards,
Subramanian kaushik Gurumoorthy
Dynamic DCL statement execution - response (1) by Glass
GS,
This shold get you started.
REPLACE PROCEDURE UADMIN.SP_CHG_ROLE (
IN IUSERNAME CHAR(30) ,
IN IROLENAME CHAR(30))
MAIN: BEGIN
DECLARE VCMD VARCHAR(4096) DEFAULT '';
SET VCMD ='GRANT '||TRIM(IROLENAME)||' TO '||TRIM(IUSERNAME)||';';
CALL DBC.SYSEXECSQL(:VCMD);
SET VCMD ='MODIFY USER '||TRIM(IUSERNAME)||' AS
DEFAULT ROLE = '||TRIM(IROLENAME)||';';
CALL DBC.SYSEXECSQL(:VCMD);
END MAIN;
Rglass
swapping values in a column oracle SQL plus - response (1) by dnoeth
You can do it with a single query using CASE:
update emp set job= case job when 'SALESMAN' then 'CLERK' when 'CLERK' then 'SALESMAN' END where job in ('CLERK', 'SALESMAN')
ERROR IN CASTING DECIMAL TO INTEGER - forum topic by yuvana
hi I have a TABLE1 with this structure
CREATE MULTISET TABLE DB1 .TABLE1 ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
PRODUCT_NBR INTEGER
)
I have another Table2 with this structure
CREATE MULTISET TABLE DB2 .TABLE2 ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
PRODUCT_NBR UPC_NBR DECIMAL(14,0) NOT NULL COMPRESS (2200000512. ,3700016896. ,1. ,7072000513. ,40000004865. ,2. ,2200000514. ,4000000003. ,40000004869. ,5042811398. ,4177153798. ,449542. ,7410098184. ,407560. ,4900001801. ,3700033547. ,61126981899. ,7336070925. ,3400004878. ,5200032016. ,2820000784. ,5042870803. ,5042807571. ,40000004883. ,5042827029. ,7800008216. ,5042807577. ,3457587996. ,4000000031. ,4000000032. ,2820000801. ,7097044770. ,1060. ,4000015140. ,4900000551. ,78616201000. ,3600028200. ,4000000296. ,5042808618. ,3800000810. ,4900000044. ,5042838572. ,4900000045. ,9005. ,4900000046. ,3400008752. ,7800008240. ,5042838577. ,9010. ,5042805555. ,4000000051. ,2820000819. ,7800008246. ,3700013878. ,78616211000. ,5200024121. ,5200024123. ,730683. ,7084781116. ,90000099900. ,61126999100. ,4133341501. ,5400016447. ,1070006080. ,3700035907. ,9030. ,7084781126. ,3500000839. ,5042804808. ,78616233800. ,5200032585. ,5042815561. ,4900002890. ,3400000330. ,4900002891. ,4900002892. ,5400010060. ,7800011340. ,3600067662. ,5042882895. ,5042800721. ,5200033875. ,5042820947. ,3400008788. ,5200033876. ,5200033877. ,40000000344. ,5042807897. ,40000002649. ,61300871771. ,4190002012. ,90088599900. ,6827493471. ,1120. ,1200080994. ,1200080995. ,5400044132. ,9060. ,1200080996. ,4000000101. ,2820000357. ,2820000869. ,61300871526. ,4000000102. ,4000000105. ,5042828905. ,5042801258. ,7572043115. ,2820000363. ,7072000109. ,40000011377. ,40000003700. ,4900002934. ,5042864503. ,3400040568. ,6700000890. ,3700007548. ,3400007038. ,4900000639. ,5042805887. ,78616208000. ,2820000384. ,2840008321. ,1200000129. ,9090. ,1200000130. ,3400054402. ,7572033411. ,1200000131. ,5042810245. ,7160000901. ,90000099974. ,1200000134. ,4900003719. ,1230000007. ,1600027527. ,2800001159. ,40000005511. ,5400042120. ,90000099976. ,40000005512. ,78616220043. ,3400017038. ,90000099982. ,7800015246. ,4000000144. ,4900005010. ,4900005011. ,90000099987. ,4460002452. ,7800008340. ,5042803349. ,452501. ,5042861206. ,4900000663. ,5042807447. ,4900005015. ,5042808215. ,90000099993. ,7572000409. ,5042803866. ,9451441050. ,5042861211. ,5042804892. ,9451441052. ,3700028316. ,157. ,9451441053. ,1200000157. ,4000023454. ,4900004255. ,4000023455. ,1200000159. ,4000000160. ,5200032673. ,5042811555. ,3700028839. ,5042854312. ,5042832553. ,3400000686. ,5200032431. ,3700000175. ,5042861231. ,4000000432. ,3500049840. ,5042804657. ,3700000177. ,3700010673. ,2840007858. ,3700000178. ,5042878645. ,3700000181. ,4127197110. ,452535. ,3400000440. ,5042800572. ,2610000573. ,9150. ,2610000575. ,3700038592. ,2840007874. ,3700000194. ,61300871876. ,5042809285. ,5042823110. ,8813099463. ,8813099464. ,89059200200. ,7036000200. ,2840007881. ,9148600009. ,5042854349. ,3600028110. ,5042826447. ,4900000977. ,2820000465. ,1070080722. ,5042869460. ,78616215000. ,3400017115. ,61126910171. ,2820000477. ,4900004574. ,2820000478. ,4900004575. ,3400000480. ,2200000483. ,5100001251. ,2200000484. ,2200000486. ,1200000230. ,1200000231. ,5042807528. ,2200000488. ,5042807529. ,1200000233. ,1005. ,7036000237. ,4400000750. ,3400000239. ,3400000240. ,3400000241. ,1010. ,2410022642. ,4900004086. ,4400000758. ,3400000246. ,7504400120. ,471545. ,61300871930. ,5042807547. ,4177833467. ,4900000764. ,45042800124. ,99999999. )
)
NOW the error I am getting is
When I am trying to insert this PRODUCT_NBR column from DB2.TABLE2 to DB1.TABLE1
I am getting the error as 'INSERT Failed. 2616:Numeric overflow occurred during computation.
I Tried CAST(CAST(upc_number AS CHAR(10)) AS INTEGER) but, the same error message its showing.
Can any one help me to cast it .
Thank you
Yuvana
ERROR IN CASTING DECIMAL TO INTEGER - response (1) by dnoeth
Well, a decimal has a range of +/+ 2**31, of course a 14-digit decimal doesn't fit.
ERROR IN CASTING DECIMAL TO INTEGER - response (2) by yuvaevergreen
Try bigint
ERROR IN CASTING DECIMAL TO INTEGER - response (3) by yuvana
is there any possibility to cast it .
Hi Dietier.
Thank you for reply. Is there any possibility to cast it
Yuvana
Partition - forum topic by KVB
Hi ,
I have a partitioned table from 2013 and having almost 550 partitions.Most of the data looks redundant except the load date.So ,planning to identify the changes and remove the same attribute records and dump into a non-partitioned table.
What's the best approach to workout?
Example:
CREATE TABLE HODS
(
ACCNO INTEGER,
ACCNAME VARCHAR2(10),
SAL DECIMAL(7,2),
EFFDT DATE
);
INSERT INTO HODS VALUES(1,'KVB',100,'01-JAN-15');
INSERT INTO HODS VALUES(1,'KVB',100,'02-JAN-15');
INSERT INTO HODS VALUES(1,'KVB',100,'03-JAN-15');
INSERT INTO HODS VALUES(1,'KVB',200,'04-JAN-15');
INSERT INTO HODS VALUES(1,'KVB',200,'05-JAN-15');
INSERT INTO HODS VALUES(1,'KVB',100,'06-JAN-15');
INSERT INTO HODS VALUES(1,'KVB',100,'07-JAN-15');
INSERT INTO HODS VALUES(1,'KVB',200,'08-JAN-15');
COMMIT;
Expected Output:
1,KVB,100,01-JAN-15
1,KVB,200,04-JAN-15
1,KVB,100,06-JAN-15
1,KVB,200,08-JAN-15
Regards
KVB
ERROR IN CASTING DECIMAL TO INTEGER - response (4) by dnoeth
Hi Yuvana,
of course there's no way to cast a 14 digit number to an integer (and stripping of some digits by casting to a varchar(10) will result in garbage).
You need to change the target table definition to either DEC(14,0) or BIGINT.
ERROR IN CASTING DECIMAL TO INTEGER - response (5) by yuvana
Thank you Dietier.
Yuvana
How to read each row until get to the point to determine if it is paid or overpaid or partially paid - forum topic by angelcake
How do I read each line to determine if the customer has fully paid or partially paid or never paid?
I would like the code to read every line of each customer's bill until I find the TOTAL_PAYMENT_AMT = TOTAL_DUE. If found, then mark it as paid, if not found, read the next line until I found the TOTAL_PAYMENT_AMT <> 0 and TOTAL_PAYMENT_AMT + TOTAL_ADJ_AMT < TOTAL_DUE then mark it as partially paid or if the TOTAL_PAYMENT_AMT +TOTAL_ADJ_AMT > TOTAL_DUE, then mark it as paid.
For customer 111, the bill is fully paid -13129.54 from reading the first line. But for customer 222, the bill has not paid until the 2nd month for the amount of -27000.00 and for cumster 333, the bill is paid partially the 2nd and the 3rd month. For customer 444, the bill has never paid.(negative # means paid, positive # means extra amount charged)
This is the result I got from joining tables using rank over()
SELECT CUSTOMER_ID, BILL_DATE , TOTAL_DUE TOTAL_ADJ_AMT TOTAL_PAYMENT_AMT
FROM TABLE1
QUALIFY RANK() OVER(PARTITION BY CUSTOMER_ID ORDER BY BILL_DATE ASC) =1
LEFT JOIN
SELECT CUSTOMER_ID, BILL_DATE , TOTAL_DUE TOTAL_ADJ_AMT TOTAL_PAYMENT_AMT
FROM TABLE1
QUALIFY RANK() OVER(PARTITION BY CUSTOMER_ID ORDER BY BILL_DATE ASC) > 1
CUSTOMER_ID BILL_DATE TOTAL_DUE TOTAL_ADJ_AMT TOTAL_PAYMENT_AMT
111 3/19/2015 13129.54 0 -13129.54
111 4/20/2015 13129.54 0 0
222 3/25/2015 26334.12 384.00 0
222 4/24/2015 26334.12 -27000.00
333 2/25/2015 12720.21 625 0
333 3/25/2015 12720.21 407 -1000.00
333 4/24/2015 12720.21 0 -1071.15
444 2/26/2015 12266.6 0 0
444 3/26/2015 12266.6 0 0
Derived table error / object contains restricted characters - forum topic by shaves
with drvd_amts (acct_nbr, grp_br_ps_org_id, PSAmt) as (select d.acct_nbr, d.grp_br_ps_org_id, sum(d.pstd_ttl_amt) as PSAmt from psfs.ps_gl_acct_ldgr d where d.fiscal_yr_mth_nbr between 201500 and 201508 and d.acct_nbr between 130500 and 160500 group by d.grp_br_ps_org_id, d.acct_nbr) SELECT a.FA_ACCT, a.ERACBR, a.deptid, a.FA_AMT, da.PSAmt, CASE WHEN da.PSAmt IS NULL THEN a.FA_AMT ELSE a.FA_AMT - da.PSAmt END AS DIFF FROM (SELECT pdr.account_fa AS FA_ACCT, ir.erac_branch_lgcy_cd AS ERACBR, pdr.deptid, SUM(pdr.COST) AS FA_Amt FROM PSFS.PS_DEPR_RPT pdr LEFT JOIN INTGRT_RPT.DIM_LOCATION ir ON pdr.deptid = ir.erac_branch_ps_org_cd AND ir.curr_lrd_row_flg = 1 INNER JOIN RFS.STN_OPS_HIERARCHIES soh ON pdr.deptid = soh.department WHERE pdr.BUSINESS_UNIT = 'A0465' AND pdr.BOOK = 'PERFORM' AND pdr.FISCAL_YEAR = 2015 AND pdr.ACCOUNTING_PERIOD = 8 AND pdr.GROUP_ASSET_FLAG <> 'M' --AND ( ? is null or soh.REGION_CD = ?) GROUP BY FA_ACCT, ERACBR, deptid UNION All SELECT pdr.account_ad AS FA_ACCT, ir.erac_branch_lgcy_cd AS ERACBR, pdr.deptid, SUM(pdr.depr_ltd) AS FA_Amt FROM PSFS.PS_DEPR_RPT pdr LEFT JOIN INTGRT_RPT.DIM_LOCATION ir ON pdr.deptid = ir.erac_branch_ps_org_cd AND ir.curr_lrd_row_flg = 1 INNER JOIN RFS.STN_OPS_HIERARCHIES soh ON pdr.deptid = soh.department WHERE pdr.BUSINESS_UNIT = 'A0465' AND pdr.BOOK = 'PERFORM' AND pdr.FISCAL_YEAR = 2015 AND pdr.ACCOUNTING_PERIOD =8 AND pdr.GROUP_ASSET_FLAG <> 'M' --AND ( ? is null or soh.REGION_CD = ?) GROUP BY FA_ACCT, ERACBR, deptid ) a LEFT JOIN drvd_amts da ON a.deptid =da.grp_br_ps_org_id AND a.fa_acct = da.acct_nbr GROUP BY 1,2,3,4,5,6 HAVING DIFF <> 0 UNION SELECT daq.acct_nbr AS FA_ACCT, ir.erac_branch_lgcy_cd AS ERACBR, daq.grp_br_ps_org_id, b.FA_AMT, daq.PSAmt, CASE WHEN b.fa_amt IS NULL THEN daq.psamt ELSE b.FA_AMT – daq.psamt END AS DIFF FROM drvd_amts daq LEFT JOIN INTGRT_RPT.DIM_LOCATION ir ON daq.grp_br_ps_org_id = ir.erac_branch_ps_org_cd AND ir.curr_lrd_row_flg = 1 LEFT JOIN (SELECT pdr.account_fa AS FA_ACCT, pdr.deptid, SUM(pdr.COST) AS FA_Amt FROM PSFS.PS_DEPR_RPT pdr INNER JOIN RFS.STN_OPS_HIERARCHIES soh ON pdr.deptid = soh.department WHERE pdr.BUSINESS_UNIT = 'A0465' AND pdr.BOOK = 'PERFORM' AND pdr.FISCAL_YEAR = 2015 AND pdr.ACCOUNTING_PERIOD = 8 AND pdr.GROUP_ASSET_FLAG <> 'M' --AND ( ? is null or soh.REGION_CD = ?) GROUP BY FA_ACCT, deptid UNION All SELECT pdr.account_ad AS FA_ACCT, pdr.deptid, SUM(pdr.depr_ltd) AS FA_Amt FROM PSFS.PS_DEPR_RPT pdr INNER JOIN RFS.STN_OPS_HIERARCHIES soh ON pdr.deptid = soh.department WHERE pdr.BUSINESS_UNIT = 'A0465' AND pdr.BOOK = 'PERFORM' AND pdr.FISCAL_YEAR = 2015 AND pdr.ACCOUNTING_PERIOD = 8 AND pdr.GROUP_ASSET_FLAG <> 'M' --AND ( ? is null or soh.REGION_CD = ?) GROUP BY FA_ACCT, deptid) b ON daq.grp_br_ps_org_id = b.deptid AND daq.acct_nbr = b.fa_acct Where ir.ody_group_cd = 'A0465' GROUP BY 1,2,3,4,5,6 HAVING DIFF <> 0 ORDER BY 1, 3
I'm trying to use a derived table for the first time and am getting an error message that says "SELECT failed 6725 object name contains restricted characters". I'm not sure what is wrong. I've included the SQL below. Any help would be greatly appreciated. Thank You
Derived table error / object contains restricted characters - response (1) by dnoeth
Don't know how you typed it (did you write the code in MS Word?), but in line 85 there's an illegal character:
ELSE b.FA_AMT – daq.psamt END AS DIFF
The '-' is not U+002D HYPHEN-MINUS
but U+2013 EN DASH
, simply replace it.
Partition - response (1) by dnoeth
What's your Teradata release?
In TD14.10 this could be done with an INS/SEL into a normalized table or using
SELECT ACCNO, ACCNAME, SAL, BEGIN(pd) FROM ( SELECT NORMALIZE ACCNO, ACCNAME, SAL, PERIOD(EFFDT, EFFDT + 1) AS pd FROM HODS ) AS dt
Before TD14.10 it's more complicated, e.g. using the TD_NORMALIZE_MEET function:
WITH cte(ACCNO, ACCNAME, SAL, pd) AS ( SELECT ACCNO, ACCNAME, SAL ,PERIOD(EFFDT, EFFDT + 1) AS pd FROM HODS ) SELECT ACCNO, ACCNAME, SAL ,BEGIN(Pd) FROM TABLE (TD_NORMALIZE_MEET (NEW VARIANT_TYPE(cte.ACCNO, cte.ACCNAME, cte.SAL) ,cte.pd) RETURNS (ACCNO INTEGER ,ACCNAME VARCHAR(10) ,SAL DECIMAL(7,2) ,pd PERIOD(DATE)) HASH BY ACCNO, ACCNAME, SAL LOCAL ORDER BY ACCNO, ACCNAME, SAL, pd ) AS dt
Execute Teradata Stored Procedure from SQL Server - response (1) by Fred
A stored procedure can only be called in the same mode (Teradata BTET or ANSI) used to define the procedure. Change the Session Mode option in the ODBC DSN configuration.
DBC.ColumnsV ColumnFormat - forum topic by mojave
Can anyone suggest documentation anywhere to help me decipher the DBC.ColumnsV ColumnFormat column? For example, a float column with ColumnFormat -9.99999999999999E-999? Or an Integer column with -(10)9? What exactly is that telling me? Or a Decimal column with -(32)9.9(6)? Or a Decimal column with ----------9.?
I need to get the latest patch of the TPT API to help with a problem with Informatica, Looking on the T@YS site I can find the TTU for 14.10 that has the latest levels for GSS, ICU and CLI, but there is no mention of the TPT API itself. Can anyone tell me where to find the TPT API software?