In my Informatica mapping, I need to do the following activities:
creating 'A' volatile table
inserting records into 'A' table, from 'B' normal table
again I want to insert records into 'C' normal table using 'A' volatile table.
If my question is not clear, just post your comments and I will try to clarify it.
Do you have any logic to impliment after creating the volatile table? what kind of logic(Simple/Complex)? Based on my understanding, here is what you can do. Let me know if you are looking for something else.
You can do this in 2 ways.
create a Stored proc which creates volatile table based on other Multiset table, Impliment logic (If any ) then push it over to Other Multiset table (C)
Read from B, Use SQL transformation to create Volatile table, and then insert to Volatile table
use volatile table as source and use rest of the transformations and then to Table C.
Related
My Teradata query creates a volatile that is used to join to existing views. When linking query to excel the following error pops up: "Teradata: [Teradata Database] [3932] Only an ET or null statement is legal after a DDL Statement". Is there a workaround for this for someone that does not have write permissions in teradata to create a real view or table? I want to avoid linking to Teradata in SQL and running an open query to pull in the data needed.
This is for Excel 2016 64bit and using Teradata version 15.10.1.12
Normally this error will occur if you are using ANSI mode or have issued a BT (Begin Transaction) in BTET mode.
Here are a few workarounds to try:
Issue an ET; statement (commit) after the create volatile table statement. If you are using ANSI mode, use COMMIT; instead of ET;. If you are unsure, try each one in turn. Only one will be valid but both do the same thing. Make sure your Volatile table includes ON COMMIT PRESERVE ROWS
Try using BT ET mode (a.k.a. Teradata mode) when establishing the session. I do not remember where but there will be a setting in the ODBC configuration for this.
Try using a Global Temporary table. These work similarly to Volatile tables except you define them once and the definition sticks around. That is, you can create it in, say BTEQ, or SQL assistant etc. The definition is common to all users and sessions (i.e. your Excel session), but the content is transient and unique to each session (like a volatile table).
Move the select part of your insert into the volatile table into the query that selects the data from the volatile table. See simple example below.
If you do not have create Global Temporary table permissions, ask your DBA.
Here is a simple example to illustrate point 4.
Current:
create volatile table tmp (id Integer)
ON COMMIT PRESERVE ROWS;
insert into tmp
select customer_number
from customer
where X = Y and yr = 2019
;
select a,b,c
from another_tbl A join TMP T ON
A.id = T.id
;
Becomes:
select a,b,c
from another_tbl A join (
select customer_number
from customer
where X = Y and yr = 2019
) AS T
ON
A.id = T.id
;
Or better yet, just Join your tables directly.
Note The first sequence (create table, Insert into and select) is a three statement series. This will return 3 "result sets". The first two will be row counts the last will be the actual data. Most programs (including I think Excel) can not process multiple result set responses. This is one of the reasons it is difficult to use Teradata Macros with client tools like Excel.
The latter solution (a single select) avoids this potential problem.
I have a VOLATILE TABLE in teradata that i created with the code below
CREATE VOLATILE TABLE Temp
(
ID VARCHAR(30),
has_cond INT
) ON COMMIT PRESERVE ROWS;
I want to insert records from a select statement that i have created which is a pretty big SQL statement and definitely requires a row lock before proceeding
INSERT INTO Temp
(ID ,has_cond)
SELECT * FROM....
Can anyone tell me how to safely lock the rows so i can insert the records into my VOLATILE TABLE as they are production tables and i don't want to lock out some ETL that might be happening in the background
I don't think you can apply a row lock for an insert unless you put the select in a view.
Or you switch to lock table, but don't forget to include all tables...
But in most production environments there's a database with 1-1-views including lock row access, you can use those (or you might already, check Explain).
I have a requirement that I need to store a list of parameters. The parameters will be input as a csv file. They will be inserted into a table if not already existing. I have got a suggestion that I can import this data into a volatile table and use a sql query like:
insert into table permvariables
select * from tempvariables
minus
select * from permvariables;
Where tempvariables is my volatile table and permvariables is my permanent table. Will this solution work? Is there a better way to do it?
Instead of MINUS simply use a
MERGE INTO permvariables AS tgt
USING tempvariables AS src
ON tgt.pk_column(s) = src.pk_column(s)
WHEN NOT MATCHED INSERT VALUES (src.pk_column(s), src.cola, ...)
I want to create a temp table in my trigger to store some of the data. I did some research online and most people suggest that I create it by using the following query:
create #tempTableName (x datatype, y datatype..);
or
select * into #tempTableName from ...;
However, when I did it myself in oracle, it does not work and it seems to suggest me that I can name a table start with "#". What should I do in such circumstance? Also, what is the difference between a PL/SQL table and a temp table? Thanks.
Can any one depict a simple example for using temporary tables in stored procedure for updating two tables in mysql?
Two kind of temporary tables available. One is session based and the other one is global temporary table.
Below is the simple example:
Select A,b,c into #MyTemp From MyDbTable
In the above example, #myTemp is the temporary table that you are creating. MyDbTable is the one that exist in your database. You can create multiple temporary tables.
I would suggest reading the article from here: Link
--Create a temp table and insert all these counts in it
Create Table #OperatorReportCount(Id int identity,Particulars varchar(100),NoOfArticles int)
--Insert these values in table
Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles processed',#ProcessedArticleCount)
Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles approved',#ArticlesApproved)
Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles rejected',#ArticleRejectedCount)
Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Rejections recieved',#RejectionsRecievedCount)
Insert Into #OperatorReportCount(Particulars,NoOfArticles) Values('Articles put on hold',#ArticlesOnHoldCount)
--Select the operator count table
Select Particulars,NoOfArticles From #OperatorReportCount