Selecting a Long datatype

I have created a select statement and saved it to the variable sql_str. I then Open the cursor "OPEN v_cursor FOR sql_str;".
One of the columns in the select statement has a datatype of LONG. I fetch the column into a variable that I have declared as Long. I get the following error: ORA-00997: illegal use of LONG datatype.
What am I doing wrong?

One of the columns in the select statement has a datatype of LONG. I fetch the column into a variable that I have declared > as Long. I get the following error: ORA-00997: illegal use of LONG datatype.
What am I doing wrong?What are you doing differently:
SQL> desc user_views
VIEW user_views
Name                                      Null?    Type                       
VIEW_NAME                                 NOT NULL VARCHAR2(30)               
TEXT_LENGTH                                        NUMBER(0)                  
TEXT                                               LONG                        <-- Long
TYPE_TEXT_LENGTH                                   NUMBER(0)                  
TYPE_TEXT                                          VARCHAR2(4000)             
OID_TEXT_LENGTH                                    NUMBER(0)                  
OID_TEXT                                           VARCHAR2(4000)             
VIEW_TYPE_OWNER                                    VARCHAR2(30)               
VIEW_TYPE                                          VARCHAR2(30)               
SUPERVIEW_NAME                                     VARCHAR2(30)               
EDITIONING_VIEW                                    VARCHAR2(1)                
READ_ONLY                                          VARCHAR2(1)                
SQL> declare
   t   long;
begin
   for c in (select text from user_views where rownum = 1)
   loop
      t := c.text;
      dbms_output.put_line (t);
   end loop;
end;
SELECT
    "LIB_DYN_QUERY_ID" AS "LIB_DYN_QUERY_ID"
   ,"LIB_DYN_QUERY_NAME" AS "LIB_DYN_QUERY_NAME"
   ,"LIB_DYN_QUERY" AS "LIB_DYN_QUERY"
   ,"CREATED_ON" AS "CREATED_ON"
   ,"CREATED_BY" AS "CREATED_BY"
  FROM
    "UT_LIB_DYN_QUERIES"
  WITH READ ONLY
PL/SQL procedure successfully completed.?

