How to solve the following error for loading data - teradata

Below is my code for creating and loading data with fastload onto teradata database.
CREATE TABLE MARK,FALLBACK
(
A INTEGER NOT NULL,
B INTEGER NOT NULL,
C DATE,
D INTEGER NOT NULL,
E DECIMAL(10,2),
PRIMARY KEY (D)
) PRIMARY INDEX(A,B);
While processing the fastload script, it gives an error of
RDBMS error 3621: Cannot load table MARK
unless secondary indexes and join indexes are removed
How should I solve this kind of problem?

Related

Issue with cursor retrieving values

I am trying to use a cursor for the following block of code, but it is not compiling and giving error saying the following:
PL/SQL: SQL Statement ignored
PL/SQL: ORA-00947: not enough values
All the trxn table values are being fetched, Does anyone have faced similar error before? Any way this can be fixed or am I missing something?
I am trying to use a cursor for the following block of code, but it is not compiling and giving error saying the following:
PL/SQL: SQL Statement ignored
PL/SQL: ORA-00947: not enough values
All the trxn table values are being fetched, Does anyone have faced similar error before? Any way this can be fixed or am I missing something?
cursor bulk_select is
with trxn as (
select --+ materialize
-- Wire info
wt.id
,wt.fl
,wt.abc
,wt.xyz
from
wt_temp_t wt
where
<condition>
)
select a
,b
,c
from
(
select
w.aa
,w.bb
,w.cc
trxn w
where
<condition>
)included_trxn
-- Left joins in case the acct is null or external
left outer join table
acct a_cp,
cust c_cp
where
<condition>
type tab_bulk_select is table of bulk_select%rowtype;
cur_bulk_select tab_bulk_select;
BEGIN
EXECUTE IMMEDIATE 'truncate table AML_CAMBRS6_HUB_SPOKE_TMP';
commit;
open bulk_select;
LOOP
fetch bulk_select bulk collect into cur_bulk_select limit 50000;
FORALL i IN 1..cur_bulk_select.COUNT
insert /*+ append */ into AML_CAMBRS6_HUB_SPOKE_TMP (a,b,c)
values cur_bulk_select(i);
commit;
EXIT When bulk_select%NOTFOUND;
END LOOP;
CLOSE bulk_select;
Its because in trxn you are fetching only 2 values wt.fo_trxn_seq_id ,wt.pass_thru_fl.
But in select clause select w.aa ,w.bb, w.cc trxn w where <condition> you are using aa, bb, cc and also missing from in statement.

Sqoop trying to --split-by ROWID (Oracle) fails

