sql loaded for decimal numbers is going to warning - sql-loader

In my csv file i am having decimal number. I am trying to insert data but the concurrent program is going to warning. In the log Error "Record 1: Rejected - Error on table HR_SAL_DATA_TMP, column CHANGE_PERCENTAGE1.
ORA-01722: invalid number". In my control file i have used DECIMAL EXTERNAL but still it is giving the same error. I would be highly obliged If any one helps me out.

I had similar problem and the reason was mismatched data types in the database. Cross-check the data types of your columns and the ones in datafile

The reason might be connected to NLS settings, try this:
CHANGE_PERCENTAGE1 "TO_NUMBER (:CHANGE_PERCENTAGE1, '999999999D9', 'NLS_NUMERIC_CHARACTERS='',.''')",

Related

Difficulties creating CSV table in Google BigQuery

I'm having some difficulties creating a table in Google BigQuery using CSV data that we download from another system.
The goal is to have a bucket in the Google Cloud Platform that we will upload a 1 CSV file per month. This CSV files have around 3,000 - 10,000 rows of data, depending on the month.
The error I am getting from the job history in the Big Query API is:
Error while reading data, error message: CSV table encountered too
many errors, giving up. Rows: 2949; errors: 1. Please look into the
errors[] collection for more details.
When I am uploading the CSV files, I am selecting the following:
file format: csv
table type: native table
auto detect: tried automatic and manual
partitioning: no partitioning
write preference: WRITE_EMPTY (cannot change this)
number of errors allowed: 0
ignore unknown values: unchecked
field delimiter: comma
header rows to skip: 1 (also tried 0 and manually deleting the header rows from the csv files).
Any help would be greatly appreciated.
This usually points to the error in the structure of data source (in this case your CSV file). Since your CSV file is small, you can run a little validation script to see that the number of columns is exactly the same across all your rows in the CSV, before running the export.
Maybe something like:
cat myfile.csv | awk -F, '{ a[NF]++ } END { for (n in a) print n, "rows have",a[n],"columns" }'
Or, you can bind it to the condition (lets say if your number of columns should be 5):
ncols=$(cat myfile.csv | awk -F, 'x=0;{ a[NF]++ } END { for (n in a){print a[n]; x++; if (x==1){break}}}'); if [ $ncols==5 ]; then python myexportscript.py; else echo "number of columns invalid: ", $ncols; fi;
It's impossible to point out the error without seeing an example CSV file, but it's very likely that your file is incorrectly formatted. As a result, one typo confuses BQ into thinking there are thousands. Let's say you have the following csv file:
Sally Whittaker,2018,McCarren House,312,3.75
Belinda Jameson 2017,Cushing House,148,3.52 //Missing a comma after the name
Jeff Smith,2018,Prescott House,17-D,3.20
Sandy Allen,2019,Oliver House,108,3.48
With the following schema:
Name(String) Class(Int64) Dorm(String) Room(String) GPA(Float64)
Since the schema is missing a comma, everything is shifted one column over. If you have a large file, it results in thousands of errors as it attempts to inserts Strings into Ints/Floats.
I suggest you run your csv file through a csv validator before uploading it to BQ. It might find something that breaks it. It's even possible that one of your fields has a comma inside the value which breaks everything.
Another theory to investigate is to make sure that all required columns receive an appropriate (non-null) value. A common cause of this error is if you cast data incorrectly which returns a null value for a specific field in every row.
As mentioned by Scicrazed, this issue seems to be generated as some file rows has an incorrect format, in which case it is required to validate the content data in order to figure out the specific error that is leading this issue.
I recommend you to check the errors[] collection that might contains additional information about the aspects that can be making to fail the process. You can do this by using the Jobs: get method that returns detailed information about your BigQuery Job or refer to the additionalErrors field of the JobStatus Stackdriver logs that contains the same complete error data that is reported by the service.
I'm probably too late for this, but it seems the file has some errors (it can be a character that cannot be parsed or just a string in an int column) and BigQuery cannot upload it automatically.
You need to understand what the error is and fix it somehow. An easy way to do it is by running this command on the terminal:
bq --format=prettyjson show -j <JobID>
and you will be able to see additional logs for the error to help you understand the problem.
If the error happens only a few times you just can increase the number of errors allowed.
If it happens many times you will need to manipulate your CSV file before you upload it.
Hope it helps

