Datatype of id columns NUMBER or STRING
hi,
plz tell me would it be beneficial to put the datatype of id columns as a string instead of number,,someone told me that string comparison is much faster than number column comparisons,,the reason he told me is tht comparison is done in binary form,,and to convert from string to binary is much lesser expensive than to convert from number to binary,,,the other group is saying that it has to convery string to number to binary,,,similarly number to binary,,so plz tell me what should be the datatype of id column let say values coming in it are like 001,002 etc...
regards
umar
I suggest you to do the workbench. I mean, take the execution plan of both number & string values and evaluate yourself.
Also, see the following link from the asktom site
http://asktom.oracle.com/pls/ask/f?p=4950:8:12430422674567031403::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:3051443177514,
Similar Messages
-
Using number datatype for date column
Hi
Is there a side effect for using "number" datatype for "date" column?
If so, what is the disadvantage?
Many thanksHi,
Ora_83 wrote:
Hi
Is there a side effect for using "number" datatype for "date" column?
If so, what is the disadvantage?Yes, there's a definite disadvantage.
Oracle provides date arithmetic and a number of functions for manipulating DATEs. None of them work with numbers.
For example,
SELECT TRUNC (order_date, 'MONTH') AS order_month
, AVG (ship_date - order_date) AS avg_delay
FROM orders
GROUP BY TRUNC (order_date, 'MONTH')
;order_month involves a DATE function; it's pretty easy to find the month that conatins order_date.
avg_delay involves date arithmetic. It's extrememly easy to find how much the time passed between order_date and ship_date.
Depending on how you code dates as numbers, doing either one of the above may be just as easy, but doing the other will be very difficult. You'll waste a lot of effort converting the NUMBERs to real DATEs whenever you need to manipulate them.
Validation can be very difficult for NUMBERs, also.
Watch this forum. It's a rare day when there's not some question about how to get around a problem caused by storing dates in a NUMBER (or VARCHAR2) column. Don't add to that. Always use DATE columns for dates. -
Change column datatype from varchar2 to number(10) and keep existing data
Hi,
I need to change the datatype on a column that already has data in it from a varchar2 to number(10). The data that is already there is not necessarily number data, however I must be able to keep the old data to. We are running 10g. Does anyone have any ideas? Thanks. Here's the current data.
Current Values for From_Value
T
U
T2
K
M
A
T
T1
O
E
S
NSTU
4Example of keeping the data in the current column and adding a new numeric column for numeric data:
SQL> drop table t purge;
Table dropped.
SQL> create table t(i int, x varchar2(10));
Table created.
SQL> insert into t values(1, 'T1');
1 row created.
SQL> insert into t values(2, 2);
1 row created.
SQL> --
SQL> alter table t add (xn number);
Table altered.
SQL> --
SQL> begin
2 for c in (select i, x from t)
3 loop
4 begin
5 update t set xn = to_number(c.x) where i = c.i;
6 exception
7 when invalid_number then null;
8 end;
9 end loop;
10 end;
11 /
PL/SQL procedure successfully completed.
SQL> show errors
No errors.
SQL> select * from t;
I X XN
1 T1
2 2 2 -
I am using Apex 4.2.2.00.11
am using the following description to create a web service reference:
web reference :REST
Name :Yahoo Map
URL :http://local.yahooapis.com/MapsService/V1/mapImage
HTTP Method: GET
Basic Authentication: No
Add Parameter:
Name Type
appid String
location String
Output Format: XML
XPath to Output Parameters : /Result
Output Parameter:
Name Path Type
Url /text() String
Then i tried to create form and report on webservice:
Web Service Reference Type: Yahoo Map
Operation: doREST
All the fields i keep as default
I tick the checkbox (url)in report Parameter
After clicking next whereever required i click create button
I get the following error
ORA-20001: Unable to create form on table. ORA-02263: need to specify the datatype for this column.
Please someone help to solve this as i need to fix it urgently.336554,
Looks like there is a 127-column limit on the number of report columns supported when using that wizard. Do you have more than that?
57434 -
PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got NUMBER
Hi all,
Wondering if you could assist? I'm exploring User Types and having a small problem. I'm getting the above error for a user type I have created which I'm calling in a function. Here's what my code looks like which I'm running the 'scott' schema for testing purposes
SQL> CREATE OR REPLACE TYPE NBR_COLL AS TABLE OF NUMBER;
2 /
Type created.
SQL> create or replace FUNCTION first_rec_only
2 (
3 NUM_ID IN NUMBER
4 ) RETURN NUMBER IS
5 v_num NBR_COLL;
6 BEGIN
7 select deptno into v_num from dept;
8 RETURN v_num(v_num.FIRST);
9 END first_rec_only;
10 /
Warning: Function created with compilation errors.
SQL> show errors
Errors for FUNCTION FIRST_REC_ONLY:
LINE/COL ERROR
7/4 PL/SQL: SQL Statement ignored
7/11 PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got
NUMBER
SQL>
Any clues to what I'm doing wrong? Cheers.The deptno column is a number, you cannot directly select a number into your type, you need to use your type's constructor.
Something like:
CREATE OR REPLACE FUNCTION first_rec_only (NUM_ID IN NUMBER) RETURN NUMBER IS
v_num NBR_COLL;
BEGIN
SELECT nbr_coll(deptno) INTO v_num from dept;
RETURN v_num(v_num.FIRST);
END first_rec_only;Note that although this will compile, it will throw ORA-01422: exact fetch returns more than requested number of rows when you run it. you need to either use the input parameter as a predicate on your query against dept, use rownum = 1 in the query or use bulk BULK COLLECT INTO, depending on what exactly you want to accomplish.
John -
i am using the following description to create a web service reference:
web reference :REST
Name :Yahoo Map
URL :http://local.yahooapis.com/MapsService/V1/mapImage
HTTP Method: GET
Basic Authentication: No
Add Parameter:
Name Type
appid String
location String
Output Format: XML
XPath to Output Parameters : /Result
Output Parameter:
Name Path Type
Url /text() String
Then i tried to create form and report on webservice:
Web Service Reference Type: Yahoo Map
Operation: doREST
All the fields i keep as default
I tick the checkbox (url)in report Parameter
After clicking next whereever required i click create button
I get the following error
ORA-20001: Unable to create form on table. ORA-02263: need to specify the datatype for this column.
Please someone help to solve this as i need to fix it urgently.i exported the application from apex.oracle.com and imported it to our environment
import went fine, but when I ran the IR page I got
ORA-20001: get_dbms_sql_cursor error ORA-00904: : invalid identifier
evidently the problem is a lack of public execute on DBMS_LOB, which is used in the generated IR source.
while waiting for the DBA to grant privs on DBMS_LOB, changing the dbms_lob.getlength call to length() fixes the IR.
however, i am not getting the download link on the associated form page... changed templates, that's not the issue -- we'll see if that's a dbms_lob issue as well -
ORDER BY timestamp column as a string
Does any one have any tips/tricks for using an ORDER BY clause for a timestamp column that is a string?
I am developing a UNION query that combines data from a table and an audit history table to show current data plus historical data.
I had to convert the timestamp column to a string so the datatypes would match for the UNION query, but now they ORDER BY clause does not work.
For example:
SELECT
location,
'CURRENT' as VALID_DATE
FROM
person
UNION
SELECT
location,
TO_CHAR(audit_date)
FROM
person_audit
ORDER BY 2 DESCHi,
user2269823 wrote:
Using the 'yyyy-mm-dd' format works pretty well when ordering by the string. It looks like when ordering by a string Oracle just looks at the characters sequentially.
For example:
2009-1-14
2008-12-31
2007-6-6Looks like you have changed the format slightly?
Consider this
SQL> select TO_CHAR(sysdate,'FMyyyy-mm-dd')
, TO_CHAR(sysdate, 'yyyy-mm-dd') from dual;
TO_CHAR(SY TO_CHAR(SY
2009-5-28 2009-05-28
SQL>Looks fine with me, as long as you don't have the FM format model modifer.
Regards
Peter -
Column number in JTextArea?
Hi
How do I get column number of current cursor
in JTextArea? I need to display this info
in my editor.
This is complicated by the fact that tab size
is not fixed, typing a combination of space
and tabs randomly can result in tabs
having tab size of 1 amid normal tabs.
Hence counting the number of chars in the
current line up to cursor position, call it C,
then C minus number of tabs, T and plus
T * tabSize won't work because tabSize is
sometimes 1.
Thanks
miawomiHello
Just figure out how to do this. In case anyone
get stuck with the same problem, here is my
soln:
JTextArea textArea = ...
int caretPos = textArea.getCaretPosition();
int lineCount = textArea.getLineCount();
int tabSize = textArea.getTabSize();
int currentLine = 1;
String str = "";
int c = 0;
try {
currentLine = textArea.getLineOfOffset( caretPos );
int startOffset =
textArea.getLineStartOffset (currentLine );
str = textArea.getText( startOffset,
caretPos-startOffset );
FontMetrics fm = textArea.getFontMetrics( textArea.getFont() );
StringBuffer buffer = new StringBuffer();
for ( int i = 0; i < tabSize; i++ )
buffer.append(" ");
int tabWidth = fm.stringWidth( buffer.toString() );
for ( int i = 0; i < str.length(); i++ ) { char C = str.charAt( i );
if ( fm.charWidth( C ) == tabWidth )
c = c + tabSize;
else
c++;
} catch ( BadLocationException ex ) {
ex.printStackTrace();
If anyone has a much less cpu intensive solution,
please let me know.
Thanks in advance
miaw -
Loading a large number of strings into memory quickly
Hello,
I'm working on an iPhone application where I need to load a large number of strings into memory. Currently I'm simply reading from a file where each string is stored in plain text on a single line. I read the file contents into a string using stringWithContentsOfFile and then I create an NSSet object using NSSet setWithArray:[string componentsSeparatedByString:@"\n"]];
This works like a charm but takes around 8 seconds to load on the iPhone. I'm looking for ways to speed this up. I've already tried a few things which weren't any faster:
1) I used [NSKeyedArchiver archiveRootObject:myList toFile:appFile]; to store the NSSet data structure. Then instead of reading the text file storage. I read this file using [NSKeyedUnarchiver unarchiveObjectWithFile:appFile]; This was actually very slow and created a strings file that was about 2x the size of the original plain text.
2) Instead of using an NSSet, I used and NSDictionary and used writeToFile and dictionaryWithContentsOfFile. This was also no faster.
3) Finally I tried using the NSDictionary to write to a binary file format using NSPropertyListSerialization. This was also not any faster.
I've been thinking about using SQLite instead of the flat file read, but I haven't had a chance to prototype that out to see if it would be faster. It's important that I can do fast searches for specific strings, which is why I originally used a set.
Does any one else have any ideas how to load this into memory faster? If all else fails, I'm simply going to load the strings into memory using a separate thread on application launch so I don't prevent the user from getting to the main menu for 8 seconds.
Thanks,
-KeithI'd need to know more about what you're doing, but from what you're describing I think you should try to change your algorithm.
For example: Instead of distributing one flat file, split your list of strings into 256 files, based on the first two hex digits of their MD5 hashes*. (Two digits might not be enough--you might need three or four. You may also want to use folders, especially if you need more than two digits.) When testing if a string exists, first calculate its MD5 hash and extract the necessary number of digits, then load that file into memory and scan its list. (You can cache these lists in memory so that you only have to load each file once--just make sure that a didReceiveMemoryWarning message will empty those caches.)
Properly configured, SQLite may be faster than the eight second load time you talk about, especially if you ensure it indexes the column you store the strings in. But it's probably overkill for this application.
\* A hash is a numeric code calculated from a string; on average, changing a single bit anywhere in the string should change half the bits in the hash, so even very similar strings should generate very different hashes. I suggest using MD5 instead of -\[NSString hash\] because the hash method is not guaranteed to return the same results on Mac OS and iPhone OS, or on different releases of either OS. You could also use a different algorithm, like a CRC; these are faster but I'm not as familiar with them. This thread discusses calculating MD5 hashes on iPhone OS: http://discussions.apple.com/thread.jspa?messageID=7362074
Message was edited by: Brent Royal-Gordon -
ORA-00932: inconsistent datatypes: expected UDT got NUMBER
Hello Friends...
i got this error while inserting record ..
ORA-00932: inconsistent datatypes: expected UDT got NUMBER
wht is that UDT ??
Thanks..You cannot insert into your table STUDENT using the COURSE_TAB collection, since the column SUB is defined as a single object type.
So either you have to modify your insert into two inserts as follows;
INSERT INTO STUDENT VALUES(1,COURSE('1','ORACLE') )
INSERT INTO STUDENT VALUES(1,COURSE('2','JAVA') )
/or you have to modify your table structure so you can store a nested table, which will allow you to have a single insert
something like this:
drop table s
drop type course_tab
create or replace type course_type as object (
CNO CHAR(1),
C_CNAME VARCHAR2(10)
CREATE or replace TYPE course_tab AS TABLE OF course_type;
create table s ( c course_tab )
nested table c store as course_list
-- You can now have a single insert as follows:
1* insert into s (c) values ( course_tab ( course_type('1','Java'), course_type('2','Oracle')) )
SQL> /
1 row created.Be careful of using nested tables though. asktom reckons one should not use them.
P; -
Hi Friends,
I am getting this error : ORA-00932: inconsistent datatypes: expected DATE got NUMBER at OCI call OCIStmtExecute when I am trying to put the filter condition on the date column.
"Dim-Time"."Day" <= cast(MAX("Dim-Time"."Day") as date) and "Dim-Time"."Day" >= TIMESTAMPADD(SQL_TSI_MONTH, -1,cast(MAX("Dim-Time"."Day") as date).
I have casted the max date but though I am getting the above error. I am thinking max(date) is creating the problem.
Please suggest your on opinion this.
Thanks.Not sure why you need cast in your statement if at all it is required then you need to do as below
cast("Dim-Time"."Day" as date)<= cast(MAX("Dim-Time"."Day") as date) and cast("Dim-Time"."Day" as date) >= TIMESTAMPADD(SQL_TSI_MONTH, -1,cast(MAX("Dim-Time"."Day") as date).
~ http://cool-bi.com -
Error message - ORA-00932: inconsistent datatypes: expected CHAR got NUMBER
Here is my Report Query...
select
from DW_RFA_JOBDATA
where FINISH_TIME >= :P1_START_DATE
and FINISH_TIME < :P1_END_DATE
AND RFA_FLAG = (CASE :P1_JOB_CLASSIFICATION WHEN '0' THEN 'LSF'
WHEN '1' THEN 'NON-LSF'
ELSE RFA_FLAG END)The column RFA_FLAG data type is NUMBER(*,0)... i am displaying LSF and Non-LSF in the select list box , but i get the error ORA-00932: inconsistent datatypes: expected CHAR got NUMBER >
I have created static LOV with LSF display 0 return
NON-LSF display 1 return..
Could any body please help me in truble shooting the error ? how do i convert datatype into number i dont have any privileges to make changes to the table...Are there multiple columns in the table you are using from your LOV?
Your LOV select is:
select
from DW_RFA_JOBDATA
where FINISH_TIME >= :P1_START_DATE
and FINISH_TIME < :P1_END_DATE
AND RFA_FLAG = (CASE :P1_JOB_CLASSIFICATION WHEN '0' THEN 'LSF'
WHEN '1' THEN 'NON-LSF'
ELSE RFA_FLAG END)Maybe try this:
select
from DW_RFA_JOBDATA
where FINISH_TIME >= :P1_START_DATE
and FINISH_TIME < :P1_END_DATE
AND TO_CHAR(RFA_FLAG) = DECODE(:P1_JOB_CLASSIFICATION,'0','LSF','1','NON-LSF',RFA_FLAG) -
What is excel file's maximum column number limit?
Hello all,
I am writing a long csv string within one line to an excel file. When I open the generated excel file, it reports "File not loaded completely". And it only generated patial file.
I am thinking maybe excel has maximum column number limit, and my excel file required more than 312 columns, that's why it caused this problem.
Does any one know the answer?
Thanks in advance !
RachelOk, I already solved this problem, excel has a 256 column limit.
Thanks,
Rachel -
Concatenate multiple columns into one string
Hello,
I am using Oracle 11.2, how can I concatenate the value of multiple columns into one string with one SQL:
create table testTb(classId number(5), classRoom varchar2(32));
insert into testTb value(101, 'room101');
insert into testTb value(101, 'room201');
insert into testTb value(101, 'room301');
insert into testTb value(202, 'room444');
insert into testTb value(202, 'room555');
I would like to generate the result as followings:
Class 101 is in room101, room201, room301
Class 202 is in room444, room555
Thanks,Hi,
Since you're using Oracle 11.2, you can use the aggregate LISTAGG function:
SELECT 'Class ' || classid
|| ' is in '
|| LISTAGG ( classroom
) WITHIN GROUP (ORDER BY classroom)
AS txt
FROM testtb
GROUP BY classid
;The generic name for concatenating all the strings in a group is String Aggregation . This page shows several ways to do it, suitable for different versions of Oracle. -
How to Plot number and string in one row (data logger counter) ?
hi all i made data log quantity using Digital Counter via modbus to monitoring quantity and reject that has and Name Operator, Machine and Part Number.
i have problem about plot the number & string in one row, as shown on the picture below :
how to move that string on one row ? i attach my vi.
Thanks~
Attachments:
MODBUS LIB Counter.vi 39 KBDuplicate and answered - http://forums.ni.com/t5/LabVIEW/How-to-Plot-number-and-string-in-one-row-data-logger-counter-via/m-p...
Maybe you are looking for
-
How do I share files between two Macs on my wireless network?
I have an iMac G4 and an ibook G3 on a wireless network. I have "file sharing" activated on both computers. (Also Appletalk, which may or may not be a misguided move, but I got the idea from OSX "Help.") When I try to get from either computer onto th
-
My iPhone 4 will not sync since upgrading to latest software release. I keep getting the error message "required file cannot be found". I've tried restoring several times with no success. I am using a MacPro notebook with the latest software relea
-
How do I remove a small box on my vector that I didn't add?
I've been working on a downloaded vector, but when I opened up it up in Ai a black square appeared in the center. (this did not appear on another computer). The square is now pink, has a "1" in the upper lefthand corner, and a jagged line in anothe
-
Cant get working Media Centre Remote under Win7
G'day just a quick one for you I have just updated to windows 7 ultimate 64 bit on my Toshiba Satellite P200 and the only thing I cant get working is my media centre remote. Any suggestions would be greatly appreciated.
-
Using Belkin ADC toDVI cable on older G4
I have a new 23 inch apple display and it works perfect with my Windows laptop. I wanted to use it on a Mac G4 (Green). The video Card did not support DVI so I bought a Belken ADC to DVI cable from the apple store on 5th ave. I plug in and the screen