I am new to the CLPPlus editor and I'm trying a simple query that works if I execute it from a file like this
db2 -td% -svf C:\query.sql
and the query.sql file contains:
SELECT tx.ID,XMLQUERY('for $e in $d/Client/Address return data($e)' passing tx.contactinfo as "d") FROM clients tx %
If I just place the query as it is in the CLP or CLPPLUS editor as it is I get errors.
Error FROM CLP: SQL0104N An unexpected token "for $e in $d/Client/Ad"
was found following "LECT tx.ID,XMLQUERY(". Expected tokens may
include: "
Error from CLPPLUS: SQL16002N An XQuery expression has an unexpected
token "in" following "for ". Expected tokens may include: "is". Error
QName=err:XPST0003.
Related
I am trying to use Apache Drill to export a .csv file. This other question indicated that this is achieved by:
use dfs.tmp;
alter session set `store.format`='csv';
create table dfs.tmp.my_output as select * from cp.`employee.json`;
I tried running this block (of three commands) simultaneously in the Apache Drill web interface but got the error bellow. It somehow is not recognizing the ; or not taking multiple commands.
I also tried running each line separately, without the ; but the changes of the two commands did not persist (and the export command (3rd command) deafauted back to exporting a parquet file (the set default)).
How can I run this in Drill?
Query Failed: An Error Occurred
org.apache.drill.common.exceptions.UserRemoteException: PARSE ERROR: Encountered ";" at line 1, column 12. Was expecting one of: <EOF> "." ... "[" ... SQL Query use dfs.tmp; ^ alter session set `store.format`='csv'; create table dfs.tmp.`elos_cnis` as select * from dfs.tmp.`/bases_parquet/elos_cnis` [Error Id: 00493fbe-924e-43e9-a684-f7d1abfed04e on sbsb35.ipea.gov.br:31010] (org.apache.calcite.sql.parser.SqlParseException) Encountered ";" at line 1, column 12. Was expecting one of: <EOF> "." ... "[" ... org.apache.drill.exec.planner.sql.parser.impl.DrillParserImpl.convertException():391 org.apache.drill.exec.planner.sql.parser.impl.DrillParserImpl.normalizeException():121 org.apache.calcite.sql.parser.SqlParser.parseStmt():149 org.apache.drill.exec.planner.sql.SqlConverter.parse():157 org.apache.drill.exec.planner.sql.DrillSqlWorker.getQueryPlan():104 org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan():79 org.apache.drill.exec.work.foreman.Foreman.runSQL():1017 org.apache.drill.exec.work.foreman.Foreman.run():289 java.util.concurrent.ThreadPoolExecutor.runWorker():1142 java.util.concurrent.ThreadPoolExecutor$Worker.run():617 java.lang.Thread.run():748 Caused By (org.apache.drill.exec.planner.sql.parser.impl.ParseException) Encountered ";" at line 1, column 12. Was expecting one of: <EOF> "." ... "[" ... org.apache.drill.exec.planner.sql.parser.impl.DrillParserImpl.generateParseException():17963 org.apache.drill.exec.planner.sql.parser.impl.DrillParserImpl.jj_consume_token():17792 org.apache.drill.exec.planner.sql.parser.impl.DrillParserImpl.SqlStmtEof():861 org.apache.drill.exec.planner.sql.parser.impl.DrillParserImpl.parseSqlStmtEof():180 org.apache.drill.exec.planner.sql.parser.impl.DrillParserWithCompoundIdConverter.parseSqlStmtEof():59 org.apache.calcite.sql.parser.SqlParser.parseStmt():142 org.apache.drill.exec.planner.sql.SqlConverter.parse():157 org.apache.drill.exec.planner.sql.DrillSqlWorker.getQueryPlan():104 org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan():79 org.apache.drill.exec.work.foreman.Foreman.runSQL():1017 org.apache.drill.exec.work.foreman.Foreman.run():289 java.util.concurrent.ThreadPoolExecutor.runWorker():1142 java.util.concurrent.ThreadPoolExecutor$Worker.run():617 java.lang.Thread.run():748
Drill Web-UI does not support submitting multiple queries within the same query page. Please try using SqlLine or submit in Web-UI one-by-one
alter system set `store.format`='csv';
query to set store.format at the system level, since Web-UI does not store session by default and after that submit the following query
create table dfs.tmp.my_output as select * from cp.`employee.json`;
I am trying to query a table by selecting only those cases that meet a certain condition. It is a query called from Beeline, within a R script.
The problem is the field that must meet this condition has a reserved word as a column name: 'table'.
Whenever I run this in an AWS-EMR cluster:
SELECT ... FROM ... WHERE `table` = 'something' AND year = 2018
I get the following error:
bash: table: command not found
Connecting to jdbc:hive2://localhost:10000
Connected to: Apache Hive (version 2.3.2-amzn-0)
Driver: Hive JDBC (version 2.3.2-amzn-0)
Transaction isolation: TRANSACTION_REPEATABLE_READ
. . . . . . . . . . . . . . . . Error: Error while compiling statement: FAILED: ParseException line 1:242 cannot recognize input near '=' ''something'' 'and' in expression specification (state=42000,code=40000)
Closing: 0: jdbc:hive2://localhost:10000
ExitValue: 1
Both blocks marked in bold style should be fixed. Notice that the keyword 'table' is already escaped with backticks.
I have searched the web, but still cannot find a proper solution. Any help would be appreciated.
As #SamsonScharfrichter pointed out in the comments:
Short-term workaround: try escaping back-ticks i.e. \`table\` or maybe \\`table\\`
This worked for my problem.
I am trying to convert data from ORacle to MongoDB JSON format . But when trying to convert, I am getting following error when writing to JSON field. can anyone help. I have attached the flow and the mapping
Error message
tarting job ora2mongo at 03:14 17/08/2018.
[statistics] connecting to socket on port 4071
[statistics] connected
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Incorrect number of arguments for type Queue<E>; it cannot be parameterized with arguments <>
Syntax error on token "null", delete this token
Syntax error on token "null", delete this token
Syntax error on token "null", delete this token
queue cannot be resolved or is not a field
queue cannot be resolved to a variable
queue cannot be resolved or is not a field
queue cannot be resolved to a variable
Syntax error, insert "AssignmentOperator Expression" to complete Assignment
Syntax error, insert ";" to complete Statement
The left-hand side of an assignment must be a variable
Syntax error on token "null", invalid ClassType
Syntax error, insert "new ClassType ( )" to complete Expression
Syntax error, insert "AssignmentOperator Expression" to complete Assignment
Syntax error, insert ";" to complete Statement
Syntax error on token "null", invalid ClassType
Syntax error, insert "new ClassType ( )" to complete Expression
at rdbms_to_mongo.ora2mongo_0_1.ora2mongo.tOracleInput_1Process(ora2mongo.java:3156)
[statistics] disconnected
at rdbms_to_mongo.ora2mongo_0_1.ora2mongo.tOracleConnection_1Process(ora2mongo.java:550)
at rdbms_to_mongo.ora2mongo_0_1.ora2mongo.runJobInTOS(ora2mongo.java:5272)
at rdbms_to_mongo.ora2mongo_0_1.ora2mongo.main(ora2mongo.java:5129)
Job ora2mongo ended at 03:14 17/08/2018. [exit code=0]
While trying to run PL/pgSQL via JDBC driver (postgresql-9.4.1211.jre7.jar; using ANT) I get following error: ERROR: syntax error at or near "$"
Is there any way howto fix this via setting JDBC properties or changing the query of PL/pgSQL?
query:
DO $$
BEGIN
CREATE SEQUENCE id_sequence_SEQ OWNED BY id_sequence.id;
EXCEPTION WHEN duplicate_table
THEN
END
$$
LANGUAGE plpgsql;
error:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$"
Position: 5
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2458)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2158)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:291)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:432)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:358)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:305)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:291)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:269)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:265)
I tried executing a DO statement with JDBC and it works just fine.
There must be something weird in your statement. Try and log the statement by setting log_min_error_statement and log_min_messages to error. Execute the statement, then look at the message in the PostgreSQL log file. It should contain the statement that was actually executed. Examine it for weird characters and other strangeness.
Please also note that there is a syntax error in you PL/pgSQL: there must be something between THEN and END. For a no-op, use the statement NULL;.
So I'm working with DB2 from command line. Before you ask, yes, it is running with admin rights and I can connect to the database and db2 is running.
Here is my input in the cmd:
db2 xquery declare default element namespace "http://tpox-benchmark.com/security"; for $s in db2-fn:xmlcolumn("SECURITY.SDOC")/Security where $s/Symbol= "BCIIPRC" return $s
And this is the error that I get:
SQL16002N An XQuery expression has unexpected token "/" following
"pace http:". Expected tokens may include: ":". Error
QName=err:XPST0003. SQLSTATE=10505
And your question is?
Your shell may be stripping away those double quotes. Try enclosing the entire xquery statement in single quotes:
db2 'xquery declare ... return $s'
I replaced the " with ' and it works now. Thanks #mustaccio for the suggestion.
db2 xquery declare default element namespace "http://tpox-benchmark.com/security"; for $s in db2-fn:xmlcolumn("SECURITY.SDOC")/Security where $s/Symbol= "BCIIPRC" return $s