I never had an issue creating a table on RDBMS.
But this drill thing is really weird - i cant create new empty tables
I was following Apache Drill guide for creating table
which i don't get why isn't it working like
first:
0: jdbc:drill:zk=local> USE s3XXXXX.dss;
+-------+---------------------------------------------+
| ok | summary |
+-------+---------------------------------------------+
| true | Default schema changed to [s3XXXXX.dss] |
+-------+---------------------------------------------+
1 row selected (0.172 seconds)
And now for the Create commnad:
0: jdbc:drill:zk=local> CREATE TABLE s3XXXXX.dss.`name_key` (NBVXA ) AS QUERY;
Jun 11, 2017 10:53:28 PM org.apache.calcite.runtime.CalciteException <init>
SEVERE: org.apache.calcite.runtime.CalciteException: Non-query expression encountered in illegal context
Jun 11, 2017 10:53:28 PM org.apache.calcite.runtime.CalciteException <init>
SEVERE: org.apache.calcite.runtime.CalciteContextException: From line 1, column 53 to line 1, column 57: Non-query expression encountered in illegal context
Error: PARSE ERROR: Non-query expression encountered in illegal context
SQL Query CREATE TABLE s3XXXXX.dss.`name_key` (NBVXA ) AS QUERY
its a bit fishy, But i have found this solution which is close enough:
CREATE TABLE s3xxxxxx.dss.`name_key3` as SELECT DATE_PART('day', '2015-04-02') xx FROM (VALUES(1)) ;
Related
I want to add a new column to acc table. I created a new column in the acc table of type timestamp and named it ring_time. In every call I put the ring time to a $dlg_var like this:
$dlg_var(ringtime) = $Ts;
Then I add a extra column in config like this:
modparam("acc", "log_extra", "src_user=$fU;src_domain=$fd;src_ip=$si;" "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;ring_time=$dlg_var(ringtime)")
but when I try to test it, I always get:
db_mysql [km_dbase.c:122]: db_mysql_submit_query(): driver error on query: Incorrect datetime value: '1591361996' for column kamailio.acc.ring_time at row 1 (1292)
Jun 5 17:29:59 kamailio /usr/sbin/kamailio[22901]: ERROR: {2 102 INVITE 105a0f4a3d99a0a5558355e54b43f4e1#192.168.1.121:5060} <core> [db_query.c:244]: db_do_insert_cmd(): error while submitting query
Jun 5 17:29:59 kamailio /usr/sbin/kamailio[22901]: ERROR: {2 102 INVITE 105a0f4a3d99a0a5558355e54b43f4e1#192.168.1.121:5060} acc [acc.c:477]: acc_db_request(): failed to insert into database
Sounds like an error with the SQL INSERT query, if I had to guess I'd say you're being caught out by the date format in the SQL table not matching the date format you're pushing to it.
I don't know the structure of your database, but there's a simple trick I use for debugging SQL queries when I can't see the query being run;
Start up Wireshark/TCPdump on the machine and packet capture for all SQL traffic (MySQL is port 3306) and replicate the error.
From the packet capture and you'll be able to see the Query Kamailio's database engine ran.
If the error "db_mysql [km_dbase.c:122]: db_mysql_submit_query(): driver error on query: Incorrect datetime value: '1591361996' for column kamailio.acc.ring_time at row 1 (1292)", the '1591361996' looks like it is an epoch for the $dlg_var(ringtime). The "Incorrect datetime value" part of the error looks like the database is trying to store the value in datetime data type so a data type mismatch. Double-check and you may need either change the ringtime to convert to datetime or change the database column to a type that will take epoch.
I have the following data frame
CALL_DISPOSITION CITY END INCIDENT_NUMBER
0 ADV-Advised Waterloo Fri, 23 Mar 2018 01:13:27 GMT 6478983
1 AST-Assist Waterloo Sat, 18 Mar 2017 12:41:47 GMT 724030
2 AST-Assist Waterloo Sat, 18 Mar 2017 12:41:47 GMT 999000
I am trying to push this to an IBM DB2 Database.
I have the following code:
# IBM DB2 imports
import ibm_db
# instantiate db2 connection
connection_id = ibm_db.connect(
conn_string,
'',
'',
conn_option,
ibm_db.QUOTED_LITERAL_REPLACEMENT_OFF)
# create list of tuples from df
records = [tuple(row) for _, row in df.iterrows()]
# Define sql statement structure to replace data into WATERLOO_911_CALLS table
column_names = df.columns
df_sql = "VALUES({}{})".format("?," * (len(column_names) - 1), "?")
sql_command = "REPLACE INTO WATERLOO_911_CALLS {} ".format(df_sql)
# Prepare SQL statement
try:
sql_command = ibm_db.prepare(connection, sql_command)
except Exception as e:
print(e)
# Execute query
try:
ibm_db.execute_many(sql_command, tuple(temp_records))
except Exception as e:
print('Data pushing error {}'.format(e))
However, I keep getting the following error:
Exception: [IBM][CLI Driver][DB2/LINUXX8664] SQL0104N An unexpected token "REPLACE INTO WATERLOO_911_CALLS" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "<space>". SQLSTATE=42601 SQLCODE=-104
I don't understand why that is the case. I followed the steps outlined in this repo but I can't seem to get this to work. What am I doing wrong? Please let me know there are any clarifications I can make.
It hints about missing spaces, maybe it needs one between the fields in the VALUE() string.
Like df_sql = "VALUES({}{})".format("?, " * (len(column_names) - 1), "?")
instead of df_sql = "VALUES({}{})".format("?," * (len(column_names) - 1), "?")
Just a hunch.
I find that printing sql_command before executing it could also help troubleshooting.
A database table named lines with only has 1 column price
Model
class Line extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'lines';
protected $guarded = ['id'];
}
Table
+-------------+-----------+-------------------+-------------------------+---------------+
| COLUMN_NAME | DATA_TYPE | NUMERIC_PRECISION | NUMERIC_PRECISION_RADIX | NUMERIC_SCALE |
+-------------+-----------+-------------------+-------------------------+---------------+
| price | numeric | 19 | 10 | 3 |
+-------------+-----------+-------------------+-------------------------+---------------+
When I run this code I get an error
Code
DB::transaction(function() {
Line::insert([
['price' => 13.52],
['price' => 35]
]);
});
Error
SQLSTATE[22018]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Conversion failed when converting the nvarchar value '13.52' to data type int. (SQL: insert into [lines] ([price]) values (13.52), (35))
I have done some research
If I remove the transaction it works fine
If I change the value 35 to 35.00 it works fine
If I insert them one-by-one it also works fine
The statement insert into [lines] ([price]) values (13.52), (35) runs fine inside multiple SQL clients (DBeaver, SQL Operations Studio) also if executed inside a transaction (BEGIN TRANSACTION; .... COMMIT;)
Setup
PHP 7.1
Debian 9 (but problem also occurs on Windows)
SQL Server 2012
Laravel: 5.8
My question
Is there some way I can handle this issue globally without having to resort to any of the previously mentioned fixes?
Since it works fine in an SQL editor, I assume it must be either a Laravel issue, or a PHP SQL driver issue?
The issue here seems to be that your Laravel model is not properly defining the lines field to map to a decimal column. One option would be to use casts property of your model (documentation):
protected $casts = [
'lines' => 'real',
];
Regarding the error on the SQL Server side, I don't know why it is trying to convert the text to integer, but in any case, if it can't make an implicit conversion it would throw an error similar to this.
I have been using the query below and it was working fine but now it's giving a SQL error.
There were no changes made that could cause this to stop working.
There is no Field 'APPLICATIONID' in the table.
QueueSQL=select distinct (convert(char(5),SkillsetID)+'='+Skillset) from iagentbySkillsetStat where ApplicationID > 10000
QueueMappingSQL=SELECT DISTINCT (convert(char(5),SkillsetID)+'='+Skillset), SkillsetID FROM iagentbySkillsetStat iagentbySkillsetStat WHERE (iagentbySkillsetStat.ApplicationID>10000)
DB- Intersystems Cache
Error details for the log files are below.
14/09/2016 11:20:05 a.m. > ERROR - SQL Error '[Cache ODBC][State : S1000][Native Code 29]
[C:\xlink\xlink Compiled Package\Xlink Application\Isps_Ul.exe]
[SQLCODE: <-29>:<Field not found in the applicable tables>]
[Cache Error: <<SYNTAX>errdone+2^%qaqqt>]
[Details: <Prepare>]
[%msg: < SQL ERROR #29: Field 'APPLICATIONID' not found in the applicable tables^select distinct ( convert ( char ( 5 ) , SkillsetID ) + :%qpar(1) + Skillset ) from iagentbySkillsetStat where ApplicationID >>]'
Question was also asked at InterSystems Developer Community, where I noticed that table names are different. So, the answer is, that table name is suddenly changed somehow.
I got a short question on Apache kylin (version 1.5.3). I have built a cube successfully. Now I want to use the 'insight' tab of kylin to submit some queries. I have a table with two columns (id[varchar], abc[int]).
Queries like
select id, abc
from table
where abc = 12;
are working fine. But
select id, abc
from table
where abc != 12;
returns an error:
Lexical error at line 3, column 11. Encountered: "!" (33), after : ""
Does anyone knows the right lexical term of 'not'?
Thank you in advance,
Søren