External table syntax error KUP-01005 Oracle - sql

I receive error as below every time when i select external table that i have created.
ORA-29913: bład podczas wykonywania wywołania (callout) ODCIEXTTABLEOPEN
ORA-29400: bład kartrydza danych
KUP-00554: error encountered while parsing access parameters
KUP-01005: syntax error: found "minussign": expecting one of: "badfile, byteordermark, characterset, column, data, delimited, discardfile, dnfs_enable, dnfs_disable, disable_directory_link_check, field, fields, fixed, io_options, load, logfile, language, nodiscardfile, nobadfile, nologfile, date_cache, dnfs_readbuffers, preprocessor, readsize, string, skip, territory, variable, xmltag"
KUP-01007: at line 4 column 23
29913. 00000 - "error in executing %s callout"
The external table is created successfully. Here is the script which creates external table:
CREATE TABLE TB_CNEI_01C
(
NEW_OMC_ID VARCHAR(2),
NEW_OMC_NM VARCHAR(8),
NEW_BSS_ID VARCHAR(6),
NEW_BSS_NM VARCHAR(20),
OMC_ID VARCHAR(2),
OMC_NM VARCHAR(8),
OLD_BSS_ID VARCHAR(6),
OLD_BSS_NM VARCHAR(20),
DEPTH_NO INTEGER,
NE_TP_NO INTEGER,
OP_YN INTEGER,
FAC_ALIAS_NM VARCHAR(20),
FAC_GRP_ALIAS_NM VARCHAR(20),
SPC_VAL VARCHAR(4),
INMS_FAC_LCLS_CD VARCHAR(2),
INMS_FAC_MCLS_CD VARCHAR(3),
INMS_FAC_SCLS_CD VARCHAR(3),
INMS_FAC_SCLS_DTL_CD VARCHAR(2),
LDEPT_ID VARCHAR(3),
FAC_ID VARCHAR(15),
MME_IP_ADDR VARCHAR(20),
MDEPT_ID VARCHAR(4),
HW_TP_NM VARCHAR(20),
MME_POOL_NM VARCHAR(20),
BORD_CNT INTEGER,
FAC_DTL_CLSFN_NM VARCHAR(50),
INSTL_FLOOR_NM VARCHAR(20),
INSTL_LOC_NM VARCHAR(30)
)
ORGANIZATION EXTERNAL
(
TYPE oracle_loader
DEFAULT DIRECTORY EXTERNAL_DATA
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE
badfile EXTERNAL_DATA:'testTable.bad'
logfile EXTERNAL_DATA:'testTable.log'
CHARACTERSET x-IBM949
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
(
NEW_OMC_ID VARCHAR(2),
NEW_OMC_NM VARCHAR(8),
NEW_BSS_ID VARCHAR(6),
NEW_BSS_NM VARCHAR(20),
OMC_ID VARCHAR(2),
OMC_NM VARCHAR(8),
OLD_BSS_ID VARCHAR(6),
OLD_BSS_NM VARCHAR(20),
DEPTH_NO INTEGER,
NE_TP_NO INTEGER,
OP_YN INTEGER,
FAC_ALIAS_NM VARCHAR(20),
FAC_GRP_ALIAS_NM VARCHAR(20),
SPC_VAL VARCHAR(4),
INMS_FAC_LCLS_CD VARCHAR(2),
INMS_FAC_MCLS_CD VARCHAR(3),
INMS_FAC_SCLS_CD VARCHAR(3),
INMS_FAC_SCLS_DTL_CD VARCHAR(2),
LDEPT_ID VARCHAR(3),
FAC_ID VARCHAR(15),
MME_IP_ADDR VARCHAR(20),
MDEPT_ID VARCHAR(4),
HW_TP_NM VARCHAR(20),
MME_POOL_NM VARCHAR(20),
BORD_CNT INTEGER,
FAC_DTL_CLSFN_NM VARCHAR(50),
INSTL_FLOOR_NM VARCHAR(20),
INSTL_LOC_NM VARCHAR(30)
)
)
LOCATION ('TB_CNEI_01C.csv')
);
I have checked all permisions for data directory and data files

I had a few commented lines in my 'CREATE TABLE ..' script. I removed those commented lines and the error disappeared.
I received the above suggestion from : http://www.orafaq.com/forum/t/182288/

It seems your CHARACTERSET(x-IBM949) containing - character is not valid
You may try the other alternatives without that sign,
such as
AL32UTF8, US7ASCII, WE8MSWIN1252 .. etc.

Related

[Amazon](500310) Invalid operation: syntax error at end of input Position: 684;

