I have a drop down in form that allow users to select multiple value at the same time in R Shiny and saving the record in SQLite DB at the back end and data type is VARCHAR
dropDown:
But when i click on save button i am getting below error:
Error in : Expecting a single string value: [type=character; extent=2].
Any help would be appreciated! :)
The error tells you all you need to know. Your selectInput is returning a vector of characters. Your database is expecting a scalar character. So, either turn the value of the selectInput into a scalar (by concatenation or pasting) or modify your database so that it can accept multiple rows of data which correspond to your input. The choice is yours.
I can't tell you which is more appropriate because you've provided no context.
Related
In my DB, some of values of a column (called status) are null, and if they are null, I want to show a String "canceled".
Guess I need to do it on Attributes - common -if-null but then don't know how to specify it.
Can anyone help me?
There are multiple options, as you said, Attributes - common - if-null on the field containing the status should do that, you can specify a String by entering it in the Value box. If your string disappears after unfocusing, click the ... while the Value entry is selected, that will launch a Popup-entrybox.
Alternatively, you could put that logic into your query
select coalesce(status, 'Cancelled')
from table
COALESCE
Evaluates the arguments in order and returns the current value of the first expression that initially doesn't evaluate to NULL. For example, SELECT COALESCE(NULL, NULL, 'third_value', 'fourth_value'); returns the third value because the third value is the first value that isn't null.
Some databases might have similar functions with different names, with Oracle e.g. there's nvl()
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).
I have to set default values for the lookup transformation. Default values are stored in separate file.
Input file is in XML format.
So need to write Unix script for this.
Thanks in advance.
Ok... so take your lookup returned port to another expression tramsformation which has all your fields set via iif to be equal to the value they would get set or the desired default value when the lookup returned field is null.
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.
I want to select some rows from a SQLite table, and add an empty character column at the same time, but I get an error. The statement is SELECT firstname, SPACE(100) AS mytext FROM Customers, and the error message is "No such function: space".
I can run the same command in SQL-server without any probems, and in SQLite I can select additional numeric columns without problems (eg. SELECT firstname, 8 AS newfield ...), but not character columns.
Any help would be appreciated.
Regards, Alan
Functions are not standard across database engines; some will be the same, but most are not. A complete list of standard functions is here http://www.sqlite.org/lang_corefunc.html. You can also create custom functions in C, C#, or whatever you're using.
There is no built in version of SPACE. You need to create a custom function or use a string literal.