How do I convert tables with boolean fields to json using Apache NIFI? - runtime-error

I am trying to extract a table from a Sybase database and convert it to a json file. I'm using the QueryDatabaseTableRecord processor with the following properties:
QueryTable_config.
Also, I have configured the JsonRecortSetWriter with the following properties:
JsonWriter_config.
When I run the process, I get the following error:
nifi_error.
The problem is that values in the boolean field "defo" in the table are considered as integer rather than boolean. Here is a caption from the table I want to convert:
tab_cap.
I've tried many solutions but nothing works.
Any idea please ?

Related

SQLite, Update Statement using DateTime

I have been trying to update a datetime column using the following SQL Statement:
UPDATE HistoricData SET RecordDate=DATETIME(RecordDate,'60 minutes') WHERE DataStreamID=1 AND TimeFrameID=5
However, I keep getting the following error message:
NOT NULL Constraint Failed: HistoricData.RecordDate
If you could recommend the appropriate change to get this working, I would very much appreciate it.
I will attempt to attach a sample schema and data:
Table Data
Table Schema
After inspecting your DML, my only remaining concern was the datetime format you have in your table. I tried updating such a value as you did, and guess what, it returns NULL: http://sqlfiddle.com/#!7/f4651/10 Why? Because your strings (do notation) are not valid ISO-8601 strings. You probably need to simply replace the dots with dashes before updating (http://sqlfiddle.com/#!7/f4651/11).

Delphi - ClientDataSet SQL calculated field causing "Invalid field type" error at runtime [duplicate]

Using Delphi 10.2, SQLite and Teecharts. My SQLite database has two fields, created with:
CREATE TABLE HistoryRuntime ('DayTime' DateTime, Device1 INTEGER DEFAULT (0));
I access the table using a TFDQuery called qryGrpahRuntime with the following SQL:
SELECT DayTime AS TheDate, Sum(Device1) As DeviceTotal
FROM HistoryRuntime
WHERE (DayTime >= "2017-06-01") and (DayTime <= "2017-06-26")
Group by Date(DayTime)
Using the Field Editor in the Delphi IDE, I can add two persistent fields, getting TheDate as a TDateTimeField and DeviceTotal as a TLargeIntField.
I run this query in a program to create a TeeChart, which I created at design time. As long as the query returns some records, all this works. However, if there are no records for the requested dates, I get an EDatabaseError exception with the message:
qryGrpahRuntime: Type mismatch for field 'DeviceTotal', expecting: LargeInt actual: Widestring
I have done plenty of searching for solutions on the web on how to prevent this error on an empty query, but have had not luck with anything I found. From what I can tell, SQLite defaults to the wide string field when no data is returned. I have tried using CAST in the query and it did not seem to make any difference.
If I remove the persistent fields, the query will open without problems on an empty return set. However, in order to use the TeeChart editor in the IDE, it appears I need persistent fields.
Is there a way I can make this work with persistent fields, or am I going to have to throw out the persistent fields and then add the TeeChart Series at runtime?
This behavior is described in Adjusting FireDAC Mapping chapter of the FireDAC's SQLite manual:
For an expression in a SELECT list, SQLite avoids type name
information. When the result set is not empty, FireDAC uses the value
data types from the first record. When empty, FireDAC describes those
columns as dtWideString. To explicitly specify the column data type,
append ::<type name> to the column alias:
SELECT count(*) as "cnt::INT" FROM mytab
So modify your command e.g. this way (I used BIGINT, but you can use any pseudo data type that maps to a 64-bit signed integer data type and is not auto incrementing, which corresponds to your persistent TLargeIntField field):
SELECT
DayTime AS "TheDate",
Sum(Device1) AS "DeviceTotal::BIGINT"
FROM
HistoryRuntime
WHERE
DayTime BETWEEN {d 2017-06-01} AND {d 2017-06-26}
GROUP BY
Date(DayTime)
P.S. I did a small optimization by using BETWEEN operator (which evaluates the column value only once), and used an escape sequence for date constants (which, in real you replace by parameter, I guess; so just for curiosity).
This data type hinting is parsed by the FDSQLiteTypeName2ADDataType procedure that takes and parses column name in format <column name>::<type name> in its AColName parameter.

Set correct data type with OpenAccess ORM Fluent API

I am using Telerik Data Access Fluent Model(Open Access) Code first approach for generating Database. Everything is going right except some issues.
• I have created a Property as Decimal in code. But in database its data type is numeric not decimal. I need to set data type as decimal but this is giving me numeric.
• Same type of issue is there with Bool property in code that gives me tinyint as datatype in database instead bit. I also set the property as Boolean in C# code and generated column is still tinyInt. I need to set it as bit in database
Here are images for my properties and generated columns(From these properties in Database)
These are properties that are written in code
http://screencast.com/t/sOXOi3as0N
And this is the image of generated table in database
http://screencast.com/t/9KmmEK1IL
it seems to be the default behavior of the product - to map decimal CLR type props to columns of numeric SQL type and bool props to tinyint cols. You need to slightly change the mapping configuration for the package persistent type by specifying the correct SQL types for underlying columns mapped to these props in the following way:
mappingConfiguration.HasProperty(x => x.BasicPrice).HasColumnType("decimal").HasPrecision(18).HasScale(2);
mappingConfiguration.HasProperty(x => x.IsActive).HasColumnType("bit");

How to get Binary equivalent of BLOB data type in Oracle

I am using C# for front end and Oracle as a database. I have a BLOB type field in a table and is used to contain images. What I actually need to do is that whenever a record in table doesn't contain any image I want to show default pic for that particular record in front end. For that purpose can I get a binary format of that default image(without saving that image with a dummy record) after saving it temporarily in database, and then using that binary format in query to show default pic when the image doesn't exists for any record. What I am getting now is :
SELECT EMP_IMG FROM Employee_Master WHERE EMP_CODE = 1234
----------------------------------------------------------
(BLOB)
Look into byte[]; use Binary Serializer to get the byte[] version of the object.
See this: C# Object Binary Serialization

html output from stored procedure in a variable in servlets getting truncated

i am having a stored procedure in sql server which returns a variable of nvarchar(max) datatype . the value of the variable is a html file contains table.
in servlets i am able to get the output value from the stored procedure and store it in a string variable. But when i am printing it then it is getting truncated and some portion of the html file is missing. how to overcome this issue.
thanks in advance.
as for this is concerned i find out the reason, i was using wrong jdbc sql data type , while i was using varchar it is truncating but when i changed that into longvarchar then things got working now.

Resources