CREATE EXTERNAL TABLE schema_vtvs_ai_ext.fire(
fire_number VARCHAR(50),
fire_year DATE,
assessment_datetime INTEGER,
size_class CHAR,
fire_location_latitude REAL,
fire_location_longitude REAL,
fire_origin VARCHAR(50),
general_cause_desc VARCHAR(50),
activity_class VARCHAR(50),
true_cause VARCHAR(50),
fire_start_date DATE,
det_agent_type VARCHAR(50),
det_agent VARCHAR(50),
discovered_date DATE,
reported_date DATE,
start_for_fire_date DATE,
fire_fighting_start_date DATE,
initial_action_by VARCHAR(50),
fire_type VARCHAR(50),
fire_position_on_slope VARCHAR(50),
weather_conditions_over_fire VARCHAR(50),
fuel_type VARCHAR(50),
bh_fs_date DATE,
uc_fs_date DATE,
ex_fs_date DATE
);
This is the SQL code i have written to add an external table in Redhsift schema but the below error. i can't seem to see where the error is?
[Amazon](500310) Invalid operation: syntax error at end of input Position: 684;
If your data is in Amazon S3, then you need to specify the file format (via STORED AS) and the path to data files in S3 (via LOCATION).
This is the example query for csv files (with 1 line header):
create external table <external_schema>.<table_name> (...)
row format delimited
fields terminated by ','
stored as textfile
location 's3://mybucket/myfolder/'
table properties ('numRows'='100', 'skip.header.line.count'='1');
See official doc for details.

Why deleting from a table does not work in PostgreSQL

I tried deleting a row from a table but the result was
DELETE 0
When I created a copy of the original table and performed the delete on the new copy-table
the result was: DELETE 1 as expected
I've created a trigger function that updates a column on a different table upon inserting or deleting is there an option that this is the problem?
Does anyone know what might be the problem ??
P.S. I post a similar to the creation code of the original table because it has been altered for the next parts of the university project and the trigger function's code
P.S.2 A friend who has the same exact database, table, trigger function etc.
doesn't have this problem
create table Listings(
id int,
listing_url varchar(40),
scrape_id bigint,
last_scraped date,
name varchar(140),
summary varchar(1780),
space varchar(1840),
description varchar(2320),
experiences_offered varchar(10),
neighborhood_overview varchar(1830),
notes varchar(1790),
transit varchar(1810),
access varchar(1830),
interaction varchar(1340),
house_rules varchar(1820),
thumbnail_url varchar(10),
medium_url varchar(10),
picture_url varchar(150),
xl_picture_url varchar(10),
street varchar(90),
neighbourhood varchar(20),
neighbourhood_cleansed varchar(70),
neighbourhood_group_cleansed varchar(10),
city varchar(40),
state varchar(60),
zipcode varchar(20),
market varchar(30),
smart_location varchar(40),
country_code varchar(10),
country varchar(10),
latitude varchar(10),
longitude varchar(10),
is_location_exact boolean,
property_type varchar(30),
room_type varchar(20),
accommodates int,
bathrooms varchar(10),
bedrooms int,
beds int,
bed_type varchar(20),
amenities varchar(1660),
);
CREATE FUNCTION Vs()
RETURNS "trigger" AS
$Body$
BEGIN
IF(TG_OP='INSERT')THEN
UPDATE "Host"
SET listings_count = listings_count + 1
WHERE id = NEW.host_id;
RETURN NEW;
ELSIF(TG_OP='DELETE')THEN
UPDATE "Host"
SET listings_count = listings_count -1
WHERE id = OLD.host_id;
RETURN OLD;
END IF;
END;
$Body$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER InsertTrigger
before INSERT
ON "Listing"
FOR EACH ROW
EXECUTE PROCEDURE Vs();
CREATE TRIGGER DeleteTrigger
before DELETE
ON "Listing"
FOR EACH ROW
EXECUTE PROCEDURE Vs();

Relative path error when creating external tables

