Re: [cx-oracle-users] "expecting string, unicode or buffer object" on executemany
Brought to you by:
atuining
From: Avinash P. N. <avi...@or...> - 2014-10-15 02:23:47
|
Hello Riccardo, For the 26 nd column " Competenzascarti " different data types have been bound in the first and second iteration. In the first iteration value is ''50899.74" which is a string and second iteration value is 0.0 which is a number. If using executemany() the binds have to be of the same data type across iterations else inconsistent results may occur. Thus if you try to execute with cursor.execute() it will work correctly. Also if you remove the quotes and send as numbers it will run correctly. Best Regards, Avinash ----- Original Message ----- From: ol...@ca... To: cx-...@li... Cc: avi...@or... Sent: Tuesday, 23 September, 2014 7:42:47 PM GMT +05:30 Chennai, Kolkata, Mumbai, New Delhi Subject: RE: [cx-oracle-users] "expecting string, unicode or buffer object" on executemany Hi, we are using: - python: 2.6.6 - cx_Oracle: 5.1.2 The problem seems to be caused by an incorrect definition of numeric fields: I try to insert a record with a numeric values but wrote as a string (surrounded by double quotes). If I use the instruction “execute” in a cycle I obtain an “invalid number” error from oracle ( ORA-01722), but if I use the “executemany” the error is: “ expecting string, unicode or buffer object ” When I use my code into my program it works correctly, and the records are inserted in table without any errors, but if I extract the part for the attached example I receive the error code 1722… To replicate the problem, I send you a code example (see attached). Thanks a lot. Riccardo Here you can find the “create table” scripts: CREATE TABLE "A_TEST" ( " Compagnia " NUMBER, " Datavalutazione " DATE, "Descr.compagnia" VARCHAR2(4000 BYTE), " Tipovalutazione " VARCHAR2(4000 BYTE), " Ramo " VARCHAR2(4000 BYTE), " Struttura " VARCHAR2(4000 BYTE), " Portafoglio " VARCHAR2(4000 BYTE), "Descr.portafoglio" VARCHAR2(4000 BYTE), " Prodotto " NUMBER, "Descr.prodotto" VARCHAR2(4000 BYTE), " Sottoprodotto " VARCHAR2(4000 BYTE), " Descrsottoprodotto " VARCHAR2(4000 BYTE), " Titolocodiceinterno " NUMBER, "ISIN" VARCHAR2(4000 BYTE), "Descr.titolo" VARCHAR2(4000 BYTE), " Quantita " NUMBER, " Valorecarico " NUMBER, " Prezzocarico " NUMBER, " Valoremercato " NUMBER, " Prezzomercato " NUMBER, " Plusmercato " NUMBER, " Minusmercato " NUMBER, "Plus_minusnegoziazione" NUMBER, " Competenzadividendi " NUMBER, " Competenzacedolare " NUMBER, " Competenzascarti " NUMBER, " Capitalemedio " NUMBER, " Rendimentodiperiodo " NUMBER, "Duration" NUMBER, " Durationmodificata " NUMBER, " Rendimentoeffettivolordo " NUMBER, " Vitaresidua " NUMBER, "RipresediValore" NUMBER, " Minusresidue " NUMBER, " Nominaleinizioperiodo " NUMBER, "Pat.nettoannocorrente" NUMBER, " Gruppotitolo " VARCHAR2(4000 BYTE), " Categoriadibilancio " VARCHAR2(4000 BYTE), "Descr.categoriadibilancio" VARCHAR2(4000 BYTE), "Catt.ST.P.CL.1" VARCHAR2(4000 BYTE), "Cod.Bloomberg" VARCHAR2(4000 BYTE), "YellowKeyBloomberg" VARCHAR2(4000 BYTE), "Index-linked" VARCHAR2(4000 BYTE), " Tipoquotazione " VARCHAR2(4000 BYTE), " Tipofondo " VARCHAR2(4000 BYTE), " Fondo " VARCHAR2(4000 BYTE), " Tipostrutturato " VARCHAR2(4000 BYTE), "FondoArmonizzato" VARCHAR2(4000 BYTE), " Dataemissione " DATE, " Datascadenza " DATE, " Prezzoemissione " NUMBER, " Datarimborso " DATE, " Prezzorimborso " NUMBER, " Paeseemissione " VARCHAR2(4000 BYTE), "AreaGeografica" VARCHAR2(4000 BYTE), "ZonaA" VARCHAR2(4000 BYTE), " Mnemonicoemittente " VARCHAR2(4000 BYTE), " Settoreemittente " VARCHAR2(4000 BYTE), "Descr.emittente" VARCHAR2(4000 BYTE), " Capogruppoemittente " VARCHAR2(4000 BYTE), "RatingMOODYS" VARCHAR2(4000 BYTE), "RatingS&P" VARCHAR2(4000 BYTE), "RatingFITCH" VARCHAR2(4000 BYTE), " Ratingcalc ." VARCHAR2(4000 BYTE), "RatingMOODYSI.E." VARCHAR2(4000 BYTE), "RatingSPIE" VARCHAR2(4000 BYTE), "RatingFITCHIE" VARCHAR2(4000 BYTE), "Ratingcal.cIE" VARCHAR2(4000 BYTE), " Tipotasso " VARCHAR2(4000 BYTE), " Periodicitacedola " VARCHAR2(4000 BYTE), " Cedolacorrente " VARCHAR2(4000 BYTE), " Tassocedola " NUMBER, "Floor" NUMBER, "Cap" NUMBER, " Subordinato " VARCHAR2(4000 BYTE), " Mercatodiquotazione " VARCHAR2(4000 BYTE), " Divisaemissione " VARCHAR2(4000 BYTE), "Descr.calcolorateo" VARCHAR2(4000 BYTE), " Datagodimento " DATE, " Tipopaese " VARCHAR2(4000 BYTE), "Valorestoricodiv.ist." NUMBER, "Valorestoricodiv.emi." NUMBER, " Cambiodicarico " NUMBER, " Capitalesociale " NUMBER, " Collegamentoistituto " VARCHAR2(4000 BYTE), "FondoAperto_Chiuso" VARCHAR2(4000 BYTE), "FondoRiservato" VARCHAR2(4000 BYTE), "ValoreNominalefineperiodo" NUMBER ) From: avinash nandakumar [mailto:avi...@or...] Sent: martedì 23 settembre 2014 14:29 To: cx-...@li... Cc: Oliosi Riccardo Subject: Re: [cx-oracle-users] "expecting string, unicode or buffer object" on executemany Hello Ricardo, Can you send a sample insert statement (unicode) similar to one you are using. Also can you inform which python/ cx-oracle and oracle version you are using. Best Regards, Avinash On 9/23/2014 5:32 PM, Oliosi Riccardo wrote: Hello everybody, I have a strange error: When I call: cursor.executemany( self.__sql, self.__buffer ) where self.__sql is an insert statement (unicode) and self.__buffer is a list of tuple, the execution throws an exception with the following message: “expecting string, unicode or buffer object” But if I substitute the executemany with a cycle: for item in self.__buffer: cursor.execute(self.__sql, item) the script works without any problems. Can anyone help me? Thanks in advance. Riccardo ______________________ Riccardo Oliosi SIDFramework Gruppo CAD IT Tel. +39.045.82.11.111 Fax +39.045.82.11.110 ol...@ca... www.cadit.it CAD IT S.p.A. Sede legale: Via Torricelli, 44/A - 37136 Verona C.S. € 4.669.600,00 i.v. C.F./P.IVA e n. iscr. R.I. di VR 01992770238 R.E.A. di VR n. 210441 ______________________ Questo messaggio, con gli eventuali allegati, contiene informazioni riservate o confidenziali. Chiunque lo ricevesse pur non essendone il destinatario è pregato di segnalarlo immediatamente al mittente, di cancellarlo dal proprio sistema e di non copiarlo, diffonderne il contenuto o utilizzarlo in alcun modo. This e-mail and any files transmitted with it are confidential or privileged. If you are not the intended recipient of this e-mail, please notify the sender and delete it from your system immediately: you should not copy, disclose or use either it or its attachments in any way whatsoever. ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ cx-oracle-users mailing list cx-...@li... https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |