Good day,
org.springframework.dao.DataIntegrityViolationException: could not insert: [com.entity.payment.BPaymentItem]; SQL [insert into sc.PHistoryItem (amount, beneficiaryAccNo, beneficiaryBankCode, beneficiaryBankName, beneficiaryRef2, billCode, branchId, chargeTo, cibRefNo, cifId, collectionAccountNo, companyId, companyName, createdHostDateTime, currentStatus, customerCategoryCharges, customerCategoryCode, customerCategoryId, customerCategoryName, description, errorCode, errorMessage, fromAccountName, fromAccountNo, fromAccountType, fromFavourite, gst, gstAmount, gstInclusive, gstName, gstRate, gstRefNo, gstTaxCode, hostRefNo, nbpsBillerCode, nbpsBillerName, nbpsReferenceNo, nbpsRrn2, nbpsRtn, nbpsSystemReferenceNo, notifyRetryCount, paymentDate, paymentHistoryId, processDate, promotionCharges, promotionCode, promotionId, promotionName, ref1, ref2, reference, rejectReason, remittanceStatus, remittanceTo, rfi, rrnInfo, rtTrxCode, rtnStatus, serviceCharge, serviceChargeCode, serviceChargeGLAcct, serviceChargeId, serviceChargeName, servicePackageCode, servicePackageId, servicePackageName, serviceType, showTerm, smsCharges, smsGst, smsGstAmount, smsGstInclusive, smsGstRate, smsGstTaxCode, toAccountName, toAccountNo, toAccountType, transferType, type, validateSig, approvalItemId) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.DataException: could not insert: [com.entity.payment.BPaymentItem]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:642) ~[org.springframework.orm-3.0.4.RELEASE.jar:3.0.4.RELEASE]
Caused by: com.ibm.db2.jcc.am.SqlDataException: DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null, DRIVER=3.63.123
at com.ibm.db2.jcc.am.fd.a(fd.java:671) ~[db2jcc.jar:na]
...
SQLSTATE 22001 is causing by Character data, right truncation occurred; for example, an update or insert value is a string that is too long for the column, or a datetime value cannot be assigned to a host variable, because it is too small.
But is there a way to check which column causing this error?
There is no way from this error message to determine the column which is causing your problem. But based on this error: SQLERRMC=null. Your data is trying to insert a null value, either your column doesn't accept nulls or your not passing the right type of null.
If you're using a prepared statement like this, then to insert a null you would need to specify it.
String query = "insert into table_temp(col1,col2) values(?,?)";
pstmt = con.prepareStatement(query);
pstmt.setString(1, "a");
pstmt.setNull(2, java.sql.Types.NULL);
Related
I have followed other posts related to inserting a dictionary into a Postgresql. The syntax is as follows:
sql_insert = 'INSERT INTO table_results (id, name, state, response, duration_time) VALUES (%(id)s, %(name)s, %(response)s, %(duration_time)s);'
The dictionary has the following data:
data= {'id': 29, 'name': "ABC'S KINDERGARDEN", 'response': 'OK', 'duration_time': 60}
Then, I can execute the insert statement:
db.session.execute(sql_insert,data_dict )
However, the previous throws the next error:
(psycopg2.errors.SyntaxError) syntax error at or near "%"
LINE 1: ...1, result_response, result_duration_secs) VALUES (%(id)s, %(...
^
[SQL: INSERT INTO table_results (id, name, state, response, duration_time) VALUES (%%(id)s, %%(name)s, %%(state)s, %%(response)s, %%(duration_time)s);]
(Background on this error at: http://sqlalche.me/e/13/f405)
I have tried several ways with this as the most general accepted format.
The following snippet includes the import and code:
import psycopg2
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
sql_insert = "INSERT INTO table_results (" + ", ".join(data_dict.keys()) + ") VALUES (" + ", ".join(["%("+k+")s" for k in data_dict]) + ");"
db.session.execute(sql_insert,data_dict )
db.session.commit()
Thanks
I'm using magento 2.0.4 and PHP 7.
At this point i'm desperate as my website needs to go live tomorrow.
On checkout i get the next error :
picture here<---
>
>
> In my exception log i have the next output : [2016-04-26 18:52:21]
> main.CRITICAL: Zend_Db_Statement_Exception: Report ID:
> webapi-571fb8e513432; Message: SQLSTATE[23000]: Integrity constraint
> violation: 1062 Duplicate entry 'O-16-04-000014-1' for key
> 'SALES_ORDER_INCREMENT_ID_STORE_ID', query was: INSERT INTO
> `sales_order` (`state`, `status`, `protect_code`,
> `shipping_description`, `is_virtual`, `store_id`, `customer_id`,
> `base_discount_amount`, `base_grand_total`, `base_shipping_amount`,
> `base_shipping_tax_amount`, `base_subtotal`, `base_tax_amount`,
> `base_to_global_rate`, `base_to_order_rate`, `discount_amount`,
> `grand_total`, `shipping_amount`, `shipping_tax_amount`,
> `store_to_base_rate`, `store_to_order_rate`, `subtotal`, `tax_amount`,
> `total_qty_ordered`, `customer_is_guest`, `customer_note_notify`,
> `customer_group_id`, `quote_id`, `base_shipping_discount_amount`,
> `base_subtotal_incl_tax`, `base_total_due`,
> `shipping_discount_amount`, `subtotal_incl_tax`, `total_due`,
> `weight`, `increment_id`, `applied_rule_ids`, `base_currency_code`,
> `customer_email`, `customer_firstname`, `customer_lastname`,
> `customer_middlename`, `customer_taxvat`, `discount_description`,
> `global_currency_code`, `order_currency_code`, `remote_ip`,
> `shipping_method`, `store_currency_code`, `store_name`,
> `total_item_count`, `customer_gender`,
> `discount_tax_compensation_amount`,
> `base_discount_tax_compensation_amount`,
> `shipping_discount_tax_compensation_amount`,
> `base_shipping_discount_tax_compensation_amnt`,
> `discount_tax_compensation_invoiced`,
> `base_discount_tax_compensation_invoiced`,
> `discount_tax_compensation_refunded`,
> `base_discount_tax_compensation_refunded`, `shipping_incl_tax`,
> `base_shipping_incl_tax`, `gift_message_id`, `delivery_date`) VALUES
> (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '2016-04-19') in
> /data/sites/web/versdiversbe/www/vendor/magento/framework/Webapi/ErrorProcessor.php:194
> Stack trace:
> #0 /data/sites/web/versdiversbe/www/vendor/magento/framework/Webapi/ErrorProcessor.php(139):
> Magento\Framework\Webapi\ErrorProcessor->_critical(Object(Zend_Db_Statement_Exception))
> #1 /data/sites/web/versdiversbe/www/vendor/magento/module-webapi/Controller/Rest.php(163):
> Magento\Framework\Webapi\ErrorProcessor->maskException(Object(Zend_Db_Statement_Exception))
> #2 /data/sites/web/versdiversbe/www/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(24):
> Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
> #3 /data/sites/web/versdiversbe/www/vendor/magento/framework/App/Http.php(115):
> Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
> #4 /data/sites/web/versdiversbe/www/vendor/magento/framework/App/Bootstrap.php(258):
> Magento\Framework\App\Http->launch()
> #5 /data/sites/web/versdiversbe/www/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
> #6 {main} [] []
Anyone please an idea what i can do or check or how i can continue trouble shooting?
Things i have done :
disabled every module that i have
redeployed static content
Checked php.ini settings
Checked tax rates for double entries backend
checked database for sales_sequence tables
Know that
i use Php 7.0
i use phpmyadmin 4.5
I'm using a shared host at the moment
I have limited knowledge of PHP coding
UPDATES
So now i get to the order confirmation page BUT i do not get a confirmation mail. It seems that the server has internal problems to reach the xml files
UPDATES 2
I keep having 'order confirmation mail was not sent' then i press send mail (in the backend on the order view) and it says 'order confirmation mail was sent' but it is not. Hmmn
I solved this problem by deleting orders (actual orders, not order queue) from the cron_schedule in the database and putting my website 'asynchronous sending' on disabled
So I have an update_all query that looks like this:
Task.where(...).update_all('position = position - X, parent_id = Y')
I want to replace X and Y with integer values. And I'd like to do it safely: "the rails way".
Any idea of how I can achieve this ?
EDIT: There is no position variable in my rails controller. If X = 1, The final query should literally contain "position=position-1".
Also, The update_all documentation specifies that this method only takes one argument: A string, array, or hash representing the SET part of an SQL statement.
EDIT 2: Alright, I got it working by slightly tweaking Arup Rakshit solution. Here's the final working solution:
Task.update_all(['position = position - ?, parent_id = ?', X, Y])
Write as :
Task.where(...)
.update_all(['position = ?, parent_id = ?', position - X, Y])
Read update_all.
conditions - An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro for more info.
Demo:
Loading development environment (Rails 4.2.0)
[1] pry(main)> Person.pluck(:name, :email)
(0.4ms) SELECT "people"."name", "people"."email" FROM "people"
=> [["xxxx", nil], ["xxxx", nil], ["xxxx", nil]]
[3] pry(main)> Person.where(email: nil).update_all ["name = ?, email = ?", "foo", "test#test.com"]
SQL (0.7ms) UPDATE "people" SET name = 'foo', email = 'test#test.com' WHERE "people"."email" IS NULL
=> 3
[4] pry(main)> Person.pluck(:name, :email)
(0.3ms) SELECT "people"."name", "people"."email" FROM "people"
=> [["foo", "test#test.com"], ["foo", "test#test.com"], ["foo", "test#test.com"]]
[5] pry(main)>
Try doing it this way:
Task.where(...).update_all("position = ?, parent_id = ?",position - X, Y )
I am trying to call a function from oracle using OLE DB Command for SSIS, I have the connection set up Correctly but I think my Syntax for calling the function is incorrect?
EXEC UPDATE_PERSON ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? output
I have used this on a SQL stored proc for testing & it has worked. the oracal connection is 3rd party & they have just supplied the function name & expected parameters. I should get 1 return parameter.
The Error:
Error at Data Flow Task [OLE DB Command [3013]]: SSIS Error Code DTS_E_OLEDBERROR. AN OLE DB error has occurred. Error code 0x80040e14.
An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80040E14
Description: "ORA-00900: invalid SQL statement".
in your syntax you have to change the command " EXCU " to " EXEC ".
EXEC UPDATE_PERSON ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? OUTPUT
i have to mention that there is no need for { }
other than that you have to be aware of your full path of the SP that your are executing " by means of specifying [databaseName].[dbo]. if needed
Regards,
S.ANDOURA
Try wrapping it in curly braces:
{EXEC UPDATE_PERSON ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? output}
I don't think Oracle functions have output parameters - are you absolutely certain this is a function and not a proc? functions don't normally perform updates either.
syntax:
SELECT crm_customer.UPDATE_PERSON( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) FROM dual
I will update further details once solution has been completed
Thanks for the help
i'm trying to extract input fields from a website page and the page url (which contain these inputs ) and store them into a database ... ok
*** code works fine with no errors , but this isn't the desired output i want
spider code :
class MySpider(CrawlSpider):
name = 'isa_spider'
allowed_domains = ['testaspnet.vulnweb.com']
start_urls = ['http://testaspnet.vulnweb.com']
rules = (
Rule(SgmlLinkExtractor(allow=('/*' ) ),callback='parse_item'),)
def parse_item(self, response):
hxs = HtmlXPathSelector(response)
item=IsaItem()
item['response_fld']=response.url
res = hxs.select("//input[(#id or #name) and (#type = 'text' )]/#id ").extract()
item['text_input'] = res[0] if res else None # None is default value in case no field found
res = hxs.select("//input[(#id or #name) and (#type = 'password')]/#id").extract()
item['pass_input'] = res[0] if res else None # None is default value in case no field found
res = hxs.select("//input[(#id or #name) and (#type = 'file')]/#id").extract()
item['file_input'] = res[0] if res else None # None is default value in case no field found
return item
pipeline code
class SQLiteStorePipeline(object):
def __init__(self):
self.conn = sqlite3.connect('./project.db')
self.cur = self.conn.cursor()
def process_item(self, item, spider):
self.cur.execute("insert into inputs ( input_name) values(?)", (item['text_input'],))
self.cur.execute("insert into inputs ( input_name) values(?)", (item['pass_input'],))
self.cur.execute("insert into inputs ( input_name) values(?)", (item['file_input'],))
self.cur.execute("insert into links (link) values(?)", (item['response_fld'],))
self.conn.commit()
return item
database schema picture
required output picture
(sorry for not inserting images directly since my reputation is less than 10)
Haven't tested this:
class SQLiteStorePipeline(object):
def __init__(self):
self.conn = sqlite3.connect('./project.db')
self.cur = self.conn.cursor()
def process_item(self, item, spider):
cursor = self.cur
target_id = ? # determine target id
cursor.execute("insert into links (target, link) values(?, ?)", (target_id, item['response_fld'],))
link_id = cursor.lastrowid # find out just inserted link id
cursor.execute("insert into inputs (link_id, input_name, input_type) values(?, ?, ?)", (link_id, item['text_input'], 1))
cursor.execute("insert into inputs (link_id, input_name, input_type) values(?, ?, ?)", (link_id, item['pass_input'], 2))
cursor.execute("insert into inputs (link_id, input_name, input_type) values(?, ?, ?)", (link_id, item['file_input'], 3))
self.conn.commit()