match the number with the varchar data type
Hi allI want to compare the number data type with string. Is this possible? I use the function to_char. The example below.
SQL> select * from tab_a;
PLOT_NUMBER
------------
1
2
3
4
5
6
6 rows selected
SQL> select * from tab_b;
PLOT_NAME PLOT_NUMBER
--------------- ------------
seawods 5
bridge cros 2,4
hill park 1
bash hunk 3,6
SQL> select a.*, b.* from tab_a a, tab_b b where to_char(a.plot_number)=b.plot_number;
PLOT_NUMBER PLOT_NAME PLOT_NUMBER
------------ --------------- ------------
1 hill park 1
5 seawods 5
as you can see here this number of parcel 2, 4, and plot_number 3.6 not reported because they are string.Can anyone please suggest what can do us in this case.
I can't do chane data type.
Thanks in advance
SAZ
What you can do in the case?
Drop table table_b purge
as the 'design' of this table is obviously out of whack, and the content should have been
PLOT_NAME PLOT_NUMBER
--------------- ------------
seawods 5
bridge cros 2
bridge cros 4
hill park 1
bash hunk 3
bash hunk 6
You now have the instr function to the "join".
I would recommend standardization of the design. NOW
-----------------
Sybrand Bakker
Senior Oracle DBA
Tags: Database
Similar Questions
-
Impact on performance when you use the LONG data type
Hi all
Only I have a doubt about the use of LONG data type
I use the data type LONG for some columns in a table and I created indexes on the columns separately, but these column values can be easily fit into the varchar data type.
(Just to see the performance on this issue)
Suppose that a common select query with WHERE condition on any of the column which has LONG data type will affect the performance of the query?
Please explain.
Thank you(1) the LONG (and LONG RAW) data types have been depricated for quite a while. Oracle has been strongly recommends that you move to 8.1.5 CLOB and BLOB data types. Why you use the LONG data type? You're still on Oracle 7?
(2) have you tried to write a query that has a WHERE condition that refers to a LONG column? In general, you can not because it does not support the type of data LONG. For example
SQL> ed Wrote file afiedt.buf 1 create table a ( 2 col1 varchar2(30), 3 col2 long 4* ) SQL> / Table created. SQL> select * from a where col2='abc'; select * from a where col2='abc' * ERROR at line 1: ORA-00997: illegal use of LONG datatype
LONG data types are a royal pain to work with. They also have implications on the performance of wicked on the client.
Justin
-
convert the varchar2 data type to the data number type
How to convert the varchar2 data type to the data type number.
It looks like my data
create table one)
col1 varchar2 (50)
col2 varchar2 (500);
Insert in a (col1, col2) values ('1234 ', ' 2345');
Select Column1 of number (19)) cast (to_number (col1);
IAM getting error invalid number
I need to create a table with the same columns with data like number types (19)
can someone help me
Thank youYou have changed your original post, so now I see that you get the invalid number.
This is why you should always avoid the varchar columns to store numbers or dates...
Since your table source contains a nonnumeric value, you can write a pl/sql to convert data and see what records are false:
SQL> insert into a (col1,col2) values ('xxxx','2345'); 1 row created. SQL> select * from a; COL1 COL2 -------- -------- 1234 2345 xxxx 2345 2 rows selected. SQL> create table b (col1 number(19), col2 number(19)); Table created. SQL> set serverout on SQL> declare 2 cursor c is 3 select * from a; 4 begin 5 for r in c loop 6 begin 7 insert into b values (to_number(r.col1), to_number(r.col2)); 8 exception 9 when invalid_number then 10 dbms_output.put_line('Row rejected: col1='||r.col1||' col2='||r.col2); 11 end; 12 end loop; 13 end; 14 / Row rejected: col1=xxxx col2=2345 PL/SQL procedure successfully completed. SQL> select * from b; COL1 COL2 ---------- ---------- 1234 2345 1 row selected.
Max
Published by: Massimo Ruocchio, June 14, 2011 20:00
Added the first query in the example -
As an operator with the long data type
Oracle 10g.
Hi gurus
I want to apply as an operator on the long data type, but I get the error message, can you please help me why is that I use as an operator with the long data type. I did some research and but unable to find a solution, see query for more details below...
Query
SELECT trigger_body FROM user_triggers
WHERE trigger_body LIKE '% UPDA % CASE % ';
Error
ORA-00932: inconsistent data types: expected NUMBER got LONG
00932 00000 - ' incompatible data types: wait %s %s got. "
* Cause:
* Action:
Error on line: column 2: 7
Concerning
Muzz
Adrian Billington wrote to the top of your options.
-
Problem with the CLOB data type.
Greetings,
I am facing a problem with the CLOB data type. I know that the CLOB data type is 4 GB (I use Oracle 9i). But in the Pl Sql procedure, I can only store 34305 size for a CLOB variable character data.
This is the test script that I am trying to run.
DECLARE
-Local variables here*.
I have INTEGER;
C_1 CLOB.
BEGIN
FOR Rec IN (SELECT
*
ACCORDING TO THE TABLE)
LOOP
C_1: = c_1 | Rec.Clo_1;
END LOOP;
EXCEPTION
WHILE OTHERS THEN
Dbms_Output.put_line (SQLERRM);
END;
Here variable C_1 range value 34305 good character regardless of type CLOB. Now the above script fails if query my buckle - huge number of return values. It is throwing the exception "error during transfer of files ORA-06502: PL/SQL: digital error or value."
He would be grateful if someone can help me on this.
Thank you.You are probably better off using DBMS_LOB.append, instead of the concatenation of varchar2 (|).
And... take off your when-other Manager exceptions, please...
-
Using DBMS_DATAPUMP with the LONG data type
I have a procedure below that calls the DBMS_DATAPUMP procedure using a REMOTE_LINK move a schema of one database to another. However, some tables in this schema have columns with the data type of LONG. And when I run it I get an error saying that you cannot move the data with the LONG data type using a REMOTE CONNECTION. So no data in these specific tables gets flying over.
Does anyone else have this problem? If so, do you have a work around? I tried to add a CLOB column in my table and affecting the new CLOB equal THROUGHOUT, but I couldn't get that to not work either... even when I tried to use a TO_LOB. If I could get that pass, then I could just slide ALONG, the schema, and then re-create the LONG column on the opposite side.
Here is my procedure...
DECLARE
/ * IMPORT/EXPORT VARIABLES * /.
v_dp_job_handle NUMBER; -The handful of job data pump
v_count NUMBER; -Index of the loop
v_percent_done NUMBER; -Percentage of job complete
v_job_state VARCHAR2 (30); -To keep track of job status
v_message KU$ _LOGENTRY; -For error messages and work in PROGRESS
v_job_status KU$ _JOBSTATUS; -The State of the work of get_status
v_status KU$ _STATUS; -The status returned by get_status object
v_logfile NUMBER;
T_DATE VARCHAR2 (13).
v_source_server_name VARCHAR2 (50);
v_destination_server_name VARCHAR2 (50);
BEGIN
v_project: = 'TEST ';
T_DATE: = TO_CHAR (SYSDATE, 'MMDDYYYY_HHMI');
v_source_server_name: = 'TEST_DB ';
v_dp_job_handle: = DBMS_DATAPUMP. OPEN)
OPERATION = > "IMPORT."
JOB_MODE = > "SCHEMA."
REMOTE_LINK = > v_source_server_name,
JOB_NAME = > v_project | ' _EXP_' | T_DATE,
VERSION = > 'LAST');
v_logfile: = DBMS_DATAPUMP. KU$ _FILE_TYPE_LOG_FILE;
DBMS_DATAPUMP. ADD_FILE)
MANAGE = > v_dp_job_handle,
FILENAME = > v_project | ' _EXP_' | T_DATE |'. JOURNAL '.
DIRECTORY = > 'DATAPUMP. "
FILETYPE = > v_logfile);
DBMS_DATAPUMP. () METADATA_FILTER
MANAGE = > v_dp_job_handle,
NAME = > 'SCHEMA_EXPR ',.
VALUE = > ' = "' | v_project | " ' ') ;
DBMS_DATAPUMP. START_JOB (v_dp_job_handle);
v_percent_done: = 0;
v_job_state: = "UNDEFINED";
WHILE (v_job_state! = "COMPLETED") AND (v_job_state! = "STOPPED")
LOOP
DBMS_DATAPUMP. GET_STATUS)
v_dp_job_handle,
DBMS_DATAPUMP. KU$ _STATUS_JOB_ERROR + DBMS_DATAPUMP. KU$ _STATUS_JOB_STATUS + DBMS_DATAPUMP. KU$ _STATUS_WIP.
-1,
v_job_state,
v_status);
v_job_status: = v_status. JOB_STATUS;
IF v_job_status. PERCENT_DONE! = v_percent_done THEN
DBMS_OUTPUT. Put_line ('* percent of the job done = ' |) To_char (v_job_status. PERCENT_DONE));
v_percent_done: = v_job_status. PERCENT_DONE;
END IF;
IF BITAND (v_status. MASK, DBMS_DATAPUMP. KU$ _STATUS_WIP)! = 0 THEN
v_message: = v_status. WORK IN PROGRESS;
ELSIF BITAND (v_status.mask, DBMS_DATAPUMP. KU$ _STATUS_JOB_ERROR)! = 0 THEN
v_message: = v_status. ERROR;
ON THE OTHER
v_message: = NULL;
END IF;
IF v_message IS NOT NULL THEN
v_count: = v_message. FIRST;
While v_count IS NOT NULL
LOOP
DBMS_OUTPUT. Put_line (v_message (v_count). LOGTEXT);
v_count: = v_message. Next (v_count);
END LOOP;
END IF;
END LOOP;
DBMS_OUTPUT. Put_line ("' job has completed");
DBMS_OUTPUT. Put_line (' State of the Final work = ' | v_job_state);
DBMS_DATAPUMP. Detach (v_dp_job_handle);
END;TO_LOB can be used to insert, create table in select and update the instructions to convert
So: You simply cannot use it in SELECT..., you can use CREATE TABLE BLAH AS SELECT TO_LOB (LONG_COLUMN) OF DREADED_TABLE_WITH_LONG_COL;
-
DLL for LabWindows/CVI 8.0 with the bool data type
Hello
I want to use a new SWIR camera in LabWindows/CVI 8.0 (Windows XP 32bits).
The company delivered with the camera produced a 32-bit dll by using Microsoft Visual C++ 2010. The .dll and .lib and .h files include a working SDK/API (some functions with the bool data type)
Compilation-online syntax error, variable Boolean is not a data type in LabWindows/CVI 8.0
Generate the import of DLL-online syntax error library
I tried to convert bool char (typedef unsigned char bool => no more syntax error but the functions does not work.)
What can I do?
Martin
Hello again, Naumann!
Microsoft Visual C++ 2010 represents Boolean using 1 byte, as stated by MSDN: https://msdn.microsoft.com/en-us/library/tf4dy80a(v=vs.100).aspx
I guess that you import C++ functions using the syntax for extern "C". Otherwise, because of the C++ name mangling wouldn't you able to bind C++ library against your code CVI.
You can also specify how you import C++ functions?
In addition, because you have not described the problem as a corruption of heads or runtime error, I guess the C++ library function is called correctly the CVI. That said, I tend to believe that the problem is not really in the mechanism of interaction of C/C++, but in the C++ library. If you would start calling a dummy C++ function returning an integer from a simple CVI application that should work, because redefine bool in CVI 1 byte must ensure that settings are correctly transferred onto the stack.
If you need to create a wrapper function of C++ that is not using bool and calls the C++ function, I expect to return the same result.
Maybe you are missing a few prior initialization steps required? The provider of the camera also comes all example code?
Best regards!
-Johannes
-
Syntex to create the table with the long data type
I'm looking to create a table based on another table that having the column long data type. Throw the error ORA-00997: illegal use of the LONG data type
I tired itcreate table abc_long (ag bgd long number);
create table abc_long_dummy as ( ) Select *of abc_long); - ORA-00997 error: illegal use of the LONG data type
How to get there?
I'm looking to create a table based on another table that having the column long data type.
You really don't want to do that.
LONG data type has been deprecated for some time now, use CLOB.
The TO_LOB() function will do the conversion on the fly:
create table abc_long_dummy as select ag , to_lob(bgd) as bgd from abc_long ;
-
Insert/update the column with the clob data type
Hi all
ORCL Version: 11g.
I have a table with the clob data type.
Test12
(col1 clob);
I'm trying to insert/update to update the column with more than 4000 characters.
But due to the limitation of tank 4000, I could not Insert/Update.
Need your help in resolving this issue.
THX
Rod.
The limit of 4000 characters is incorrect. That pertains only to the varchar2 data type. A clob can hold more than 4 G.
Here is an example that shows how to insert it, I found...
Otherwise, here is a way 'dirty' to do.
insert into your_table (COLA, COLB)
values
(PRIMARY_KEY, PART 1 OF DATA)
;
Update your_table
Define COLB = COLB | PART 2 OF BIG DATA
where COLA = PRIMARY_KEY;
Update your_table
Define COLB = COLB | PART 3 OF BIG DATA
where COLA = PRIMARY_KEY;
.. and so on...
I don't know that I personally recommend the second style... But he could do the job.
-
Cannot save the types of collection with the correct data type (structure type)
Hi all!
I am beginner in using the Data Modeler (SQL Develeoper Version 3.0.04 build HAND - 04.34)
I tried to define types of structured data type type collection.
for example
Types of structure: StruA (for example, Integer, Float) and StruB (e. g. whole, Timestamp, Double, Double)
Types of collections: TabA should collect the types of StruA and TabB should collect the types of StruB.
create or replace TYPE TabA IS TABLE OF StruA;
create or replace TYPE TabB IS TABLE OF StruB;
It is possible to select the correct data type in the 'Collection Type properties' dialog box.
The data type is installed to unknown after the registration and the reopening of the design. I see that the correct type has been entered in the xml file associated with the type of collection:
< dataTypeDescr class = "oracle.dbtools.crest.model.design.datatypes.CollectionType$ DataTypeWrapper" >
65677BBB-FB68-963C-552D-3F98E528520B < type > < / type >
false < isreference > < / isreference >
< / dataTypeDescr >
File name of the structured type is 65677BBB-FB68-963C-552D-3F98E528520B.xml
On the display of the design or generation DDL lose again this information.
Is - this poor handling or a bug in the Data Modeler?
Can anyone help? THX
Gabor
Edited by: user9529349 the 26.09.2011 07:49Hey Gabor,
I'm afraid that this is a bug. This problem was reported earlier in this forum, loss of definition of type of data from one type of collection
Thank you
David -
How to extract data using the xml data type
Hello
I tried the following example using the xml data type, but not the desired output.
could you please correct the query in order to obtain the necessary
CREATE TABLE TEST.EMP_DETAIL ( EMPNO NUMBER, ENAME VARCHAR2(32 BYTE), EMPDETAILS SYS.XMLTYPE )
I need to get the record for Empid = '2'Insert into EMP_DETAIL (EMPNO, ENAME, EMPDETAILS) Values (7, 'Martin', XMLTYPE('<Dept> <Emp Empid="1"> <EmpName>Kevin</EmpName> <Empno>50</Empno> <DOJ>20092008</DOJ> <Grade>E3</Grade> <Sal>3000</Sal> </Emp> <Emp Empid="2"> <EmpName>Coster</EmpName> <Empno>60</Empno> <DOJ>01092008</DOJ> <Grade>E1</Grade> <Sal>1000</Sal> </Emp> <Emp Empid="3"> <EmpName>Samuel</EmpName> <Empno>70</Empno> <DOJ>10052008</DOJ> <Grade>E2</Grade> <Sal>2530</Sal> </Emp> <Emp Empid="4"> <EmpName>Dev</EmpName> <Empno>80</Empno> <DOJ>10032007</DOJ> <Grade>E2</Grade> <Sal>1200</Sal> </Emp> </Dept> '));
Then tried the following query with no expected o/p
Thank you...SELECT a.empno,a.ename,a.empdetails.extract('//Dept/Emp/EmpName/text()').getStringVal() AS "EmpNAME", a.empdetails.extract('//Dept/Emp/Empno/text()').getStringVal() AS "EMPNumber", a.empdetails.extract('//Dept/Emp/DOJ/text()').getStringVal() AS "DOJ", a.empdetails.extract('//Dept/Emp/Grade/text()').getStringVal() AS "Grade", a.empdetails.extract('//Dept/Emp/Sal/text()').getStringVal() AS "Salary", a.empdetails.extract('//Dept/Emp[@Empid="2"]').getStringVal() AS "ID", a.empdetails.extract('//Dept/Emp[EmpName="Coster"]').getStringVal() AS "CHK" FROM emp_detail a where empno=7 AND a.empdetails.existsNode('//Dept/Emp[@Empid="2"]') =1
Karthick_Arp wrote:
I'm not very good at that... But if your XML code should not be more like thisSQL> Insert into EMP_DETAIL 2 (EMPNO, ENAME, EMPDETAILS) 3 Values 4 (7, 'Martin', XMLTYPE('
5 6 .. cut ..1 7Kevin 850 920092008 10E3 113000 12Why? It is perfectly valid to data as attributes rather than elements and also quite common for key values.
-
CREATE or REPLACE (name in varchar2) procedure Compress_tab_partition
is
last_mnth_var varchar2 (8);
curr_mnth_var varchar2 (8);
number of last_mnth;
number of curr_mnth;
last_partition varchar2 (8);
high_val varchar2 (4000);
StartSelect to_char (add_months (trunc (sysdate, 'MM'),-1), 'YYYYMM') | ' 00' in the double last_mnth_var;
Select to_char (sysdate, 'YYYY') | TO_CHAR (sysdate, 'mm') | ' 00' in the double curr_mnth_var;
Select to_number (last_mnth_var) in the double last_mnth;
Select to_number (curr_mnth_var) in the double curr_mnth;Dbms_output.put_line ('Compression of GOLDMGR Table scores.' | table-name |) "to go". ») ;
Dbms_output.put_line(' ');/ * Step 1 - identify the name of the partition of the specified table must be compressed * /.
Select high_value from high_val from user_tab_partitions where table_name = table-name;
Select nom_partition into last_partition from user_tab_partitions where table_name = table-name and high_value = rtrim (high_val);/ * Step 2 - Alter partition table to compress * /.
run immediately "ALTER TABLE GOLDMGR." | table_name | ' CHANGE THE PARTITION '. last_partition | "COMPRESS by low query";
/ * Step 3 - Index rebuild step * /.
I'm in (select index_name in user_indexes where table_name = table-name)
loop
run immediately "ALTER INDEX GOLDMGR." | i.index_name |' REBUILD ";
end loop;Dbms_output.put_line (' COMPLETED: compress the Table partitions change.) ") ;
end;
/I'm getting an error like: Error (21,100): PL/SQL: ORA-00997: illegal use of the LONG data type
Please resolve.
HIGH_VALUE datatype is LONG. You may not use for a long TIME in WHERE clause expressions. You need to loop through the partitions by selecting HIGH_VALUE and then comparing. Secondly, there is no need to select double to calculate expressions. For example:
Select to_char (add_months (trunc (sysdate, 'MM'),-1), 'YYYYMM') | ' 00' in the double last_mnth_var;
should be replaced by
last_mnth_var: = to_char (add_months (trunc (sysdate, 'MM'),-1), 'YYYYMM') | ' 00'.
and there is no need to add_months here:
last_mnth_var: = to_char (trunc (sysdate, 'MM') - 1, "YYYYMM"). ' 00'.
But the main question is simply ALTER TABLE MODIFY PARTITION COMPRESS allows compression but does not compress. You must issue ALTER TABLE MOVE PARTITION COMPRESS:
SQL > create table tbl (n) partition by range (n)
2 (partition p1 values less than (maxvalue))
3. Select lpad('X',4000,'X') from dual connect by level<=>=>
4.Table created.
SQL > select bytes
2 from WHERE user_segments
3 where nom_segment = 'TBL '.
4 and nom_partition = 'P1 '.
5.BYTES
----------
830472192SQL > alter table tbl
2. change the partition p1 compress
3.Modified table.
SQL > select bytes
2 from WHERE user_segments
3 where nom_segment = 'TBL '.
4 and nom_partition = 'P1 '.
5.BYTES
----------
830472192SQL > alter table tbl
2. move the partition p1 compress
3.Modified table.
SQL > select bytes
2 from WHERE user_segments
3 where nom_segment = 'TBL '.
4 and nom_partition = 'P1 '.
5.BYTES
----------
8388608SQL >
SY.
-
How to use the LOB data type?
I can't create a table with the LOB data type.
Do I need an additional parameter in sys.odbc.ini?
My dsn information is
[tpch]
Driver=/home/TimesTen/TimesTen/tt1121/lib/libtten.so
Data store = / home/timesten/TimesTen/tt1121/tpch/tpch
LogDir = / home/timesten/TimesTen/tt1121/tpch/logs
PermSize = 4096
TempSize = 2048
PLSQL = 1
LOB = 1
DatabaseCharacterSet = US7ASCII
-bash-4, $ 1 ttdaemonadmin-version
TimesTen Release 11.2.1.2.0
There is no LOB = 1 attribute; Please, delete it from your definition ODBC to avoid potential errors.
LOB support has been added in the major version 11.2.2 TimesTen. So you use 11.2.1 LOB is not available. If you want to use LOB data, then you must upgrade to 11.2.2.
Chris
-
XMLTable: definition of the columns data type of table
Hello world
I am using ORACLE 11 g and you want to shred XML into a table called test used. I was hoping I'd be able to get the types of data to the employees table existing instead of specify them in the clause of columns. Is this possible?
Here is an example of what I'm trying to do. But I get an error: PL/SQL: ORA-00907: lack the right parenthesis on the line starting with columns.
Error detailsinsert into EMPLOYEES select * from xmltable( '/employees/employee' passing EMP_XML columns FIRST_NAME EMPLOYEES.FIRST_NAME%TYPE path 'first_name', LAST_NAME EMPLOYEES.LAST_NAME%TYPE path 'last_name', GENDER EMPLOYEES.GENDER%TYPE path 'gender', AGE EMPLOYEES.AGE%TYPE path 'age' );
Thank you.columns FIRST_NAME EMPLOYEES.FIRST_NAME%TYPE path 'first_name', * ERROR at line 16: ORA-06550: line 16, column 42: PL/SQL: ORA-00907: missing right parenthesis ORA-06550: line 11, column 5: PL/SQL: SQL Statement ignored
Specification of column names is required, but you can omit the declaration of data types.
See: the function XMLTABLE SQL/XML in Oracle XML DB
XMLTable is used with storage XML based on a schema of XMLType data type is optional. If absent, the data type is inferred from the XML schema. If Oracle > XML DB is unable to determine the right type of a node, a default type VARCHAR2 (4000) is used.
It is an Oracle extension; in the SQL/XML standard, the data type is always required.
Note:
The alleged data type might change as a result of the application of a patch or upgrade of Oracle XML DB. In particular, a new set of release or patch might be able to > determine the data type when the previous version was unable to do so (and therefore not reimbursed to VARCHAR2 (4000)). To protect against such an eventuality, specify an explicit data type with the data type. -
I want to convert the double data type to string type
I want to convert the double data type to string, have idea about thatHello
Use f
FN: String (ARG) returns the string value of the argument. The argument can be a number, boolean, or node-set element
Example: string (314)
Result: "314".http://w3schools.com/XPath/xpath_functions.asp#string
See you soon,.
Vlad
Maybe you are looking for
-
How can I show more top sites when I open a new tab? Currently it only shows four.
I opened a new tab and I see that first four sites, I used to get eight. How to change this back?
-
Genesis 4 Apple Tv doesn't have an optical Audio input jack.
I just replaced my generation 3 Apple Tv with a generation 4 Apple Tv. The Genesis 3 has an optical Audio input jack that I used to connect my Bose system. The Genesis 4 doesn't have it. Now I can't audio through my Bose system. Any suggestions?
-
HP 15 laptop keyboard stopped working (half anyway)
Z X C V Space bar M period and coma all stopped working randomly on my HP notebook15 while I was typing? I had to go on my phone to ask this question, because the space bar will not work. I had not yet 3 months and I don't spill anything on it. I res
-
Specification of starting byte of the string of bytes
Hello dear community, I'm looking for a way to start reading a continuous string series increments specified in specific positions of the string. I'll explain: The idea is using an Arduino board to read analog values of the 16 photodiodes and send th
-
ConfigFree has stopped working, can't use system restore
try using toshiba laptop wireless already installed cofigfree on computer, but does not work