PostgreSQL error : 22007 invalid_datetime_format - postgresql

I have a program that is dependant on PostgreSQL, It is suddenly giving me the error
SQLSTATE[22007]: Invalid datetime format: 7 ERROR: invalid input syntax for type time: "00:00:01."
LINE 1: ...:55:02.027392', '00:00:00.042608', '00:55:02.07', '00:00:01....
It occurred after loading some data into a folder that is monitored for changes to update the database. I have since removed ALL the data from that folder. I have searched for several hours, I am unable to find anything giving me direction where to start.
postgresql-9.1-main.log
2015-04-05 12:26:15 EDT ERROR: invalid input syntax for type time: "00:00:01." at character 234
2015-04-05 12:26:15 EDT STATEMENT: INSERT INTO cc_schedule (starts, ends, cue_in, cue_out, fade_in, fade_out, clip_length, position, instance_id, file_id, stream_id) VALUES ('2015-04-06 17:00:00.000000', '2015-04-06 17:55:02.027392', '00:00:00.042608', '00:55:02.07', '00:00:01.', '00:00:01.', '00:55:02.027392', 0, 25, 1717, null) RETURNING id
I would appreciate any advice. I am thinking there is just a bungled entry somewhere that could be removed? or do I need to reinstall PostgreSQL ?

you have two time entries with a dot at the end of time, that cause the error:
00:00:01.
fix the data to
00:00:01

I found the issue, I had changed a configuration as related to Track Fade time. When doing so from "0.50" to "1." leaving . at the end bungled it. Thank You for your time and assistance.

Related

Add a missing key to JSON in a Postgres table via Rails

I'm trying to use update_all to update any records that is missing a key in a JSON stored in a table cell. ids is the ids of those records and I've tried the below...
User.where(id: ids).
update_all(
"preferences = jsonb_set(preferences, '{some_key}', 'true'"
)
Where the error returns is...
Caused by PG::SyntaxError: ERROR: syntax error at or near "WHERE"
LINE 1: ...onb_set(preferences, '{some_key}', 'true' WHERE "user...
The key takes a string value so not sure why the query is failing.
UPDATE:
Based on what was mentioned, I added the parentheses and also added / modified the last two arguments...
User.where(id: ids).
update_all(
"preferences = jsonb_set(preferences, '{some_key}', 'true'::jsonb, true)"
)
still running into issues and this time it seems related to the key I'm passing
I know this key doesn't currently exist for the set of ids
I added true for create_missing so that 1 isn't an issue
I get this error now...
Caused by PG::UndefinedFunction: ERROR: function jsonb_set(hstore, unknown, jsonb, boolean) does not exis
some_key should be a key in preferences
You're passing in raw SQL so you are 100% responsible for ensuring that is actually valid SQL. What you have there isn't. Check your parentheses:
User.where(id: ids).
update_all(
"preferences = jsonb_set(preferences, '{some_key}', 'true')"
)
If you look more closely at the error message it was telling you there was a problem precisely at the introduction of the WHERE clause, and right after ...true' so that was a good place to look for problems.
Syntax errors like this can be really annoying, but don't forget your database will usually do its best to pin down the place where the problem occurs.

Talend: configuration dimension time error in tOracleOutput

I still have this problem
Exception in component tOracleOutput_1
java.sql.SQLSyntaxErrorException: ORA-00904: : invalid identifier
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
There is some currupt code in your job. What you can do is first check is there any code generated for this job. if not try removing each component/disable and run and see if the error persist or not
I have had this as well. What usually helps is restarting Talend or restarting the computer.
If that doesn't help, there is something wrong with the job. Then I check every schema, every connection, every tMap, every item in the job if there is an error which Talend doesn't show to me.
To check if the code generation system works, you can always click on the Code tab and see if something comes up.
EDIT
An error ORA-00904 comes up. This leads to the suggestion that a column is named wrongly as seen here: https://dba.stackexchange.com/questions/129641/ora-00904-error-while-querying-the-oracle-database-table
To avoid ORA-00904, column names must
begin with a letter.
consist only of alphanumeric and the special characters ($_#); other characters need double quotation marks around them.
be less than or equal to thirty characters.

Error when i want insert a date in DB with laravel

I'm using laravel 5.1 with eloquent, i have a postgre database and i would like to insert an object with some date in. My start format date is like '15/10/2015', and i need to convert into 'Y-m-d'.
For that i use date mutators in my model, i add this line :
protected $dates = ['created_at', 'updated_at', 'prj_start_date', 'prj_end_date_init'];
I use an architecture with services and repositories so in my repository for create my object in DB i have this :
$this->model->create($data);
When i try to insert i have this error
InvalidArgumentException in Carbon.php line 425:
Unexpected data found.
Unexpected data found.
Data missing
in Carbon.php line 425
at Carbon::createFromFormat('Y-m-d H:i:s', '15/10/2015') in Model.php line 2959
at Model->asDateTime('15/10/2015') in Model.php line 2915
at Model->fromDateTime('15/10/2015') in Model.php line 2870
at Model->setAttribute('prj_start_date', '15/10/2015') in Model.php line 422
Why isn't work, i've miss something ?
Can someone help me please ?
In at Carbon::createFromFormat('Y-m-d H:i:s', '15/10/2015') in Model.php line 2959 it is pretty clear that somehow laravel hardcoded it's dates mutator. I suggest using a manual approach, converting your string into Carbon instance via:
Carbon::createFromFormat($format, $time, $tz);
for example assuming have a date field instead of timestamp:
Carbon::createFromFormat('d/m/Y', '15/10/2015');
ps. i did not have the time to test this yet. Nevertheless, learning from the source is much interesting right?
ps. you might interested in changing laravel's format just like the docs however, i suspect this will affect created_at and updated_at (also deleted_at) fields that by default is a timestamp instead of dates.
ps. right, i do forget to mention you had to include Carbon to your controller, just add use Carbon/Carbon

Running a query using date from a form MS Access

How do I run a query using a value from a textbox from a form I have? I know that there is another post here at Stackoverflow dealing with this issue but I found it to be insufficient for my needs.
I formated my textbox into Medium Date format with its default value being =Date(). However, when I pick up a date and open my report I get this error:
Runtime error 3071: Expression Too Complex
My where clause is this
WHERE
(
(AllInfo.DateOpened >= CDate([Forms]![Main Form]![WindowPrintOptions]![CustomizedReport]!txtDateOpenedFrom.Value))
)
and I am sure it is this code piece that is throwing the problem since when I take it out of the query the error message simply disappears.
Any ideas?
Try with:
(AllInfo.DateOpened >= DateValue([Forms]![Main Form]![WindowPrintOptions].[Form]!txtDateOpenedFrom))
)
Folks,
I got the problem. It was the "AllInfo" alias. It wasn't applicable at that escope inside the query. By changing the proper things, it was enough to write:
[Forms]![Main Form]![WindowPrintOptions]![CustomizedReport]!txtDateOpenedFrom.Value
Issue solved. Thank you all!

Setting default in entity model for Type Time

I've tried a few values but nothing works. I could randomly try values (I did a few) and try searching (yep nothing after about 30 minutes of looking) or ask the SO folks.
So trying to set the default Time to 5:30:00 PM (17:30:00) when I create a new record. I thought all I needed to do was set it in the properties, and it seems correct, but doesn't like the value I put in. 17:00:00.0000000 and 17:00:00 and 17:00:00.0 all failed.
See image
Try setting your time to:
17:30:00.0000000z
17:30:00.0000000Z
That works for me with a database column having type Time(7). Mark Oreta's also worked. I received the same error when I omited the z or Z. Is there an issue in your table mappings?