My task is to create some external tables using hive beeline. But I encountered relative path error, says "Relative path in absolute URI: hdfs://localhost:8020./user/bigdata) (state=08S01,code=1)
Aborting command set because "force" is false and command failed:"
I am using a hql script(by requirement) to create external table, my script is this:
create external table ecustomer(
customer_id DECIMAL(3),
customer_code VARCHAR(5),
company_name VARCHAR(100),
contact_name VARCHAR(50),
contact_title VARCHAR(30),
city VARCHAR(30),
region VARCHAR(2),
postal_code VARCHAR(30),
country VARCHAR(30),
phone VARCHAR(30),
fax VARCHAR(30))
row format delimited fields terminated by '|'
stored as textfile location 'user/bigdata/ecustomer';
create external table eorder_detail(
order_id DECIMAL(5),
product_id DECIMAL(2),
customer_id DECIMAL(3),
salesperson_id DECIMAL(1),
unit_price DECIMAL(2,2),
quantity DECIMAL(2),
discount DECIMAL(1,1))
row format delimited fields terminated by '|'
stored as textfile location 'user/bigdata/eorder_detail';
create external table eproduct(
product_id DECIMAL(2),
product_name VARCHAR(50),
unit_price DECIMAL(2,2),
unit_in_stock DECIMAL(4),
unit_on_order DECIMAL(3),
discontinued VARCHAR(1))
row format delimited fields terminated by '|'
stored as textfile location 'user/bigdata/eproduct';
create external table esalesperson(
employee_id DECIMAL(1),
lastname VARCHAR(30),
firstname VARCHAR(30),
title VARCHAR(50),
birthdate VARCHAR(30),
hiredate VARCHAR(30),
notes VARCHAR(100))
row format delimited fields terminated by '|'
stored as textfile location 'user/bigdata/esalesperson';
create external table eorder(
order_id DECIMAL(5),
order_date VARCHAR(30),
ship_via DECIMAL(1),
ship_city VARCHAR(30),
ship_region VARCHAR(30),
ship_postal_code VARCHAR(30),
ship_country VARCHAR(30))
row format delimited fields terminated by '|'
stored as textfile location 'user/bigdata/eorder';
then, I execute this script on beeline server, however, I encountered the abovementioned error. I have already create a folder on my hadoop server for each table which are ecustomer, eorder_detail, eproduct, esalesperson and eorder. And the tables are also uploaded to hadoop server. Please help me resolve the error.
Try using an absolute path, instead of a relative one. e.g. 'hdfs://localhost:8020/user/bigdata/ecustomer'
create external table ecustomer(
customer_id DECIMAL(3),
customer_code VARCHAR(5),
company_name VARCHAR(100),
contact_name VARCHAR(50),
contact_title VARCHAR(30),
city VARCHAR(30),
region VARCHAR(2),
postal_code VARCHAR(30),
country VARCHAR(30),
phone VARCHAR(30),
fax VARCHAR(30))
row format delimited fields terminated by '|'
stored as textfile location 'hdfs://localhost:8020/user/bigdata/ecustomer';
...
[same for other DDLs]

Incorrect Syntax near '-' .(Microsoft SQL Server Native Client 10.0) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
While doing SSIS job I got an error in my create table query
Incorrect Syntax near '-' .(Microsoft SQL Server Native Client 10.0)
SQL statement:
CREATE TABLE Staging_ACD_Precision_Queue
(
PrecisionQueueID int,
BucketIntervalID int,
EnterpriseName varchar(32),
AgentOrdering int,
CallOrdering int,
Description varchar(255),
ServiceLevelThreshold int,
ServiceLevelType smallint,
ForceExpandingQueue varchar(1),
Deleted varchar(1),
ChangeStamp int,
Partner varchar(4),
Center varchar(4),
Partner-Center varchar(9),
LOB varchar(4),
Circle varchar(4),
TypeOfBusiness varchar(4)
)
I tried the above query. I guess from the error message that, the issue is in Partner-Center varchar(9) but I failed to fix this error. Since I'm new to SSIS and SQL queries I don't know to fix the issue.
You need to put square brackets around Partner-Center, e.g. [Partner-Center]. Embedded spaces or special characters are not allowed in field names, but you can escape them by putting the field name within square brackets.
CREATE TABLE Staging_ACD_Precision_Queue (
PrecisionQueueID int,
BucketIntervalID int,
EnterpriseName varchar(32),
AgentOrdering int,
CallOrdering int,
Description varchar(255),
ServiceLevelThreshold int,
ServiceLevelType smallint,
ForceExpandingQueue varchar(1),
Deleted varchar(1),
ChangeStamp int,
Partner varchar(4),
Center varchar(4),
[Partner-Center] varchar(9),
LOB varchar(4),
Circle varchar(4),
TypeOfBusiness varchar(4)
)
As others have stated here, I too would like to recommend you avoid using a hyphen in the field name and go with either Partner_Center or PartnerCenter as the field name instead of Partner-Center.
SQL Server does not allow - in bare field names. However, you can "escape" it by surrounding the field name with square brackets ([]):
CREATE TABLE Staging_ACD_Precision_Queue (
PrecisionQueueID int,
BucketIntervalID int,
EnterpriseName varchar(32),
AgentOrdering int,
CallOrdering int,
Description varchar(255),
ServiceLevelThreshold int,
ServiceLevelType smallint,
ForceExpandingQueue varchar(1),
Deleted varchar(1),
ChangeStamp int,
Partner varchar(4),
Center varchar(4),
[Partner-Center] varchar(9),
LOB varchar(4),
Circle varchar(4),
TypeOfBusiness varchar(4)
)
You can't have "-" in column names. you can do underscores. but not minus signs.
Actually you can however you have to [ ] around column name to create with a dash and everytime you want to access you have to [var]
Change
Partner-Center varchar(9),
to be
Partner_Center varchar(9),
or
[Partner-Center] varchar(9)

