ora-01722

Why am I getting an ORA-01722 (invalid number)?

一曲冷凌霜 提交于 2020-01-12 07:23:40
问题 I've been using a parameterized query to insert values into an Oracle table, like so: var q = "insert into MyTable(Field1, Field2...) values(:Field1, :Field2...)"; var cmd = new OracleCommand(q, conn); // conn is a pre-existing connection cmd.Parameters.Add("Field1", field1Val); cmd.Parameters.Add("Field2", field2Val); // etc... cmd.ExecuteNonQuery(); This has been working fine, but suddenly this has stopped working, and I am getting Oracle error ORA-01722 (invalid number). I have checked the

“Safe” TO_NUMBER()

孤人 提交于 2019-12-27 11:59:48
问题 SELECT TO_NUMBER('*') FROM DUAL This obviously gives me an exception: ORA-01722: invalid number Is there a way to "skip" it and get 0 or NULL instead? The whole issue: I have NVARCHAR2 field, which contains numbers and not almost ;-) (like * ) and I need to select the biggest number from the column. Yes, I know it is a terrible design, but this is what I need now... :-S UPD : For myself I've solved this issue with COALESCE(TO_NUMBER(REGEXP_SUBSTR(field, '^\d+')), 0) 回答1: I couldn't find

“Safe” TO_NUMBER()

梦想与她 提交于 2019-12-27 11:58:09
问题 SELECT TO_NUMBER('*') FROM DUAL This obviously gives me an exception: ORA-01722: invalid number Is there a way to "skip" it and get 0 or NULL instead? The whole issue: I have NVARCHAR2 field, which contains numbers and not almost ;-) (like * ) and I need to select the biggest number from the column. Yes, I know it is a terrible design, but this is what I need now... :-S UPD : For myself I've solved this issue with COALESCE(TO_NUMBER(REGEXP_SUBSTR(field, '^\d+')), 0) 回答1: I couldn't find

Invalid numbers

淺唱寂寞╮ 提交于 2019-12-24 03:24:52
问题 So, I have a column of data, to use a previous example, body temperatures, that is stored as varchar so that no record gets rejected, however, it contains numeric data. The people sending me the data are using a less than perfect system, so I have some incorrect data. What I need to do is write a SQL query to find valid values above or below a certain value. For example, all temps over 104, which should indicate either extreme cases or errors. I tried: select count(1), result_num from VITALS

Joining tables with LIKE (SQL)

安稳与你 提交于 2019-12-19 05:37:06
问题 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? 回答1: Try this syntax instead: select * from tableone join tabletwo on tableone.pizzaone like ('%' ||

Function or Procedure for an IN clause

我只是一个虾纸丫 提交于 2019-12-18 06:53:53
问题 I want to write a funcion or procedure that can be used in the IN clause of another procedure. The function or procedure would return ID numbers. The main procedure would say something like SELECT * FROM EMPLOYEES WHERE OFFICE_ID IN (GET_OFFICE_IDS); -- GET_OFFICE_IDS requires no parameters GET_OFFICE_IDS returns a VARCHAR2 with the ID separated by commas. When I run the main procedure, I get a "ORA-01722: invalid number" error which makes sense but I don't know where I need to go from here.

Function or Procedure for an IN clause

半腔热情 提交于 2019-12-18 06:52:36
问题 I want to write a funcion or procedure that can be used in the IN clause of another procedure. The function or procedure would return ID numbers. The main procedure would say something like SELECT * FROM EMPLOYEES WHERE OFFICE_ID IN (GET_OFFICE_IDS); -- GET_OFFICE_IDS requires no parameters GET_OFFICE_IDS returns a VARCHAR2 with the ID separated by commas. When I run the main procedure, I get a "ORA-01722: invalid number" error which makes sense but I don't know where I need to go from here.

Create a Sequence with START WITH from Query

坚强是说给别人听的谎言 提交于 2019-12-17 19:37:42
问题 How can I create a Sequence where my START WITH value comes from a query? I'm trying this way: CREATE SEQUENCE "Seq" INCREMENT BY 1 START WITH (SELECT MAX("ID") FROM "Table"); But, I get the ORA-01722 error 回答1: The START WITH CLAUSE accepts an integer. You can form the "Create sequence " statement dynamically and then execute it using execute immediate to achieve this. declare l_new_seq INTEGER; begin select max(id) + 1 into l_new_seq from test_table; execute immediate 'Create sequence test

Invalid number error

半世苍凉 提交于 2019-12-13 06:14:59
问题 I have a related question and trying to implement their answer to my problem. When I try to use their proposed solution I get ORA-01722: invalid number. Here is my table CREATE TABLE TEMP_PARSE_EXIST ( PHYS_ST_ADRS VARCHAR2(64 CHAR), PHYS_ADRS_LN2 VARCHAR2(64 CHAR), PHYS_COM_NM VARCHAR2(50 CHAR), PROV VARCHAR2(10 CHAR), PSTL_CD VARCHAR2(16 CHAR), CNTRY VARCHAR2(50 CHAR), MAIL_ADRS VARCHAR2(64 CHAR), MAIL_ADRS_LN2 VARCHAR2(64 CHAR), MAIL_COM_NM VARCHAR2(50 CHAR), MAIL_PROV VARCHAR2(10 CHAR),

Oracle number and varchar join

青春壹個敷衍的年華 提交于 2019-12-12 08:22:54
问题 I have a query that joins two tables. One table has a column that is of type varchar, and the other table has type of number. I have executed my query on 3 oracle databases, and am seeing some strange results I hope can be explained. On two of the databases something like the following works. select a.col1, b.somecol from tableA a inner join tableB b on b.col2=a.col1; In this query tableA.col1 is of type number and tableB.col2 is of type varchar. This works fine in two of the databases but