(be Kind, this is my first question and I did extensive Research here and on the net beforehand. Question Oracle ROWID for Sqoop Split-By Column did not really solve this issue, as the original Person asking resorted to using another column)
I am using sqoop to copy data from an Oracle 11 DB.
Unfortunately, some tables have no index, no Primary key, only partitions (date). These tables are very large, hundreds of millions if not billions of rows.
so far, I have decided to Access data in the source by explicitly adressing the partitions. That works well and Speeds up the process nicely.
I need to do the splits by data that resides in each and every table in order to avoid too many if- branches in my bash script. (we're talking some 200+ tables here)
I notice that a split by 8 Tasks results in very uneven spread of workload among the Tasks. I considered using Oracle ROWID to define the split.
To do this, I must define a boundary-query. In a Standard query 'select * from xyz' the rowid is not part of the result set. therefore, it is not an option to let Sqoop define the boundary-query from --query.
Now, when I run this, I am getting the error
ERROR tool.ImportTool: Encountered IOException running import job:
java.io.IOException: Sqoop does not have the splitter for the given SQL
data type. Please use either different split column (argument --split-by)
or lower the number of mappers to 1. Unknown SQL data type: -8
samples of ROWID :
AAJXFWAKPAAOqqKAAA
AAJXFWAKPAAOqqKAA+
AAJXFWAKPAAOqqKAA/
it is static and unique once it is created for any row.
I cast this funny datatype into something else in my boundary-query
sqoop import -Dorg.apache.sqoop.splitter.allow_text_splitter=true --connect
jdbc:oracle:thin:#127.0.0.1:port:mydb --username $USER --P --m 8
--split-by ROWID --boundary-query "select cast(min(ROWID) as varchar(18)), cast
( max(ROWID)as varchar(18)) from table where laufbzdt >
TO_DATE('2019-02-27', 'YYYY-MM-DD')" --query "select * from table
where laufbzdt > TO_DATE('2019-02-27', 'YYYY-MM-DD') and \$CONDITIONS "
--null-string '\\N'
--null-non-string '\\N'
But then I get ugly ROWIDs that are rejected by Oracle:
select * from table where laufbzdt > TO_DATE('2019-02-27', 'YYYY-MM-DD')
and ( ROWID >= 'AAJX6oAG聕聁AE聉N:' ) AND ( ROWID < 'AAJX6oAH⁖⁁AD䁔䀷' ) ,
Error Msg = ORA-01410: invalid ROWID
how can I resolve this properly?
I am a LINUX-Embryo and have painfully chewed myself through the Topics of bash-shell-scripting and Sqooping so far, but I would like to make better use of evenly spread mapper-task workload - it would cut sqoop-time in half, I guess, saving some 5 to 8 hours.
TIA!
wahlium
You can try ROWNUM, but I think sqoop import does not work with pseudocolumn.

Make SQLite abort on first error (and sing songs)

I wanted to name this post Make SQLite abort on first error but StackOverflow's AI overlords decided it doesn't fit their conception of intelligent human behavior. For the record, I was googling exactly that, but perhaps even Google AI considered my question unworthy and didn't bother to help me. Mods, feel free to change the title according to what your AI bosses desire (if you can figure it out).
I have this script
create if not exists table entries (
id integer primary key,
start datetime not null,
end datetime not null
);
delete from entries;
insert into entries values (1, '2018-08-01 10:00', '2018-08-01 15:00');
insert into entries values (2, '2018-08-01 17:00', '2018-08-01 20:00');
insert into entries values (1, '2018-08-02 19:00', '2018-08-02 00:00');
insert into entries values (1, '2018-08-03 00:00', '2018-08-03 04:00');
insert into entries values (1, '2018-08-03 14:00', '2018-08-03 18:00');
There is a mistake in create statement. When I run the script I get
% sqlite3 db.sqlite3 <ddl.sql
Error: near line 1: near "if": syntax error
Error: near line 7: no such table: entries
Error: near line 8: no such table: entries
Error: near line 9: no such table: entries
Error: near line 10: no such table: entries
Error: near line 11: no such table: entries
Error: near line 12: no such table: entries
How do I make SQLite exit executing the script on first error it encounters? I'm looking for equivalent of set -e in Bash.
From the documentation, it looks like you can turn on the dot command .bail.
.bail on|off Stop after hitting an error. Default OFF
See also - O'Reilly Using Sqlite
Edit
To exit, you can use the .exit dot command.

RODBC Teradata Copy Table

I am using RODBC with R to connect to Teradata.
I am trying to copy a large table EXAMPLE (25GB) from the READ_ONLY database to the WORKdatabase. The two databases are under the same DB system so I only need one connection.
I have tried sqlQuery, sqlCopy and sqlCopyTablefunctions but do not succeed.
sqlQuery
EDIT: syntax error corrected as suggested by #dnoeth.
CREATE TABLE WORK.EXAMPLE AS (SELECT * FROM READ_ONLY.EXAMPLE) WITH DATA;
OR
CREATE TABLE WORK.EXAMPLE AS (SELECT * FROM READ_ONLY.EXAMPLE) WITH NO DATA;
INSERT INTO WORK.EXAMPLE SELECT * FROM READ_ONLY.EXAMPLE;
I let the latter method run for 15h but it did not complete the copy.
sqlCopy
sqlCopy(ch,
query='SELECT * FROM READ_ONLY.EXAMPLE',
destination = 'WORK.EXAMPLE')
Error: cannot allocate vector of size 155.0 Mb
Does sqlCopy try to first copy the data to R's memory before creating the new table? If so, how can I bypass this step and work exclusively on the Teradata server? Also, the error persists even if use the option fast=F.
In case R's memory was the issue, I tried creating a smaller table of 1000 rows:
sqlCopy(ch,
query='SELECT * FROM READ_ONLY.EXAMPLE SAMPLE 1000',
destination = 'WORK.EXAMPLE')
Error in sqlSave(destchannel, dataset, destination, verbose = verbose, :
[RODBC] Failed exec in Update
22018 0 [Teradata][ODBC Teradata Driver] Data is not a numeric-literal.
In addition: Warning message:
In odbcUpdate(channel, query, mydata, coldata[m, ], test = test, :
character data '2017-03-20 12:08:25' truncated to 15 bytes in column 'ExtractionTS'
With this command a table was actually created but it only includes the column names without any rows.
sqlCopyTable
sqlCopyTable(ch,
srctable = 'READ_ONLY.EXAMPLE',
desttable = 'WORK.EXAMPLE')
Error in if (as.character(keys[[4L]]) == colnames[i]) create <- paste(create, :
argument is of length zero
The syntax in your sqlQuery is not correc, the WITH DATAoption is missing:
CREATE TABLE WORK.EXAMPLE AS (SELECT * FROM READ_ONLY.EXAMPLE) WITH DATA;
Caution, this will loose all NOT NULL & CHECK constraints and all indexes, resulting in the 1st column as Non-Unique Primary Index.
Either add a PI manually or switch to
CREATE TABLE WORK.EXAMPLE AS READ_ONLY.EXAMPLE WITH DATA;
if READ_ONLY.EXAMPLE is a table and you actually want an exact copy.

Sqlite3 insert statement error

I am trying to insert the following into my sqlite3 database:
INSERT INTO candlestick_1min (timestamp, close, high, low, open, volume)
VALUES (2016-08-11 15:30:00, 34.258, 34.318, 34.258, 34.302, 45890.0);
For some reason it's giving me the following error:
Error: near "15": syntax error
The schema is the following:
CREATE TABLE candlestick_1min (timestamp TEXT PRIMARY KEY NOT NULL, close REAL, high REAL, low REAL, open REAL, volume REAL);
Can anybody tell me why the error is showing up? The table is completely empty by the way.
Put the date values inside quotes '' like
INSERT INTO candlestick_1min (timestamp, close, high, low, open, volume)
VALUES ('2016-08-11 15:30:00', 34.258, 34.318, 34.258, 34.302, 45890.0);

Resources