create inserts on table data

Database

create inserts on table data

Hi!

Can you help me?
I need to create inserts on table data in order to make installation script.
I looked up in Sql Assistant, Teradata Administrator but haven't found.

it is possible to write smth on VBA or C#, but I haven't time

Thanks

Artem
3 REPLIES
N/A

Re: create inserts on table data

In SQL Assistant:

create Volatile table MyOldTable
(
Col1 Smallint Not Null
, Col2 Smallint
, Col3 Char(6))
Unique primary index (col1)
On Commit Preserve Rows
;

Insert Into MyOldTable (Col1, Col2, Col3)
Values (1,1,'One')
;
Insert Into MyOldTable (Col1, Col2, Col3)
Values (2,Null,'Twobl')
;
Insert Into MyOldTable (Col1, Col2, Col3)
Values (3,3,Null)
;
Insert Into MyOldTable (Col1, Col2, Col3)
Values (4,Null,Null)
;

Select
'Insert Into MyTable
(Col1, Col2, Col3) Values ('||
Coalesce(''''||Col1||'''','Null')
||','||
Coalesce(''''||Col2||'''','Null')
||','||
Coalesce(''''||Col3||'''','Null')
||');'
From MyOldTable
Order By Col1, Col2
;

Take the results from this select and paste into the Query window.

Re: create inserts on table data

Thanks, jimm, for your replay.
I guess i described the situation not clearly.

I have to make some procedure, programm or use functionallity of some tool to make inserts on any table in Teradata. Usually, RDBMS have management tools with such functionallity.
I used PL/SQL Developer to make such inserts in Oracle (ofcourse it is 3d party tool, but it is free for use).

But I haven't found such functionality in Teradata tools.
I started to make procedure, wich would make inserts on any table.. it uses 2 parameters: database name, table name, and works with DBC.Columns to know the structure of the table.
But my knowledge of Teradata is poor.. in Oracle I would make it much faster.

Thanks.

Artem

Re: create inserts on table data

Hi,
I am not too sure if I understood your question correctly. But one solution IF YOU ARE USING DYNAMIC inputs for Inserts in Query Assistant is:

INSERT INTO TAB A
( COL1, COL2, COL3)
SELECT (?,?,?);

When you run this query, it will prompt you to enter the values for each column dynamically. If it does not prompt you individually, it will expect a filename which means you have opted for File Import mode which is the wrong mode for single inserts.
If this is not what you were looking for, get in touch.