I've got stuck with FbException
SQL error code = -104
Token unknown - line 2, column 4
.
when trying to run this code
var result = from x in _context.Bunts
select x;
I've checked the query which was produced by EF
SELECT
"A"."BUNTCODE" AS "BUNTCODE",
"A"."BUNTNAME" AS "BUNTNAME",
"A"."BUNTDIAM" AS "BUNTDIAM"
FROM "BUNTS" AS "A"
So server thinks that something is wrong with dot after "A" statement. But this query runs just fine in IBExpert on the same machine. How to fix this problem?
I'm using:
Firebird server v2.1.6.18547
EntityFramework v6.0.0.0
EntityFramework.Firebird v4.5.2.0
FirebirdSql.Data.FirebirdClient 4.5.2.0
The error suggests you are connecting using dialect 1. Dialect 1 is the old dialect of Interbase 5 and earlier and should be considered deprecated (although unfortunately 15 years on it is still supported by Firebird...).
In dialect 1 it is not possible to quote object names, and double quotes are used for strings (instead of single quotes in dialect 3 and the SQL standard). When your query is parsed in dialect 1, Firebird sees "A" as a string constant, and the following dot (.) is not expected by the parser.
Switching to dialect 3 should fix this, however if you do that, make sure that your database itself is also dialect 3, otherwise you might get other unexpected behavior like certain datatypes not working, or errors, etc.
Related
I'm trying to update a column named value in a dbf-file. Since value is a reserved word I need to add the tablename to the query. So this works:
UPDATE "C:\TEMP\TEST_PARAM.DBF" SET TEST_PARAM.value='new value' WHERE Id='Some ID';
But now I have the problem that many of my dbf-files start with numbers in the filenames and following does not work:
UPDATE "C:\TEMP\0016_PARAM.DBF" SET 0016_PARAM.value='new value' WHERE Id='Some ID';
I've tried enclosing the table_name in single quotes, double quotes, [,... but nothing of that works. Is there something else I could try?
You don't say what language you're doing this in, but here we go in C#. The same approach should work in any language.
You need to open the DBF under an alias, and you need to be able to send multiple commands through OLEDB.
This should work.
* -- Open the dbf in the first available work area under the alias 'param'.
* -- Now you don't have to worry about the zeroes.
OleDbCommand myCommand = new OleDbCommand(#"execscript([use 'C:\TEMP\0016_PARAM.DBF' in 0 alias param])", myConnection);
var result = myExecuteNonQuery();
* -- Now do the update, referring to the alias, not the DBF filename.
myCommand = new OleDbCommand(#"execscript([update param set param.value='new' where id='some id'])", myConnection);
result = myCommand.ExecuteNonQuery();
Regarding the square brackets, Visual FoxPro has three default string delimiters, namely the usual single and double quotes, but also square brackets.
So we're using the double quotes for the C# string. The Visual Foxpro command we're running via ExecScript needs quotes too, around 'new' and 'some id', so that's using single quotes. But we need to pass that command to Execscript as a string, so that string is using the brackets.
I am trying to use the pipe character "|" in SPSS syntax with strange results:
In the syntax it appears like this:
But when I copy this line from the syntax window to here, this is what I get:
SELECT IF(SEX = 1 SEX = 2).
The pipe just disappears!
If I run this line, this is the output:
SELECT IF(SEX = 1 SEX = 2).
Error # 4007 in column 20. Text: SEX
The expression is incomplete. Check for missing operands, invalid operators,
unmatched parentheses or excessive string length.
Execution of this command stops.
So the pipe is invisible to the program too!
When I save this syntax and reopen it, the pipe is gone...
The only way I found to get SPSS to work with the pipe is when I edited the syntax (adding the pipe) and saved it in an alternative editor (notepad++ in this case). Now, without opening the syntax, I ran it from another syntax using insert command, and it worked.
EDIT: some background info:
I have spss version 23 (+service pack 3) 64 bit.
The same things happens if I use my locale (encoding: windows-1255) or Unicode (Encoding: UTF-8). Suspecting my Hebrew keyboard I tried copying syntax from the web with same results.
Can anyone shed any light on this subject?
Turns out (according to SPSS support) that's a version specific (ver. 21) bug and was fixed in later versions.
I'm on my very first script with kapacitor. I've written a tick file. Following is the script.
stream
.from().measurement('cpu')
.where("cpu" == 'cpu-total')
.alert()
.info(lamda:TRUE)
.log('/tmp/cpu.log')
I'm defining tick file to kapacitor using following command
kapacitor define highcpu -type stream -dbrp telegraf.default -tick cpu.tick
Getting Following error
invalid TICKscript: parser: unexpected unknown state, last char: ':' line 5 char 14 in "info(lamda:TRUE)". expected: ")"
I'm not getting exactly going wrong. I'm sure there is nothing wrong with config and telegraf and influxdb.
Kapacitor version 1.3.1
OS: Fedora 22
Missing 'b' in lamda.
Should be: lambda.
Q: I'm not getting exactly going wrong.
A: Short answer, syntax error.
Unfortunately the parser for Kapacitor's TICK script is not that mature yet and you really can't blame them for it. This project is still a baby, hence these such of errors only appear during runtime.
The problem is with your lambda expression .info(lamda:TRUE). You need to tell the expression which field or tag to lookup its value.
A typical lambda expression looks like
info(lambda: if ("sum" >= 45000, '1', '0'))
info(lambda: "isPeakHour" == 'true')
Something to note here is that, there is no True or False in Kapacitor yet. 1 or 0 is typically used to represent boolean.
You might also want to take note of single quote and double quotes in TICK script.
Single quotes are string literals
Double quotes are references to a field or tag. Double quotes are
only used in lambda expressions.
Hello I'm working with Firedac (Delphi Seattle) using Firebird (2.5) as a database, when I run this query using a TFDQuery, no records are returned:
SELECT ID FROM USERS WHERE PWD = 'êHÆ–!+'
The same query within a Database program as IbExpert return one record. Is there some parameter with Firedac components to configure that can solve this issue. Thanks.
It's in the query string and it's the ! char. By default, query strings are preprocessed, and you must escape constant chars like !, &, :, ?, { or }, otherwise they are used as special chars.
Your best option is using parameters. That will (except other benefits) get rid of that ! char from the preprocessed command:
FDQuery.SQL.Text := 'SELECT ID FROM USERS WHERE PWD = :Password';
FDQuery.ParamByName('Password').AsString := 'êHÆ–!+';
FDQuery.Open;
Another option is escaping that constant char or disable macro preprocessor. For more information see the Special Character Processing topic.
I am importing data from a CSV file. One of the fields has an accent(Telefónica O2 UK Limited). The application throws en error while inserting the data to the table.
PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xf36e6963
HINT: This error can also happen if the byte sequence does not match the
encoding expected by the server, which is controlled by "client_encoding".
: INSERT INTO "companies" ("name", "validated")
VALUES(E'Telef?nica O2 UK Limited', 't')
The data entry through the forms works when I enter names with accents and umlaut.
How do I workaround this issue?
Edit
I addressed the issue by converting the file encoding. I uploaded the CSV file to Google docs and exported the file to CSV.
The error message is pretty clear: Your client_encoding setting is set to UTF8 and you try to insert a character which isn't encoded in UTF8 (if it's a CSV from MS Excel, your file is probably encoded in Windows-1252 instead).
You could either convert it in your application or you can alter your PostgreSQL connection to match the encoding you want to insert (thus enabling PostgreSQL to do the conversion for you). You can do so by executing SET CLIENT_ENCODING TO 'WIN1252'; on your PostgreSQL connection before trying to insert that data. After the import you should reset it to its original value with RESET CLIENT_ENCODING;
HTH!
I think you can try to use the Ruby gem rchardet, which may be a better solution. Example code:
require ‘rchardet’
cd = CharDet.detect(string_of_unknown_encoding)
encoding = cd['encoding']
converted_string = Iconv.conv(‘UTF-8′, encoding, str_of_unknown_encoding)
Here are some related links:
https://github.com/jmhodges/rchardet
http://www.meeho.net/blog/2010/03/ruby-how-to-detect-the-encoding-of-a-string/