SSIS 2012 extracting bool from .csv failing to insert to db "returned status 2"

Hi all quick question for you.
I have an SSIS2012 package that is reading a flat file (.csv) and is loading it into a SQL Server database table. However, I am getting an error for one of the columns when loading the OLEDB Destination:
[Flat File Source [32]] Error: Data conversion failed. The data conversion for column "Active_Flag" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
I am wondering if this is because in the flat file (which is comma delimited), the values are literally spelled out "TRUE" or "FALSE". The advanced page on the flat file properties has it set to "DT_BOOL" which I thought was right. It was on DT_STRING originally, and that wasn't working either.
In the SQL server table the column is set up as a bit, and allows nulls. Is this because it is literally typed out TRUE/FALSE? What's the easiest way to fix this?
Thanks for any advice!
It actually turned out there was a blank space in front of "True"/"False" in the file. Was just bad data and I missed it. Fixing that solved my issue. Thank you though, I did try that and when that didn't work that's when I knew it was something else.

An error occurred while attempting to perform a type cast

Hi I am trying to load data from a csv to sql server. The data types in flat file source external and output are (DT_STR,50). I am converting them to their respective data types in a derived column and trying to send all the wrong fields to an error file. But when I am trying to load. I am getting the following error.
Error: 0xC0049064 at Data Flow Task, Derived Column [668]: An error occurred while attempting to perform a type cast.
Error: 0xC0209029 at Data Flow Task, Derived Column [668]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.
The field on which it is failing is 0.234 I am trying to convert it from (DT_STR,50) to (DT_NUMERIC,7,5). I do not understand why this is failing. Please help.
Unfortunately, SSIS throws some pretty generic errors and there are probably dozens of ways you can encounter this one.
I ran into this when I was unaware that my flat file contained a footer that contained a different set of fields than the normal data rows.
I discovered this after I redirected my error rows to a Multicast and enabled the data viewer on my output which let me see what was failing.
In my case, I could see that I had a footer with a reliable value that I could detect with a Conditional Split to skip it. After that, my numeric cast in the derived column behaved correctly.
It's likely that at least one of the values in your (DT_STR,50) field cannot fit (DT_NUMERIC,7,5) because it has more that 7 number characters. Enable a Data Viewer on the path that's inputting into the Data Conversion step and you will probably see what I mean (depending on buffer size, you will likely have to sort on the string field in question). If you don't see one that's too long, buffer though until you do and buffer again, at which time the Data Conversion step will fail.
I had this same error thrown while trying to convert an INT that was too big for the NUMERIC length and precision I was casting to.