Similar Messages

  • PHP selecting LONG datatype returns erroneous data

    I have a simple PHP script that queries an 8.1.6 database table with a couple of LONG datatype columns. The resulting output has a bunch of NULL characters and at the end of the column and duplicate data from the previous row. This only happens with this database instance. I run a similar query against a 9.2 database with LOB columns and the data returns correctly.
    $begin = "2004-01-15";
    $end = "2004-01-31";
    $begin = strtotime($begin." 00:00:00");
    $end = strtotime($end." 23:59:59");
    $connection = OCIPLogon($oracleUser, $oraclePasswd, $oracleServer);
    $query = "SELECT create_date, longcol1, longcol2 from table where create_date >= ".$begin." and create_date <= ".$end." order by create_date ";
    $stmt = OCIParse($connection, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    while (OCIFetch($stmt, OCI_ASSOC+OCI_RETURN_LOBS)) {
         $ncols = OCINumCols($stmt);
         for ( $i = 1; $i <= $ncols; $i++ ) {
              $result = ociresult($stmt, $i);
              if (is_object($result)) { echo "LOADING\n"; $result = $result->load(); }
              echo ocicolumnname($stmt, $i)." (".ocicolumntype($stmt, $i).") => ".trim($result)."\n";
         echo "\n";
    output is:
    CREATE_DATE (NUMBER) => 1074186503
    LONGCOL1 (LONG) => This is my first row/column with a long statement in it. 1234567890 bla bla bla bla bla bla bla bla ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
    LONGCOL2 (LONG) => This is my first row second column with a long statement in it. 1234567890 bla bla bla bla bla bla bla bla ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
    CREATE_DATE (NUMBER) => 1074184298
    LONGCOL1 (LONG) => This is my second row first column with a long statement in it. 567890 bla bla bla bla bla bla bla bla ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
    LONGCOL2 (LONG) => This is my second row second column with a long statement in it. 4567890 bla bla bla bla bla bla bla bla ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
    The actual data in the two rows is:
    First record:
    CREATE_DATE => 1074186503
    LONGCOL1 => This is my first row/column with a long statement in it. 1234567890 bla bla bla bla bla bla bla bla
    LONGCOL2 => This is my first row second column with a long statement in it. 1234567890 bla bla bla bla bla bla bla bla
    Second record:
    CREATE_DATE => 1074184298
    LONGCOL1 => This is my second row first column with a long statement in it.
    LONGCOL2 => This is my second row second column with a long statement in it.
    I am running PHP 4.3.6 on Linux. The database is Oracle 8.1.6.3.0.
    Any idea what is causing this?

    Get the latest version of oci8 and re-try. It has been extensively changed since your version. Try pulling the latest PHP from http://snaps.php.net
    Try only querying one LONG at a time (just to test whether it works). I recall LONGS needing special treatment in C code.
    When was the to_lob() function introduced in Oracle?:
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/functions185.htm#SQLRF06134
    Maybe you can convert to a LOB?
    -- cj

  • Selecting From Column with Long Datatypes

    create table temp
    a long
    insert into temp values ('abc');
    commit;
    select * from temp
    where a = 'abc'
    I am getting the following error while am tring to select a = 'abc';
    ora-00997 : illegal use of LONG datatype
    How can i select values from a column with long datatypes

    insert into temp values ('abc');
    cannot (must not) work, when the column is type long (thats a numeric type!!)
    -> here you get an ora- 00911 errorcode
    that the select doesn't work then should be clear.
    mfg f.humer

  • HS generic and long datatypes in Oracle 8i

    I have a problem importing LONG datatype columns
    from Hyperion Pillar to Oracle (version 8.1.6.0.0) using
    the (Hyperion supplied) ODBC driver and generic HS.
    The error message I get is
    ORA-03001: unimplemented feature
    ORA-02063: preceding line from PILLAR.WORLD
    From the message it seems clear that Oracle cannot
    deal with longs using generic connectivity (at least
    in v. 8.1.6).
    My questions:
    1) Is there a workaround ?
    2) Does this work in 9i ?
    Notes:
    1) The problem is not with the ODBC driver, as I
    can see the long datatype columns using another
    tool which connects to Pillar via ODBC.
    2) HS has been set up correctly because all datatypes
    other than long can be viewed in Oracle without any
    problems.
    3) Operating System: Windows NT 4.00.1381
    Any help would be much appreciated!
    Kailash.

    Thanks for the reply.
    Pillar LONGS (or MEMO, as they are referred to in Pillar)
    map to ODBC SQL_LONGVARCHAR. So it appears that the
    mapping is OK, and that SELECTing from these columns
    should be possible via generic connectivity.
    Any other ideas on what may be wrong? Any help is
    much appreciated.
    Thanks,
    Kailash.

  • Sql syntax for converting a long datatype value in to a integer datatype value

    I have to make a sql query where in i have a value of long datatype and i want to convert it into integer datatype value
    null

    It would have helped if you could have posted sample data.
    now my requirement is to calculate the difference in hours between the start time and end time.Assuming you want the difference in time irrespective of the dates and the time is stored like HH24:MI:SS format, you could try something like:
    SQL> WITH test_tab AS
      2       (SELECT '09:12:33' start_time, '12:30:33' end_time
      3          FROM DUAL
      4        UNION ALL
      5        SELECT '09:12:33' start_time, '14:12:33' end_time
      6          FROM DUAL)
      7        -- end of test data
      8  SELECT end_time, start_time,
      9         TRUNC (  (  TO_DATE (end_time, 'HH24:MI:SS')
    10                   - TO_DATE (start_time, 'HH24:MI:SS')
    11                  )
    12                * 24
    13               ) diff_in_hours
    14    FROM test_tab
    15  /
    END_TIME START_TI DIFF_IN_HOURS
    12:30:33 09:12:33             3
    14:12:33 09:12:33             5
    2 rows selected.Hope this helps,
    Regards,
    Jo

  • Illegal use of LONG datatype error message when i create materialized view

    Hello to all
    I want create read only materialized view replication environment two of our tables have LONG datatype when i create materialized view against on them
    I recieve this error message
    CREATE MATERIALIZED VIEW MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID AS SELECT * FROM MDB.TOAD_PLAN_TABLE@arahisto
    Error report:
    SQL Error: ORA-00997: illegal use of LONG datatype
    00997. 00000 - "illegal use of LONG datatype"
    Do you know any resort solution for it?
    thanks

    You can not use longs in materialized views over a database link, you can however take a part of a long over to a materialized view.
    I have gotten this to work in the past l had to create a PL/SQL function that you can use to extract the character data from the long column and use that to
    as part of the function you will need to pass in the columns of the table that will identify the unique records so you can pick out the long column
    example function
    -- you will need to make sure this funtion is in the remote location as you can not select longs accross a DB LINK.
    CREATE OR REPLACE FUNCTION MDB.TOAD_PLAN_LONG_CONV
    (pass in the primary key columns for the table)
    RETURN VARCHAR2
    IS
    v_long VARCHAR2(32767) ;
    BEGIN
    BEGIN
    -- need to select the long column into the PL/SQL variable
    SELECT long_column
    INTO v_long
    FROM MDB.TOAD_PLAN_TABLE
    WHERE key_columns = passed columns ;
    EXCEPTION
    WHEN OTHERS THEN
    IF SQLCODE = '-01406' THEN
    NULL ;
    ELSE
    RAISE ;
    END IF ;
    END ;
    RETURN SUBSTR(v_long,1,4000) ;
    END ;
    Then when you create the materialized view utilize that function on the long column.
    create or replace materialized view MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID
    AS
    SELECT column1, .... columnx,
    MDB.TOAD_PLAN_LONG_CONV@arahisto (primary key column list) as long_column_name
    FROM MDB.TOAD_PLAN_TABLE@arahisto ;
    See if this will work for you? Keep in mind however this solution will not get the entire long column only as much as a PL/SQL variable will hold of it.
    Mike

  • Using Decode with "Long" datatypes

    Hi,
    I want to use a select statement in a view which uses a decode function involving a "long" datatype. But doing some raises an error "Invalid datatypes". Is there a way around?
    Anupam.

    I'm a bit puzzled as to what it is you are trying to achieve (it has been an afternoon for vague requirements). Normally the sort of data that we would want to store in a LONG is ,er, long and therefore not susceptible to use in a DECODE. But it does not matter, because we can only manipulate LONGs in PL/SQL and that does not parse DECODE statements. We will have to use IF...ELSE constructs instead.
    CREATE OR REPLACE FUNCTION l2v (pl in rowid)  RETURN VARCHAR2
    AS
        ll LONG;
        rv VARCHAR2(20);        
    BEGIN
       SELECT col1
       INTO ll
       FROM   T_LONG
       WHERE  rowid = pl;
       IF ll LIKE '%text%'
       THEN
          rv := 'yes!';
       ELSE
          rv :=  'noooo';
       END IF;
       RETURN rv;
    END;
    SQL> select l2v(rowid) from t_long;
    L2V(ROWID)
    yes!
    yes!
    SQL> You can use this function in a query. Note that it is doing a SELECT in its own right so this will not be a very performant solution if you build the view on a big table.
    Cheers, APC

  • Substr with long datatype

    i try to use the substr function with the long datatype but it gave me error ora-00932 inconsistant datatypes...........

    i had saw u r given link and try that example also but it gave me the same ora-06502
    declare
    text_c1 varchar2(32767);
    sql_cur varchar2(2000);
    begin
    sql_cur := 'select '||'text'||' from
    '||'alpine'||'.'||'letters'||' where letter_id =
    '||chr(39)||7||chr(39);
    dbms_output.put_line (sql_cur);
    execute immediate sql_cur into text_c1;
    text_c1 := substr(text_c1, 1, 4000);
    --RETURN ;                                      
    dbms_output.put_line (TEXT_C1);
    END;

  • Creating tables with a long datatype

    I'm trying to create a table which is a copy of a table (and its contents) which has a long datatype column.
    I've got an error on the usual
    create table temp_XXXXX as select * from temp;
    statement.
    Any ideas please

    Can't be done using the CTAS syntax (see the SQL language reference for more details).
    To move LONG/LONG RAW data from one table to another will require some programming. If the LONG data is <32k you could do it in PL/SQL, otherwise you will need to do it in some other language/interface (maybe java?).

  • Error when using LONG Datatype

    Hi,
    I am transferring data from oracle to oracle. In my source table and target table i have a column of "long" datatype. When i execute the interface i am getting the following error.
    997 : 42000 : java.sql.SQLException: ORA-00997: illegal use of LONG datatype
    Cause: A value of datatype LONG was used in a function or in a DISTINCT, WHERE, CONNECT BY, GROUP BY, or ORDER BY clause. A LONG value can only be used in a SELECT clause.
    How can we resolve this issue in ODI?
    Thanks in Advance,
    Ram Mohan T

    Cezar,
    I am bit confused with the steps.
    1)     Create first interface with IKM Control append and flow_control yes but no long mapping
    This is the real interface to be created with out the Long Column mapping.
    2) Create second interface with IKM PL/SQL and "flow_control" NO and a "not exists "filter to "E$" (from first interface)
    Do I need to duplicate the same mapping here. I couldn’t understand this line Cezar. “and a "not exists "filter to "E$" (from first interface)”
    Does ODI doesnt provide any direct way to resolve this issue? When ever a table with Long datatype, do we need to do this steps?
    Thanks in Advance,
    Ram Mohan T

  • Accessing LONG datatype in Dynamic page

    I've been trying to access a LONG datatype in a cursor within a dynamic page. So far portal throws the following error:
    ORA-00922: missing or invalid option (WWV-11230)
    when I try the following code:
    <HTML>
    <HEAD>
    <TITLE>Dynamic Page</TITLE>
    </HEAD>
    <ORACLE>
    SET SERVEROUTPUT ON SIZE 100000;
    SET LONG 100000;
    declare
    v_text long;
    v_crn varchar2(10);
    cursor result_detail is
    select r.text, r.crn
    from results@mydb r
    where r.id = :p1;
    begin
    open result_detail;
    fetch result_detail into v_text, v_crn;
    htp.p etc ... display data ....
    close result_detail;
    end;
    </ORACLE>
    </BODY>
    </HTML>
    If I leave out the SET commands it can't find the page.
    Any clues? Has someone worked out how to get a LONG datatype value into Portal?
    Version 902.6.18 (win 2000 server)
    Thanks for any help.
    Philippe

    The SWF file was developed to work in such a way as it would only look in the root directory for the XML file.  Once the developer changed it so that it could access it from the same directory (regardless of what directory it was in), and then had to add 'id' and 'src' to the JavaScript function call, it worked like a charm.
    ^_^

  • ORA - 00997 Illegal Use Of Long Datatype when no Long is used

    I have a query that was working fine for years. We have upgraded to 10.2.0.5 on a test instance and we now get this error.
    The view in the FROM clause is an org specific view on xxc_affi_relation_headers_all. All of the fields in the view and underlying table are either VARCHAR2, NUMBER, or DATE.
    I have simplified the query to one that still gives the error.
    The query is:
    SELECT *
    FROM xxc_affi_relation_headers xarh
    WHERE xarh.affi_relation_id = (select xarh.affi_relation_id
    from xxc_affi_relation_headers xarh
    where xarh.execute_vendor_id = 125
    connect by prior xarh.affi_relation_id = xarh.parent_relation_id
    start with xarh.affi_relation_id = 214
    If I run the sub query by itself, as below, there is no error and the result is 214.
    select xarh.affi_relation_id
    from xxc_affi_relation_headers xarh
    where xarh.execute_vendor_id = 125
    connect by prior xarh.affi_relation_id = xarh.parent_relation_id
    start with xarh.affi_relation_id = 214
    If I run the main query and replace the sub query with 214, as below, thre is no error.
    Is there something that would cause an implicit conversion to a LONG datatype in this query? I am not able to find a reason for this error message that fits the query.
    The original query that caused the error was:
    SELECT xarh.affi_relation_id
    FROM
    xxc_affi_relation_headers xarh
    WHERE NOT EXISTS (SELECT 1 FROM xxc_oe_order_line_dist xold
    WHERE xold.line_id = p_line_id AND xold.dist_type = 'I'
    AND xold.affi_relation_id = xarh.affi_relation_id)-- 1704
    AND v_creation_date
    BETWEEN NVL(xarh.start_date,v_creation_date-1) AND NVL(xarh.end_date,v_creation_date+1) --ES fix not a valid month
    AND xarh.sale_segment1 = (SELECT gcco.segment1 --RT 9631
    FROM oe_transaction_types_all otty, ra_cust_trx_types_all rctt, gl_code_combinations gcco
    WHERE otty.transaction_type_id = p_order_type_id
    AND otty.cust_trx_type_id = rctt.cust_trx_type_id
    AND rctt.gl_id_rev = gcco.code_combination_id )
    AND EXISTS(SELECT 1 FROM xxc_affi_relation_lines xarl WHERE xarl.affi_relation_id = xarh.affi_relation_id
    AND NVL(xarl.element_value,v_item_type) = v_item_type)
    connect by prior xarh.parent_relation_id = xarh.affi_relation_id
    Start with
    xarh.affi_relation_id = (select xarh.affi_relation_id
    from xxc_affi_relation_headers xarh
    where xarh.execute_vendor_id = p_vendor_id
    AND xarh.affi_relation_id != p_parent_relation_id
    AND NOT EXISTS (SELECT 1 FROM xxc_affi_relation_headers xarh2
    WHERE xarh2.parent_relation_id = xarh.affi_relation_id)
    AND v_creation_date BETWEEN NVL(xarh.start_date,v_creation_date-1) AND NVL(xarh.end_date,v_creation_date+1)--ES fix not a valid month
    start with xarh.affi_relation_id = p_parent_relation_id
    connect by prior xarh.affi_relation_id = xarh.parent_relation_id)
    --ORDER BY NVL(parent_relation_id,-1), NVL2(xarl.element_value,1,2)
    ;

    Its a bug
    See this Oracle Document
    Bug 9726739 - ORA-997 from SQL with CONNECT BY and UNION [ID 9726739.8]
    Best Regards
    mseberg

  • ORA-00997: illegal use of LONG datatype - while inserting a record

    Hello,
    I have this table:
    create table TEST
    USER VARCHAR2(20) not null,
    WINCFG LONG RAW
    There are a few records, some with user='OLDUSER'.
    I want to add new records with a statement like this one:
    insert into TEST
    select 'NEWUSER',wincfg from TEST where user='OLDUSER'
    But Oracle returns the error:
    "ORA-00997: illegal use of LONG datatype"
    I have no idea...
    Thank you

    SQL> insert into TEST
      2  (
      3  select 'NEWUSER',wincfg from TEST where user='OLDUSER'
      4  );
    select 'NEWUSER',wincfg from TEST where user='OLDUSER'
    ERROR at line 3:
    ORA-00997: illegal use of LONG datatype
    SQL> copy from scott/tiger@mydb insert test using select * from test;
    Array fetch/bind size is 15. (arraysize is 15)
    Will commit when done. (copycommit is 0)
    Maximum long size is 80. (long is 80)
       1 rows selected from scott@mydb.
       1 rows inserted into TEST.
       1 rows committed into TEST at DEFAULT HOST connection.Hope it help

  • JDBC Thin Client and Oracle Long Datatype

    I am using Wepshere 4.0.2 , JDBC 2.0 (thin driver) and oracle 9i.
    I have a procedure which takes Oracle Long Datatype as its parameter.
    I use following code to execute procedure.
    String dataforsql="AAA000000003 123123 07/01/200301/01/2003";
    byte[] bytes = dataforsql.getBytes();
    InputStream is = new ByteArrayInputStream(bytes);
    cstmt=conn.prepareCall("call nscw.CPPF_SAVEPDCRAWTABLE2(?,?,?)");
    cstmt.setAsciiStream (1, is,bytes.length);
    The above code works perfectly for data upto 4000 bytes. Once the data crosses the 4000 mark.
    i get a procedure error
    ORA-01460: unimplemented or unreasonable conversion requested

    cstmt.setAsciiStream (1, is,bytes.length);Oracle's support for CLOB (and BLOB) columns using set{Ascii,Binary}Stream() generally s*cks. You'll have to read Oracle's own JDBC manual (you can read it online at http://technet.oracle.com) for whatever sequence they recommend.
    E.g. for insertion and updation of CLOBS, you're supposed to use an oracle-specific function (EMPTY_CLOB()) as the value in the INSERT/UPDATE statement, and then do a SELECT, getClob(), and use Clob APIs to update the actual column value. At least officially. Or you have to use some Oracle-specific APIs in oracle.sql.Connection and oracle.sql.CLOB.

  • Update LONG datatype columns

    Can anyone point me to a description on how I can update a column of datatype LONG.
    I will be using a stored procedure/cursor and need to be able to append a string variable to the end of a LONG datatype column that will have other text.
    Thanks in advance,
    Miller

    The use of LONG has several limitations. Please refer to the SQL Reference for details.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/toc.htm
    From the documentation:
    You can reference LONG columns in SQL statements in these places:
    n SELECT lists
    n SET clauses of UPDATE statements
    n VALUES clauses of INSERT statements
    The use of LONG values is subject to some restrictions:
    n A table cannot contain more than one LONG column.
    n You cannot create an object type with a LONG attribute.
    n LONG columns cannot appear in integrity constraints (except for NULL and NOT
    NULL constraints).
    n LONG columns cannot be indexed.
    n A stored function cannot return a LONG value.
    n Within a single SQL statement, all LONG columns, updated tables, and locked
    tables must be located on the same database.
    LONG columns cannot appear in certain parts of SQL statements:
    n WHERE clauses, GROUP BY clauses, ORDER BY clauses, or CONNECT BY clauses or
    with the DISTINCT operator in SELECT statements
    n The UNIQUE operator of a SELECT statement
    n The column list of a CREATE CLUSTER statement
    n The CLUSTER clause of a CREATE MATERIALIZED VIEW statement
    n SQL functions (such as SUBSTR or INSTR)
    n Expressions or conditions
    n SELECT lists of queries containing GROUP BY clauses
    n SELECT lists of subqueries or queries combined by the UNION, INTERSECT, or
    MINUS set operators
    Note: Oracle Corporation strongly recommends that you convert
    LONG columns to LOB columns. LOB columns are subject to far
    fewer restrictions than LONG columns. See "TO_LOB" on page 4-111
    for more information.

Maybe you are looking for