Sybase error code 112116 unable to solve - sybase-ase

A variable with char(20) and converting that variable to datetime
values passed to that variable 'June-2013' and 'July-2013' etc.
All results are working but failing with one of the value that is 'August-2013'.
am getting the error code as sybase error code 112116
Could any one quickly help me out ?
Regards,
Sankar.

Related

PostgreSQL: getting error messages from `pg_convert()`

I'm trying to diagnose a problem only found on a production system and I'm trying to improve the error reporting for errors thrown by pg_convert(), but not sure where to go. I tried changing the code in the dev environment to:
$converted_values = pg_convert($cnx, $table, $values);
if ($converted_values === FALSE)
throw new Exception("Failed to insert record: '".pg_last_error($cnx)."' using values: ".var_export($values, true));
But pg_last_error() returned nothing.
Note: I tested the above by trying to insert a null value into a NOT NULL column. In addition to getting no joy from pg_last_error() the log had some "PHP Notice"s in it. The production log didn't have any such notices. Just the empty return value from pg_convert() :(
I'm running PostgreSQL 9.4.6 on Debian 8.3 and PHP 5.6.22.
From what I can tell, trying to get anything done w/pg_convert() is a bust. It's not very reliable in dealing w/different data, and it's inconsistent about putting double quotes around column names. If you're using pg_convert() you'll likely want to convert to prepared statements. What they do is very different, so you might have to make fundamental changes to your code base, but we made the change and it seems to be working for us.
Edit: and one such problem that pg_convert()/pg_query() seemed to be able to roll w/that pg_execute() doesn't, is empty strings assigned to integer columns where NOT NULL isn't set. To fix this (at least for now) I had to:
loop through the array passed to pg_execute()
call pg_meta_data() when I found one w/an empty string
determine if the destination column is an integer (be careful: there are probably a lot of ways in which the type for an integer column can be expressed) then if nulls are allowed at all
overwrite the empty string w/null.
Inserting a NULL into a NOT NULL column will not trigger an error in pg_convert. Errors will result from connection problems, a missing table, or a missing column, or data that cannot be converted from the PHP structure to the type in the database (e.g. a word to a number).

'SQLSTATE[42000] while inserting data to table [closed]

I wanna insert some data in a table !! but it give me an error (only in this table I have other ones works fine)
that's my code :
and that's the error I got !
thanks for helping me with that .
Notice : I use PDO ! not Mysqli !
You have, as the error states, a syntax error in your query. Specifically, at the place it shows, you have (before binding):
VALUES (:m,:tu:,:w,:th,:f,:sa,:su)
Notice that your :tu: has a double-colon at the start AND at the end. So the final query will also suddenly have a : in a place where it shouldn't.
There is a typo in your query, check variable tu. You have :tu: instead :tu

PHP : SQL STATE 22007 when inserting date or datetime

My problem is:
I have a database, i'm trying to insert a simple date of creation in my table.
I set the field type to "date", and when i'm inserting the values via PDO in my php code, it's not working.
Well actually, the database is taking the data and inserting properly, but I still get the following error from php for some reason :
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime
value: '1' for column 'creation' at row 1
This is when I try to insert the following values :
$sql = "INSERT INTO questions VALUES (NULL,'"
.$values['type_question']
."','"
.$values['question']
."', NULL , NOW() )"
;
I'm confused because when I open phpMyAdmin or the mysql console and paste the code (I do a var_dump of my SQL), it works without any problem.
I tried the following combinations:
Field type : Date, Datetime
Value : NOW(), CURRENT_DATE(), date('Y-m-d H:i:s') from PHP
None of it is working.
I get either the error above, either the same error code but with a different message saying something like:
Incorrect value for field 'creation' at row 1
I really don't understand where it's coming from ...
Could it be a bug from PHP7 PDO? Do i do something bad?
Edit :
PHP 7.0.0
Mysql 5.7.9
Solved by modifying the my.ini file, thanks.
Check your my.ini file, remove STRICT_TRANS_TABLES from sql-mode if it's there.
Source
I have this line in my my.ini file :
sql-mode="STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER"
So, should I remove the "STRICT_ALL_TABLES" , and leave the rest be ?
I just tried it, it seems to solve the problem (I have now other errors with the request, but not linked to date / datetime), i'll keep updating to be sure it has nothing to do with it.
NB : The new error is a SQL STATE 23000 Integrity constraint violation. But the insert goes correctly and the inserted value is also correct, Again the error is coming from PHP rather than MYSQL ... -_-
The field is set with a default value, and can be NULL, i have an error if I put NULL, '', or a correct FK value in my request.
Edit : Solved. Wrong table name, nothing to do with the date/datetime as i thought, just me and my brain.