SQL Error while importing Data From Excel [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am importing Data from excel sheet. I am struggling with the following problems -
Executing (Error) Messages Error 0xc020901c: Data Flow Task 1: There was an error with output column "Intelligence" (21) on output "Excel
Source Output" (9). The column status returned was: "Text was
truncated or one or more characters had no match in the target code
page.". (SQL Server Import and Export Wizard)
Error 0xc020902a: Data Flow Task 1: The "output column "Intelligence" (21)" failed because truncation occurred, and the
truncation row disposition on "output column "Intelligence" (21)"
specifies failure on truncation. A truncation error occurred on the
specified object of the specified component. (SQL Server Import and
Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Source - MainSheetData$" (1) returned error code 0xC020902A. The component returned a failure code when the pipeline engine called PrimeOutput().
The meaning of the failure code is defined by the component, but the
error is fatal and the pipeline stopped executing. There may be error
messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
I was banging my head against the wall with this same exact error.
Try importing into MS Access and then importing into SQL Server.
turns out it only checks first 8 rows or so of the Excel sheet..so if it decides length is 225 and later on encounters more than 225 chars an error occurs , what I did to solve the problem was make a first fake row containing the worst scenario (max of everything) and problem solved !
The first error is telling you that your source data for the Intelligence column is either longer than your target column or contains charachers that your target column cannot accept.
The second error is telling you that the Intelligence column is longer than your target column and therefore its failing. I expect this is the true issue.
You can either
expand the size of your target column to cover the larger input
or
switch the Error Output of the component to "Ignore failure" on Truncation
I was having the very same issue, and although I tried numerous suggestions from searching here, the option that worked for me was to convert the excel file to a CSV and use a bulk insert command instead.
This bypassed the need to edit mappings which wasn't working for me. I had a field that was not updating when I changed the field type.
Code below from this answer:
BULK INSERT TableName
FROM 'C:\SomeDirectory\my table.txt'
WITH
(
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n'
)
GO
Importing using CSV is difficult as the import process doesn't know the max length for any field. Therefore when it hits a row longer than the initial column length it errors.
Simply save your csv file as a excel workbook and re import. You'll need to delete an existing tables that were created before failute last time.
As it's excel, it can obtain the correct field length when creating the table.
I was getting the same error while importing from Excel to SQL Server 2008. I was able to do it by exporting from xlsx to csv and then importing the csv file into Sql Server. Yes, I had to adjust the columns length by hand but it worked just fine!
I was having the same problem and had to manually go through Excel to find the problem. One time saver, if you click Report -> View Report at the bottom, it will open up a new window. If you scroll all the way to the bottom of the report, it will tell you how many rows were processed. It doesn't necessarily mean that the problem is in the next row, but at least you can skip going through all the rows before that.
What I did next in Excel was take only the amount of characters that would fit into SQL (i.e. LEFT([Column], 255) and truncate the rest.
It is not ideal, but it worked in my case.
Export
You need to change "On Error" option to Ignore and "On Truncation" option to Ignore in Review Data Type Mapping.
This will solve the problem.
I am not sure, if anyone has tried this or not:
Copy the content of the file from excel .xls or whatever excel format it is in currently and paste it into new excel file as value. Save the file in .xlsx format and try importing again with sql server.
It will be a success!!
It is enough to place the biggest length in the first row. Then it functions.

Filemaker to SQL Server via SSIS

I'm using SSIS and trying to import data from Filelmaker into SQL Server. In the Solution Explorer, I right click on "SSIS Packages" and select SQL Server Import and Export Wizard". During the process, I use my DSN as the source, SQL Server as the destination, use a valid query to pull data from Filemaker, and set the mappings.
Each time I try to run the package, I receive the following message:
The "output column "LastNameFirst" (12)" has a length that is not valide. The length must be between 0 and 4000.
I do not understand this error exactly, but in the documentation for ODBC:
http://www.filemaker.com/downloads/pdf/fm9_odbc_jdbc_guide_en.pdf (page 47) it states:
"The maximum column length of text is 1 million characters, unless you specify a smaller Maximum number of characters for the text field in FileMaker. FileMaker returns empty strings as NULL."
I'm thinking that the data type is too large when trying to convert it to varchar. But even after using a query of SUBSTR(LastNameFirst, 1, 2000), I get the same error.
Any suggestions?
I had this problem, and don't know the cause but these are the steps I used to find the offending row:
-in filemaker, export the data to CSV
-open the CSV in excel
-double click on the LastNameFirst column to maximize its width
-scroll down until you see a column '#########' -the way excel indicates data that is too large to be displayed.
I'm sure theres a better way, and I'd love to hear it!
You should use this:
nvarchar (max)