varchar2

difference between NLS_NCHAR_CHARACTERSET and NLS_CHARACTERSET for Oracle

这一生的挚爱 提交于 2019-12-18 15:54:48
问题 i have a quick question here, that i would like to know the difference between NLS_NCHAR_CHARACTERSET and NLS_CHARACTERSET setting in oracle ?? from my understanding NLS_NCHAR_CHARACTERSET is for NVARCHAR data types and for NLS_CHARACTERSET would be for VARCHAR2 data types. i tried to test this on my development server which my current settings for CHARACTERSET is as the following :- PARAMETER VALUE ------------------------------ ---------------------------------------- NLS_NCHAR_CHARACTERSET

Finding rows that don't contain numeric data in Oracle

丶灬走出姿态 提交于 2019-12-17 18:51:23
问题 I am trying to locate some problematic records in a very large Oracle table. The column should contain all numeric data even though it is a varchar2 column. I need to find the records which don't contain numeric data (The to_number(col_name) function throws an error when I try to call it on this column). 回答1: I was thinking you could use a regexp_like condition and use the regular expression to find any non-numerics. I hope this might help?! SELECT * FROM table_with_column_to_search WHERE

Cannot SUM(TO_NUMBER(varchar2 field)) :ORA 01722 [ORACLE]

為{幸葍}努か 提交于 2019-12-13 22:01:31
问题 I have myfield as varchar2 type and I try to sum this field by using sum(to_number(myfield)) but the result is ORA-01722 invalid number. before this error occured I used SUM(TO_NUMBER(REGEXP_REPLACE(BIKOU,'[[:alpha:]]', ''))) and it works but last week I put some decimal value in myfield so this code not work anymore. Here is my example of data in myfield 10,12,13.5,NULL 回答1: If you're getting that error from a string like 13.5 then your session's NLS_NUMERIC_CHARACTERS seems to be set to use

java returns empty String value for oracle VARCHAR2

↘锁芯ラ 提交于 2019-12-12 19:48:38
问题 I have the following code which appears to work correctly but it does not display any values for the personCode string. PERSON_CODE is a VARCHAR2 in an Oracle 9i database. I am using Java SE 1.7 and ojdbc7.jar for my project. I am new to Java can anybody give me some help with this? private static void GetEmployee(String input) { String output = ""; Connection con=null; PreparedStatement stmt = null; String sql ="SELECT ALL BADGE_NUMBER, PERSON_CODE FROM BADGETABLE WHERE BADGE_NUMBER = ?";

Replace CHAR with VARCHAR2

蓝咒 提交于 2019-12-12 16:27:15
问题 How can I replace CHAR with VARCHAR2 in all tables in a schema? Note: I'm content with a query that returns the ALTER TABLE statements so I can save the script and run it again. 回答1: select 'ALTER TABLE "' || owner || '"."' || table_name || '" MODIFY ("' || column_name || '" VARCHAR2(' || data_length || '));' from all_tab_columns tc where data_type = 'CHAR' and owner = :schemaname and exists ( select 1 from all_tables t where tc.owner = t.owner and tc.table_name = t.table_name ); 来源: https:/

10g ordering varchar columns when containing numbers in front

旧时模样 提交于 2019-12-12 10:56:38
问题 I have an Oracle 10g DB and have a VARCHAR2 (2000 Character) column lets name it TEST which can contain numbers in front for example: test 1test 3test When I call "... order by TEST asc" or simply "... order by TEST" I get the results ordered like test 1test 3test But I would like to get the results ordered like this: 1test 3test test So the numbered inserts first, is there a method to achieve this? 回答1: What is your NLS_SORT set to? ( select sys_context('USERENV', 'NLS_SORT') from dual ). If

Convert Varchar2 to Char array in Oracle

落花浮王杯 提交于 2019-12-11 06:16:21
问题 I have a varchar2 field and want to split it to array of chars Like 'ABCDEF' --> 'A' 'B' 'C' 'D' 'E' How can i convert my Field Values to chars array? 回答1: If you actually mean a PL/SQL collection of characters, you could do something like SQL> ed Wrote file afiedt.buf 1 declare 2 type char_arr is table of char(1) index by pls_integer; 3 l_str varchar2(100) := 'ABCDEF'; 4 l_arr char_arr; 5 begin 6 for i in 1 .. length(l_str) 7 loop 8 l_arr(i) := substr( l_str, i, 1 ); 9 end loop; 10 dbms

How does varchar2 sorting in oracle works?

余生颓废 提交于 2019-12-11 04:30:47
问题 I'm sorting a Oracle SQL query by a Varchar2 column. But when I get the results i can not correctly understand the ordering. Which is the logical order. first lower letters? numbers? symbols?. Here I attach the resulting ordering of one of the tests: select FieldToOrder from MyTable order by FieldToOrder ASC being FieldToOrder a VARCHAR2 column FieldToOrder: " 77777777777" //The first character is a blank space "aaas" "_aad" "AADD" "A00004AAAA9999" "ref11" "ref22" "0000000002222" Any ideas of

ORA-12899 value too large for column despite of same length

痞子三分冷 提交于 2019-12-10 03:36:23
问题 I am running the following query. But getting ORA-12899. Altough the length of string am trying to insert is 30. INSERT INTO TABLE1 SELECT * FROM temp_Table1 where LENGTH(column1)=30; SQL Error: ORA-12899:value too large for column "TABLE1"."column1" (actual: 31, maximum: 30) select column1 from temp_Table1 where LENGTH(column1)=30; Testing - HLC/TC Design Corre Desc temp_Table1 column1 VARCHAR2(30) Desc Table1 column1 VARCHAR2(30) 回答1: You're seeing the difference between character and byte

How to change a dataype CLOB TO VARCHAR2(sql)

社会主义新天地 提交于 2019-12-10 02:13:56
问题 Table: customers ID NAME DATATYPE NUMBER VARCHAR2(100) CLOB I want to change the DATA column from CLOB to `VARCHAR2(1000) I have try ALTER TABLE customers MODIFY DATA VARCHAR2 (1000) also ALTER TABLE customers MODIFY (DATA VARCHAR2 (1000)) also alter table customers modify (data VARCHAR2(4000)) those normally works if the datatype is not a clob but I am getting a ORA-22859 because I am using oracle toad/apex. 回答1: You may try this: Add a new column as varchar2 alter table my_table add (new