MySQL error - Invalid datetime format: 1292 Incorrect datetime value: '' for column

I am using mysql in Os X 10.9.2 and when I try to run my php website in local I have this error:
Invalid datetime format: 1292 Incorrect datetime value: '' for column nameOfTheColumn
The Error happens when I tried to insert an empty value in a datetime field. The site works fine in production and in some other locals computers, so the problem is in database and I have to be solve in my local database. Reading about the problem I read that mysql could be running in Strict mode, so I edit /usr/local/mysql/my.cnf and I comment out this line:
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
I restart computer and still is not working, but according to the documentation online and others questions, this is the way, but I would like to know What is it the exactly change I have to do to make my application works. Repeat, the code works in production, windows with xampp, etc... so can not be change because is to long and just for work in local I need the right change in MYSQL DATABASE.
Thanks in advance!
It looks like the default sql_mode on your osx instance of MySQL is set to refuse invalid dates.
You could try issuing this command:
SET SESSION sql_mode='ALLOW_INVALID_DATES'
as you initialize your session.
you can change your column to allow null
ALTER TABLE table_name MODIFY datetime_column_name datetime;
Columns are nullable by default as long as a column is not declared as NOT NULL.
At last I found the solution, in fact I was on the way, the solution is to comment out sql_mode, but the file located in /etc/my.cnf instead of /usr/local/mysql/my.cnf. If you do not comment this line, and you try to insert an empty value an error is raised, but if you comment it out, empty values becomes '0000-00-00 00:00:00'
There was a similar issue on our MySQL 5.6 server.
When I changed sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES to sql_mode=NO_ENGINE_SUBSTITUTION - the issue was fixed.
Of course, it is a good idea to be sure that the value is in the correct format.
For example, if the column type is "DATETIME", but in php we try to insert the value generated by date('c') - we'll get that error (if strict mode is turned on). But when we'll change it to: date('Y-m-d H:i:s') - the issue is gone.

Date Insertion Issue in Oracle Database and Codeigniter

I am having a problem in updating oracle db table with date column . I have tried many solutions but still not working. I can not insert the date into the database using codeigniter active record or normal query.. the column type is Timestamp. here are some solutions I have tried. could u help please.. thank you
$this->db->set('AC_START',"TO_DATE('2014-03-4 2:30','yyyy-mm-dd hh:mm')");
$this->db->set('AC_END',"TO_DATE('2014-05-5 2:34' ,'yyyy-mm-dd hh:mm')");
$this->db->insert('ACTIVITES');
here is error message that I always get
Error Number:
INSERT INTO "LI_PPPA"."ACTIVITES" ("AC_START", "AC_END") VALUES ('TO_DATE('2014-03-4 2:30','yyyy-mm-dd hh:mm')', 'TO_DATE('2014-05-5 2:34' ,'yyyy-mm-dd hh:mm')')
Filename: Directory\program\system\database\DB_driver.php
Line Number: 330
You have to make sure CI doens't escape the values you are passing to the oracle database, because to_date is an oracle function.
Try the following:
$this->db->set('AC_START',"TO_DATE('2014-03-4 2:30','yyyy-mm-dd hh:mm')",FALSE);
$this->db->set('AC_END',"TO_DATE('2014-05-5 2:34' ,'yyyy-mm-dd hh:mm')",FALSE);
$this->db->insert('ACTIVITES');code here
With that last parameter you are telling CodeIgniter to NOT escape this value.
Sonaryr's answer threw an Oracle error for me: ORA-01810
Oracle SQL Developer Statement Output:
Error report:
SQL Error: ORA-01810: format code appears twice
01810. 00000 - "format code appears twice"
*Cause:
*Action:
To Fix Change MM to MI:
$this->db->set('AC_START',"TO_DATE('2015-09-02 16:35' ,'YYYY-MM-DD HH24:MI')",FALSE);
Write Normal Query To Perform Action Against The TO_DATE(); Codegniter Does not have any library functions for to_date() for oracle.

Resources