ora-01722

Can I pass a number for varchar2 in Oracle?

蹲街弑〆低调 提交于 2019-12-01 04:34:12
问题 I have an Oracle table and a column ( col1 ) has type varchar2(12 byte) . It has one row and value of col1 is 1234 When I say select * from table where col1 = 1234 Oracle says invalid number. Why is that? Why I cannot pass a number when it is varchar2 ? EDIT: All the responses are great. Thank you. But I am not able to understand why it does not take 1234 when 1234 is a valid varchar2 datatype. 回答1: The problem is that you expect that Oracle will implicitly cast 1234 to a character type. To

Joining tables with LIKE (SQL)

蓝咒 提交于 2019-12-01 03:21:50
First of all I am using Oracle: Table One Name = tableone Table Two Name = tabletwo tableone has a column named pizzaone , tabletwo has a column named pizzatwo . I want to join tableone to tabletwo where pizzaone is somewhere in the pizzatwo 's name. What I tried: select * from tableone join tabletwo on tableone.pizzaone like ('%' + tabletwo.pizzatwo + '%') How can I correct this query? Try this syntax instead: select * from tableone join tabletwo on tableone.pizzaone like ('%' || tabletwo.pizzatwo || '%') Oracle's string concatenation operator is the double pipe (||). The invalid number error

oracle jdbc driver version madness

若如初见. 提交于 2019-11-28 20:38:43
Why the heck does Oracle offer a different(!) version of the JDBC driver, e.g. ojdbc14.jar, for every(!) database version? The files all have different sizes and thus probably different content. background: We get a random and seemingly irreproducible error saying "invalid number" when saving data (we guess it's the Timestamp). But it's not any particular statement. Most of the time, it saves just fine. Just once a month a harmless looking statement will fail. So i had a closer look at Oracle's download site and noticed that none of the filesizes match despite files sharing the same name. Our

oracle jdbc driver version madness

那年仲夏 提交于 2019-11-27 13:02:30
问题 Why the heck does Oracle offer a different(!) version of the JDBC driver, e.g. ojdbc14.jar, for every(!) database version? The files all have different sizes and thus probably different content. background: We get a random and seemingly irreproducible error saying "invalid number" when saving data (we guess it's the Timestamp). But it's not any particular statement. Most of the time, it saves just fine. Just once a month a harmless looking statement will fail. So i had a closer look at Oracle

problem using Oracle parameters in SELECT IN

落爺英雄遲暮 提交于 2019-11-27 05:30:15
I have a problem when inserting a string of numbers into sql query SELECT * FROM tablename a WHERE a.flokkurid IN (3857,3858,3863,3285) ORDER BY sjodategund, rodun ...or: SELECT * FROM tablename a WHERE a.flokkurid IN (:strManyNumbers) ORDER BY sjodategund, rodun ...with this code: using (OracleCommand sel = new OracleCommand(SQL, connectionstring)) { sel.Parameters.Add(":strManyNumbers", OracleDbType.Varchar2, "Client", ParameterDirection.Input); } So if i run this query i get: ORA-01722: invalid number but if i insert just one number, i.e. "3857" it will return query OK with data. To pass a

C# parameterized queries for Oracle - serious & dangerous bug!

浪子不回头ぞ 提交于 2019-11-26 17:28:56
问题 This is an absolute howler. I cannot believe my own eyes, and I cannot believe nobody before me would have discovered this if it was a genuine bug in C#, so I'm putting it out for the rest of the developer community to tell me what I am doing wrong. I'm sure this question is going to involve me saying "DOH!" and smacking my head very hard with the palm of my hand - but here goes, anyway... For the sake of testing, I have created a table Test_1 , with script as follows: CREATE TABLE TEST_1 (

problem using Oracle parameters in SELECT IN

[亡魂溺海] 提交于 2019-11-26 11:36:19
问题 I have a problem when inserting a string of numbers into sql query SELECT * FROM tablename a WHERE a.flokkurid IN (3857,3858,3863,3285) ORDER BY sjodategund, rodun ...or: SELECT * FROM tablename a WHERE a.flokkurid IN (:strManyNumbers) ORDER BY sjodategund, rodun ...with this code: using (OracleCommand sel = new OracleCommand(SQL, connectionstring)) { sel.Parameters.Add(\":strManyNumbers\", OracleDbType.Varchar2, \"Client\", ParameterDirection.Input); } So if i run this query i get: ORA-01722