Home » RDBMS Server » Server Administration » Long datatype
Long datatype [message #373753] Fri, 04 May 2001 11:37 Go to next message
shweta
Messages: 8
Registered: May 2001
Junior Member
I heared that Oracle8 will be able to handle LONG manipulations .I am working in a oracle 8 version.
How do I convert long datatype to int.

Thanks,
Shweta
Re: Long datatype [message #373754 is a reply to message #373753] Fri, 04 May 2001 12:54 Go to previous messageGo to next message
jack
Messages: 123
Registered: September 2000
Senior Member
According to Andrew concept its works

you could try something like this...
CREATE TABLE LONGTAB (PK NUMBER,LONGCOL LONG);

insert into longtab values(1, '123');
insert into longtab values(2, 'one long string up to 32k - thats all that pl/sql long can take');
insert into longtab values(3, '456');
insert into longtab values(4, '999 another long one');

CREATE OR REPLACE FUNCTION long_2_num (v_recid IN NUMBER)
RETURN NUMBER
IS
CURSOR datacursor (v_pk longtab.pk%TYPE) IS SELECT longcol FROM longtab WHERE pk = v_pk;
v_long LONG;
v_retval NUMBER;
BEGIN
OPEN datacursor (v_recid);
FETCH datacursor INTO v_long;
v_retval := to_num (v_long);
--DBMS_OUTPUT.PUT_LINE ( 'Converted Long = '||v_retval );
CLOSE datacursor;
RETURN v_retval;
EXCEPTION
WHEN OTHERS
THEN
RETURN NULL;-- Whoops, cant convert!
END long_2_num;
/
Re: Long datatype [message #373758 is a reply to message #373753] Fri, 04 May 2001 16:19 Go to previous message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
make sure that LONG is what you think it is. LONG in Oracle is a text datatype which can store up to 2GB. Number stores numeric data up to 38 digits.

Make sure that you select the correct datatype. By far the most common datatypes are varchar2, number and date. Avoid having a proliferation of alternatives like float, char, int etc unless you have a good reason. Remember that check constraints are a good way of enforcing data rules.
Previous Topic: copying records into an indexed/primary key table
Next Topic: Date
Goto Forum:
  


Current Time: Mon Dec 23 09:48:02 CST 2024