importing into mysql mangled

I am trying to import a CSV file into MySQL 5.0 with the following line:
LOAD DATA LOCAL INFILE 'file' INTO TABLE MYTABLE FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\'
My table schema is as follows
CREATE TABLE AUCTIONS (
ARTICLE_NO VARCHAR(20),
ARTICLE_NAME VARCHAR(100),
SUBTITLE VARCHAR(20),
CURRENT_BID DECIMAL(5,2),
START_PRICE DECIMAL(5,2),
BID_COUNT VARCHAR(20),
QUANT_TOTAL VARCHAR(20),
QUANT_SOLD VARCHAR(20),
ACCESSSTARTS VARCHAR(20),
ACCESSENDS VARCHAR(20),
ACCESSORIGIN_END VARCHAR(20),
USERNAME VARCHAR(20),
BEST_BIDDER_ID VARCHAR(20),
FINISHED TINYINT,
WATCH TINYINT,
BUYITNOW_PRICE DECIMAL(5,2),
PIC_URL VARCHAR(120),
PRIVATE_AUCTION TINYINT,
AUCTION_TYPE VARCHAR(20),
ACCESSINSERT_DATE VARCHAR(20),
ACCESSUPDATE_DATE VARCHAR(20),
CAT_DESC VARCHAR(20),
CAT_PATH VARCHAR(20),
ARTICLE_DESC TEXT,
COUNTRYCODE VARCHAR(20),
LOCATION VARCHAR(20),
CONDITIONS VARCHAR(20),
REVISED TINYINT,
PAYPAL_ACCEPT TINYINT,
PRE_TERMINATED TINYINT,
SHIPPING_TO VARCHAR(20),
FEE_INSERTION DECIMAL(5,2),
FEE_FINAL DECIMAL(5,2),
FEE_LISTING DECIMAL(5,2),
PIC_XXL TINYINT,
PIC_DIASHOW TINYINT,
PIC_COUNT VARCHAR(20),
ITEM_SITE_ID VARCHAR(20),
STARTS DATETIME,
ENDS DATETIME,
ORIGIN_END DATETIME,
PRIMARY KEY ( `ARTICLE_NO` ));
An example of the data I am trying to import, which contains intentionally snipped HTML for the ARTICLE_NAME field:
"160330609276","Ed Hardy White Tiger Panther Schuhe Gr.40 18ER103W Neu","",£40.50,£1.00,5,1,0,24/04/2009 14:41:16,27/04/2009 14:41:16,27/04/2009 14:41:16,"brand-leader-europe",0,0,0,£0.00,"http://www.modestern.de/ebay/18ER103W/Galeriebild.jpg",0,1,27/04/2009 13:43:30,27/04/2009 13:43:46,"Damenschuhe","Kleidung & Accessoires","
<!DOCTYPE html PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN""
""http://www.w3.org/TR/html4/loose.dtd"">
<html>
<head>
<title>Brand-Leader-Europe - Because Fashion is our Business</title>
<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">
</head>
<style type=""text/css"">
body {
background-color: #E2E3E0;
}
</style>
<script language=""Javascript"">
function showArtikel() {
if(document.getElementById)
document.getElementById(""artikelbeschreibung"").style.display = ""block"";
document.getElementById(""bezahlung"").style.display = ""none"";
document.getElementById(""widerrufsrecht"").style.display = ""none"";
document.getElementById(""ueberuns"").style.display = ""none"";
document.getElementById(""kontakt"").style.display = ""none"";
document.getElementById(""agb"").style.display = ""none"";
document.getElementById(""impressum"").style.display = ""none"";
}
<!-- AfterbuyListing -->",77,"Berlin",1,0,1,0,77,£0.25,£0.00,£0.25,0,0,1,77
I am not responsible for the data being imported.
This data is exported to a CSV file on a machine with no network connection, so importing into the db directly is not an option. I have tried with the ESCAPED BY clause, which does not help much.
I would like to know how I can either import the data correctly, or export the data to a CSV file in a way that can be imported directly. The CSV file is exported from a Microsoft Access 2003 database, using UTF-8, commas for delimiters, and fields enclosed by '"'.
Your LOAD is saying FIELDS TERMINATED BY ';' while everything else suggests the terminator is ',' instead, could that be the problem?