Procedure or function for insert into select ...

Hi!
We need to know if we can create a procedure or function that will run the following script:
insert into agent.train_schedule
select 4000, '06:25' ,trunc(sysdate, 'year')+t.n
from agent.trains, (select rownum -1 n from dual
connect by level <= 365) t
where agent.trains.id = 4000 and
agent.trains.weekday like '%'||to_char(trunc(sysdate, 'year')+t.n, 'd',
'nls_date_language=AMERICAN')||'%';
The script inserts the train schedule dates into the train schedule table in accordance to the trains table.
Any help would be appreciated.
Thanks!

Try the below:
Create Or Replace procedure test_proc(p_train_no number, p_train_time varchar2) as
begin
insert into agent.train_schedule
select p_train_no, p_train_time ,trunc(sysdate, 'year')+t.n
from agent.trains, (select rownum -1 n from dual
connect by level <= 365) t
where agent.trains.id = p_train_no and
agent.trains.weekday like '%'||to_char(trunc(sysdate, 'year')+t.n, 'd',
'nls_date_language=AMERICAN')||'%';
end;
Call the procedure from the gui also pass the train number and the train time.
Regards,
Samujjwal Basu

Similar Messages

  • Commit for every 1000 records in  Insert into select statment

    Hi I've the following INSERT into SELECT statement .
    The SELECT statement (which has joins ) has around 6 crores fo data . I need to insert that data into another table.
    Please suggest me the best way to do that .
    I'm using the INSERT into SELECT statement , but i want to use commit statement for every 1000 records .
    How can i achieve this ..
    insert into emp_dept_master
    select e.ename ,d.dname ,e.empno ,e.empno ,e.sal
       from emp e , dept d
      where e.deptno = d.deptno       ------ how to use commit for every 1000 records .Thanks

    Smile wrote:
    Hi I've the following INSERT into SELECT statement .
    The SELECT statement (which has joins ) has around 6 crores fo data . I need to insert that data into another table.Does the another table already have records or its empty?
    If its empty then you can drop it and create it as
    create your_another_table
    as
    <your select statement that return 60000000 records>
    Please suggest me the best way to do that .
    I'm using the INSERT into SELECT statement , but i want to use commit statement for every 1000 records .That is not the best way. Frequent commit may lead to ORA-1555 error
    [url http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:275215756923]A nice artical from ASKTOM on this one
    How can i achieve this ..
    insert into emp_dept_master
    select e.ename ,d.dname ,e.empno ,e.empno ,e.sal
    from emp e , dept d
    where e.deptno = d.deptno       ------ how to use commit for every 1000 records .
    It depends on the reason behind you wanting to split your transaction into small chunks. Most of the time there is no good reason for that.
    If you are tying to imporve performance by doing so then you are wrong it will only degrade the performance.
    To improve the performance you can use APPEND hint in insert, you can try PARALLEL DML and If you are in 11g and above you can use [url http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_parallel_ex.htm#CHDIJACH]DBMS_PARALLEL_EXECUTE to break your insert into chunks and run it in parallel.
    So if you can tell the actual objective we could offer some help.

  • ORA-01461 can bind a LONG value only for insert into a LONG

    I Use ODP.net Insert and update Image files to Oralce blob columns(Oracle8i Server,ora92 client),
    When the files larger than 4000 characters,It doesn't work.error:ORA-01461 can bind a LONG value only for insert into a LONG
    My Vb.net code:
    Dim dlg As OpenFileDialog
    Dim strFileName() As String
    Dim fsBLOB As System.IO.FileStream
    Dim Adapter As OracleDataAdapter
    Dim ds As New DataSet
    Dim row As DataRow
    Dim cb As OracleCommandBuilder
    Dim bytes() As Byte
    dlg = New OpenFileDialog
    dlg.Filter = "Import File (*.*)|*.*"
    Adapter = New OracleDataAdapter("select * from a_blob_contents where 1=0", Me.OraConnection)
    Adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
    Adapter.FillSchema(ds, SchemaType.Source, "BLOB")
    cb = New OracleCommandBuilder(Adapter)
    If dlg.ShowDialog() = DialogResult.OK Then
    strFileName = dlg.FileNames()
    Dim loopCount As Integer
    For loopCount = 0 To strFileName.GetLength(0) - 1
    row = ds.Tables("BLOB").NewRow()
    row("BLOB_ID") = GetMaxBh("A_BLOB_CONTENTS", "BLOB_ID")
    row("FILE_ID") = FileID
    row("FILE_TYPE") = FileType
    Dim file_name As String
    file_name = strFileName(loopCount)
    file_name = file_name.Substring(file_name.LastIndexOf("\") + 1, file_name.Length - file_name.LastIndexOf("\") - 1)
    row("BLOB_NAME") = file_name
    fsBLOB = New FileStream(strFileName(loopCount), FileMode.Open, FileAccess.Read)
    ReDim bytes(fsBLOB.Length)
    fsBLOB.Read(bytes, 0, System.Convert.ToInt32(fsBLOB.Length))
    fsBLOB.Close()
    row("blob_contents") = bytes
    row("user_code") = Global.user_code
    row("Operate_date") = Now
    ds.Tables("BLOB").Rows.Add(row)
    Next
    Try
    Adapter.Update(ds, "BLOB")
    Catch ex As Exception
    MessageBox.Show(ex.Message)
    End Try
    End If
    I'll appreciate for anyone who can help me solve this problem.

    Hi Zhenquan,
    The issue is that you can not direct insert more than 4K (as you have discovered). Two methods I use in this situation are:
    1) sql statement or procedure that returns a lob locator into an ODP.NET OracleBlob parameter such as:
    insert into the_table (primary_key, blob_column) values (pk_value, empty_blob()) returning blob_column into :blob_parameter.
    Once you have the OracleBlob you should be able to write/update the data.
    2) use an anonymous pl/sql block or package that uses the dbms_lob supplied package to work with the LOB.
    Here is a simple console example...
    SQL> create table blob_test
    2 (
    3 blob_id number,
    4 blob_data blob,
    5 constraint blob_test_pk primary key (blob_id)
    6 )
    7 tablespace users;
    Table created.
    Sub Main()
    Dim strFileName As String = "c:\temp\testimage.jpg"
    Dim fsBlob As FileStream = New FileStream(strFileName, FileMode.Open)
    Dim bytes(fsBlob.Length) As Byte
    fsBlob.Read(bytes, 0, fsBlob.Length)
    fsBlob.Close()
    Dim con As OracleConnection = New OracleConnection("User Id=/; Data Source=lt8i")
    con.Open()
    Dim trans As OracleTransaction = con.BeginTransaction()
    Dim sql As String = "insert into blob_test (blob_id, blob_data) values (1,empty_blob()) returning blob_data into :blob_parameter"
    Dim blob_parameter As OracleParameter = New OracleParameter
    blob_parameter.OracleDbType = OracleDbType.Blob
    blob_parameter.Direction = ParameterDirection.InputOutput
    Dim cmd As OracleCommand = New OracleCommand(sql, con)
    cmd.Parameters.Add(blob_parameter)
    cmd.ExecuteNonQuery()
    Dim blob As OracleBlob = blob_parameter.Value
    blob.Write(bytes, 0, bytes.Length)
    sql = "update blob_test set blob_data = :blob_parameter where blob_id = 1"
    cmd.CommandText = sql
    blob_parameter.Value = blob
    cmd.ExecuteNonQuery()
    trans.Commit()
    End Sub
    This sample was tossed together pretty quickly, so it is not a complete, bullet-proof sample, but hopefully it will give you what you need to get started. The 'testimage.jpg' file is just over 5MB in size.
    Hope that helps,
    Mark
    =======================================
    Mark A. Williams
    Oracle DBA
    Author, Professional .NET Oracle Programming
    http://www.apress.com/book/bookDisplay.html?bID=378

  • APex 4.1 Error ORA-01461: can bind a LONG value only for insert into a LONG

    Hi There,
    Facing a strange issue.
    I have a regular cursor, and in that cursor loop I have a select statement into some variables based on cursor parameters.
    I was getting the "ORA-01461: can bind a LONG value only for insert into a LONG column" error so I started individually checking each of the columns. Now it works fine for some column, but the moment I add this number field. It starts throwing this error. Now, the database source where the select is fired is of type number, the variable into which I select it is number .
    Infact, I dont have any LONG column defined anywhere.
    The strange thing is that the block executes perfectly fine in SQl developer. So looks like a Apex specific issue.
    I am on 4.1/11g
    Any ideas?
    Thanks,
    Sun

    sun1977 wrote:
    Now, I have put this inside a Dynamic action (PL/SQL procedure). I think this PL/SQL procedure will go up to about 1500 to 2000 lines of code. There are no long columns involved anywhere or even CLOB, BLOB etc.
    Is there any limitation to the size of code? When you say size of a code. Are you saying the whole PL/SQL block is stored in one Varchar2(4000) field? :) Did not know that. I am quite sure, the PL/SQL compiled package on the database would work perfect. Just was wondering why it was not working within APEX!
    Also, Is there any documentation regarding this that you might be aware of?You can look at the APEX views. Code for some purposes (like region source) is stored in CLOBs:
    desc apex_application_page_regions
    Name                           Null     Type               
    WORKSPACE                      NOT NULL VARCHAR2(255 BYTE) 
    WORKSPACE_DISPLAY_NAME                  VARCHAR2(4000 BYTE)
    APPLICATION_ID                 NOT NULL NUMBER             
    APPLICATION_NAME               NOT NULL VARCHAR2(255 BYTE) 
    PAGE_ID                        NOT NULL NUMBER             
    PAGE_NAME                      NOT NULL VARCHAR2(255 BYTE) 
    REGION_NAME                    NOT NULL VARCHAR2(255 BYTE) 
    PARENT_REGION_ID                        NUMBER             
    PARENT_REGION_NAME                      VARCHAR2(255 BYTE) 
    TEMPLATE                                VARCHAR2(255 BYTE) 
    TEMPLATE_ID                             NUMBER             
    STATIC_ID                               VARCHAR2(255 BYTE) 
    REST_ENABLED                            VARCHAR2(3 BYTE)   
    DISPLAY_SEQUENCE               NOT NULL NUMBER             
    DISPLAY_REGION_SELECTOR                 VARCHAR2(3 BYTE)   
    REGION_ATTRIBUTES_SUBSTITUTION          VARCHAR2(4000 BYTE)
    ESCAPE_ON_HTTP_OUTPUT                   VARCHAR2(3 BYTE)   
    DISPLAY_COLUMN                          NUMBER             
    DISPLAY_POSITION                        VARCHAR2(255 BYTE) 
    DISPLAY_POSITION_CODE                   VARCHAR2(255 BYTE) 
    REGION_SOURCE                           CLOB
    ...for others&mdash;like LOV source and DA actions (PL/SQL code is stored in <tt>ATTRIBUTE_01</tt>)&mdash;are only VARCHAR2(4000 BYTE):
    desc apex_application_page_da_acts
    Name                        Null     Type               
    WORKSPACE                   NOT NULL VARCHAR2(255 BYTE) 
    WORKSPACE_DISPLAY_NAME               VARCHAR2(4000 BYTE)
    APPLICATION_ID              NOT NULL NUMBER             
    APPLICATION_NAME            NOT NULL VARCHAR2(255 BYTE) 
    PAGE_ID                     NOT NULL NUMBER             
    PAGE_NAME                   NOT NULL VARCHAR2(255 BYTE) 
    DYNAMIC_ACTION_ID           NOT NULL NUMBER             
    DYNAMIC_ACTION_NAME         NOT NULL VARCHAR2(255 BYTE) 
    ACTION_NAME                          VARCHAR2(100 BYTE) 
    ACTION_CODE                 NOT NULL VARCHAR2(50 BYTE)  
    ACTION_SEQUENCE             NOT NULL NUMBER             
    DYNAMIC_ACTION_EVENT_RESULT          VARCHAR2(5 BYTE)   
    EXECUTE_ON_PAGE_INIT                 VARCHAR2(3 BYTE)   
    AFFECTED_ELEMENTS                    VARCHAR2(4000 BYTE)
    AFFECTED_ELEMENTS_TYPE               VARCHAR2(30 BYTE)  
    AFFECTED_REGION                      VARCHAR2(255 BYTE) 
    AFFECTED_REGION_ID                   NUMBER             
    ATTRIBUTE_01                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_02                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_03                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_04                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_05                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_06                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_07                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_08                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_09                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_10                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_11                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_12                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_13                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_14                         VARCHAR2(4000 BYTE)
    ATTRIBUTE_15                         VARCHAR2(4000 BYTE)
    STOP_EXECUTION_ON_ERROR              VARCHAR2(3 BYTE)   
    LAST_UPDATED_BY                      VARCHAR2(255 BYTE) 
    LAST_UPDATED_ON                      DATE               
    COMPONENT_COMMENT                    VARCHAR2(4000 BYTE)
    ACTION_ID                   NOT NULL NUMBER             
    COMPONENT_SIGNATURE                  CHAR(15 BYTE)       Oracle presmably have reasons for this difference but it's not something that is made clear in any way through the Builder UI.
    Common sense should come into play. As Tony points out, the proper way to develop and deploy complex PL/SQL is using modular subprograms stored in packages. Same for APEX as for anything else.

  • Error ORA-01461: can bind a LONG value only for insert into a LONG column

    Within an existing application , i need to create a new report , i created a new page in it and then tried to create classic report , during wizard when i enter the same query which i have used for previous page , it gives me following error during the creation of report.
    The following bind variable i have already used for previous page. I want to reuse the same bind variables. There is no any long dataype within column predicates.
    Error ORA-01461: can bind a LONG value only for insert into a LONG column
    OK
    Following is the query
    SELECT
       "VWSR_ALL_MERGED_DATA_MV"."SR_AREA" "SR_AREA",
       "VWSR_ALL_MERGED_DATA_MV"."SR_STATUS" "SR_STATUS",
       "VWSR_ALL_MERGED_DATA_MV"."SR_SUB_STATUS" "SR_SUB_STATUS",
       "VWSR_ALL_MERGED_DATA_MV"."SR_DATE_CREATED" "SR_DATE_CREATED",
       "VWSR_ALL_MERGED_DATA_MV"."SR_OPEN_DATE" "SR_OPEN_DATE",
       "VWSR_ALL_MERGED_DATA_MV"."SR_CLOSED_DATE" "SR_CLOSED_DATE",
       "VWSR_ALL_MERGED_DATA_MV"."SR_PRODUCT1" "SR_PRODUCT1",
       "VWSR_ALL_MERGED_DATA_MV"."SR_PRODUCT2" "SR_PRODUCT2",
       "VWSR_ALL_MERGED_DATA_MV"."SR_TIO_PRIORITY" "SR_TIO_PRIORITY",
       "VWSR_ALL_MERGED_DATA_MV"."SR_REF_NUMBER" "SR_REF_NUMBER",
       "VWSR_ALL_MERGED_DATA_MV"."SR_DATE_RECD" "SR_DATE_RECD",
       "VWSR_ALL_MERGED_DATA_MV"."SR_CIDN" "SR_CIDN",
       "VWSR_ALL_MERGED_DATA_MV"."SR_BUS_UNIT" "SR_BUS_UNIT",
       "VWSR_ALL_MERGED_DATA_MV"."SR_NUMBER" "SR_NUMBER",
       "VWSR_ALL_MERGED_DATA_MV"."SOURCE_SYSTEM" "SOURCE_SYSTEM",
       "VWSR_ALL_MERGED_DATA_MV"."BATCH_ID" "BATCH_ID"
    FROM VWSR_ALL_MERGED_DATA_MV
    WHERE trunc(VWSR_ALL_MERGED_DATA_MV.SR_DATE_RECD)=trunc(sysdate-1)
      AND VWSR_ALL_MERGED_DATA_MV.SR_TIO_PRIORITY  IN
                                                    :P2_SR_TIO_PRIORITY
                                                   ,'CEO'
                                                   ,'TER'
                                                   ,'Priority Assistance'
                                                   ,'Enquiry'
      AND   (
            (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                                         'Business Support and Improvement'
                                       , 'Finance and Administration'
                                       , 'Cust Sat Simplification and Productivity'
                                       , 'Project New and Customer Experience'
                                       , 'Corp Strategy and Customer Experience'
                                       , 'Other'
                AND :P2_SR_BUSINESS_UNIT= htf.escape_sc('BS&I'))
       OR   (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                                         'Consumer'
                                       , 'Consumer Telstra Country Wide'
                                       , 'Customer Service and Sales'
                                       , 'Offshore Sales and Service'
                                       , 'TC and TCW Operations'
                                       , 'Telstra Country Wide'
                                       , 'Other'
                AND :P2_SR_BUSINESS_UNIT= htf.escape_sc('TC&C'))
       OR   (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                             'Telstra Customer Sales and Service'                  
                            ,'Telstra Program Office'
                            ,'Human Resources'
                            ,'IT'
                            ,'Unallocated'
                            ,'Other'
                AND :P2_SR_BUSINESS_UNIT= 'OTHER')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                        'Telstra Operations'
                       ,'Telstra Networks and Services'
                       ,'Other'
                AND :P2_SR_BUSINESS_UNIT= 'TO')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Telstra Business'
                AND :P2_SR_BUSINESS_UNIT= 'TB')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Telstra Wholesale'
                AND :P2_SR_BUSINESS_UNIT= 'TW')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Telstra Enterprise and Government'
                AND :P2_SR_BUSINESS_UNIT= htf.escape_sc('TE&G'))
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Sensis'
                     ,'Sensis Pty Ltd'
                AND :P2_SR_BUSINESS_UNIT= 'SENSIS')
    AND :P2_SR_TIO_PRIORITY = 'Level 0'
    UNION
    SELECT
       "VWSR_ALL_MERGED_DATA_MV"."SR_AREA" "SR_AREA",
       "VWSR_ALL_MERGED_DATA_MV"."SR_STATUS" "SR_STATUS",
       "VWSR_ALL_MERGED_DATA_MV"."SR_SUB_STATUS" "SR_SUB_STATUS",
       "VWSR_ALL_MERGED_DATA_MV"."SR_DATE_CREATED" "SR_DATE_CREATED",
       "VWSR_ALL_MERGED_DATA_MV"."SR_OPEN_DATE" "SR_OPEN_DATE",
       "VWSR_ALL_MERGED_DATA_MV"."SR_CLOSED_DATE" "SR_CLOSED_DATE",
       "VWSR_ALL_MERGED_DATA_MV"."SR_PRODUCT1" "SR_PRODUCT1",
       "VWSR_ALL_MERGED_DATA_MV"."SR_PRODUCT2" "SR_PRODUCT2",
       "VWSR_ALL_MERGED_DATA_MV"."SR_TIO_PRIORITY" "SR_TIO_PRIORITY",
       "VWSR_ALL_MERGED_DATA_MV"."SR_REF_NUMBER" "SR_REF_NUMBER",
       "VWSR_ALL_MERGED_DATA_MV"."SR_DATE_RECD" "SR_DATE_RECD",
       "VWSR_ALL_MERGED_DATA_MV"."SR_CIDN" "SR_CIDN",
       "VWSR_ALL_MERGED_DATA_MV"."SR_BUS_UNIT" "SR_BUS_UNIT",
       "VWSR_ALL_MERGED_DATA_MV"."SR_NUMBER" "SR_NUMBER",
       "VWSR_ALL_MERGED_DATA_MV"."SOURCE_SYSTEM" "SOURCE_SYSTEM",
       "VWSR_ALL_MERGED_DATA_MV"."BATCH_ID" "BATCH_ID"
    FROM
       VWSR_ALL_MERGED_DATA_MV
    WHERE trunc(VWSR_ALL_MERGED_DATA_MV.SR_DATE_RECD)=trunc(sysdate-1)
       and VWSR_ALL_MERGED_DATA_MV.SR_TIO_PRIORITY IN (:P2_SR_TIO_PRIORITY)
    AND  (
         (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN (
                         'Business Support and Improvement'
                       , 'Finance and Administration'
                       , 'Cust Sat Simplification and Productivity'
                       , 'Project New and Customer Experience'
                       , 'Corp Strategy and Customer Experience'
                       , 'Other'
    AND :P2_SR_BUSINESS_UNIT= htf.escape_sc('BS&I'))
    OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN (
                         'Consumer'
                       , 'Consumer Telstra Country Wide'
                       , 'Customer Service and Sales'
                       , 'Offshore Sales and Service'
                       , 'TC and TCW Operations'
                       , 'Telstra Country Wide'
                       , 'Other')
    AND  :P2_SR_BUSINESS_UNIT= htf.escape_sc('TC&C'))
    OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                             'Telstra Customer Sales and Service'                  
                            ,'Telstra Program Office'
                            ,'Human Resources'
                            ,'IT'
                            ,'Unallocated'
                            ,'Other'
            AND :P2_SR_BUSINESS_UNIT= 'OTHER')
    OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                          'Telstra Operations'
                          ,'Telstra Networks and Services'
                          ,'Other'
            AND :P2_SR_BUSINESS_UNIT= 'TO')
    OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                         'Telstra Business'
            AND :P2_SR_BUSINESS_UNIT= 'TB')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Telstra Wholesale'
            AND :P2_SR_BUSINESS_UNIT= 'TW')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Telstra Enterprise and Government'
            AND :P2_SR_BUSINESS_UNIT= htf.escape_sc('TE&G'))
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Sensis'
                     ,'Sensis Pty Ltd'
            AND :P2_SR_BUSINESS_UNIT= 'SENSIS')
    AND :P2_SR_TIO_PRIORITY = 'Level 1'Edited by: user13653962 on 30/01/2013 15:11
    Edited by: user13653962 on 30/01/2013 15:14

    You have an error in the code:
    1. you don't provide a value for 'what' - you have to tell Oracle what it should execute when it submits the job.
    And remember - with ISUBMIT the next_date parameter has datatype VARCHAR2 - SUBMIT uses datatype DATE. So make sure you provide a VARCHAR2 value and do not rely on implicit conversion.
    >
    PROCEDURE DBMS_JOB.ISUBMIT
    (job IN BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN VARCHAR2
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);
    PROCEDURE DBMS_JOB.SUBMIT
    (job OUT BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN DATE DEFAULT SYSDATE
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);

  • ORA-01461: can bind a LONG value only for insert into a LONG column in 11.2

    Hello,
    We have been getting the following exception when we try to save an XML (>5k).
    SQL state [72000]; error code [1461]; ORA-01461: can bind a LONG value only for insert into a LONG column
    This is occurring only for Oracle 11g (11.2.0.1.0)
    Our column is CLOB type, not LONG type.
    Could anyone please suggest what could be the reason and fix?
    Thanks in advance
    --Cheers
    paruvid

    Thanks for quick response!!
    Inserting throw JDBC (Spring jdbcTemplate)
    using the ojdbc6.jar as driver
    here is the stask strace
    Caused by: org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO tabl1(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15,c16(CLOBCOL),c17, c18, c19) SELECT c1,c2, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? FROM table2 S JOIN table1 D ON S.c1 = D.c1 WHERE S.c2 = ? AND D.c5 = ? GROUP BY S.c1];
    SQL state [72000]; error code [1461]; ORA-01461: can bind a LONG value only for insert into a LONG column
    ; nested exception is java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:602)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:786)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:842)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:846)
    at com.smartstream.cms.message.dao.SSIMessageDao.editSSIInstance(SSIMessageDao.java:522)
    ... 52 more
    Caused by: java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
    Edited by: paruvid on Aug 9, 2011 5:07 AM
    Edited by: paruvid on Aug 9, 2011 5:17 AM
    Edited by: paruvid on Aug 9, 2011 5:23 AM

  • ORA-01461: can bind a LONG value only for insert into a LONG Classic Report

    I am trying to create a report but get a ORA-01461: can bind a LONG value only for insert into a LONG column error. I am a fairley new to Apex and my SQL skills are far from expert level. I have 3 groups we will call 'A' 'B' 'C'. 'A' is the best group 'B' is the next best and 'C' is the lowest group. Let say there are 5 people they all want to be in group A but where they are placed is based on their audition score and the users selection.
    Joe score is 50
    Beth 40
    John 30
    Ken 20
    Sally 10
    The user selects that he wants 2 people in group 'A' and 1 in group 'B' and 2 in group C. The SQL needs to rank Joe and Beth in Group A. John in group 'B' and Ken and Sally in group 'C'. The user does this type of selection for about 15 different instrument groups to make up group (band) for 'A', 'B', and 'C'.
    Here is what I have come up with that gives me the error mention above when creating a report but works in SQL developer. There is probably a far better way to write this than what I have. I am open to suggestions. Band 'A' SQL example is for all instruments. SQL's for 'B' and 'C' are just a samples of the whole thing.
    SQL for Band 'A'
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    ( ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Piccolo'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_piccolo from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Flute'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Flute from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Oboe'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Oboe from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'English_Horn'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Englishhorn from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'English_Horn'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Englishhorn from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Clarinet_Eflat'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Clarineteflat from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Clarinet'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Clarinet from festival_years where year = ':P6_YEAR')
    UNION ALL SELECT lname,fname,instrument,total FROM(SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank FROM band_students, festival_records A JOIN festival_records B on a.ID = b.ID where band_students.id = a.ID and a.instrument = 'Clarinet Bass' and a.festival_year = ':P6_YEAR' ORDER BY total, a.ID DESC NULLS LAST) WHERE Stu_Rank <= (select hb_Clarinetbass from festival_years where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Clarinet Contrabass'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Clarinetcontrabass from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Saxophone Alto'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Saxophonealto from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Saxophone Tenor'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Saxophonetenor from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Saxophone Bari'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Saxophonebari from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Bassoon'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Bassoon from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Bassoon Contra'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Bassooncontra from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Horn'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Horn from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Trumpet'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Trumpet from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Trombone'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Trombone from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Trombone Bass'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Trombonebass from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Euphonium'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Trombonebass from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Tuba'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Tuba from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Percussion'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Percussion from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Piano'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Piano from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Violin'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Violin from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Viola'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Viola from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Cello'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Cello from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Bass'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Cello from festival_years
    where year = ':P6_YEAR'
    SQL for band 'B'
    SELECT lname,fname,instrument, total
    FROM
    (SELECT lname, fname, instrument, total, RANK() OVER
    ( ORDER BY instrument,total ASC NULLS LAST) AS Stu_Rank
    FROM festival_records, band_students
    where band_students.id = festival_records.id
    and instrument = 'Piccolo'
    and festival_year = '2014'
    ORDER BY instrument, total ASC NULLS LAST)
    WHERE Stu_Rank < (select hb_piccolo from festival_years
    where year = :P6_YEAR)
    SQL for band 'C'
    SELECT lname,fname,instrument, total
    FROM festival_records, band_students
    where band_students.id = festival_records.student_id
    and instrument = 'Piccolo'
    and festival_year = ':P6_YEAR'
    minus
    SELECT lname,fname,instrument, total
    FROM
    (SELECT lname, fname, instrument, total, RANK() OVER
    ( ORDER BY instrument,total DESC NULLS LAST) AS Stu_Rank
    FROM festival_records, band_students
    where band_students.id = festival_records.student_id
    and instrument = 'Piccolo'
    and festival_year = ':P6_YEAR'
    ORDER BY instrument, total DESC NULLS LAST)
    WHERE Stu_Rank < (select hb_piccolo from festival_years
    where year = ':P6_YEAR')
    SQL

    >
    Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already).
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    You should also always post code wrapped in <tt>\...\</tt> tags.
    I am trying to create a reportWhen asking a question about "reports" it's firstly essential to differentiate between standard and interactive reports. Which is it?
    but get a ORA-01461: can bind a LONG value only for insert into a LONG column error.Where and when do you get this error? When creating the report? Or running it?
    There's also an obvious bug (repeated many times):
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank &lt;= (select hb_piccolo from festival_years
                   where year = ':P6_YEAR')
    ...<tt>':P6_YEAR'</tt> is a literal string, not a bind variable reference. <tt>':P6_YEAR'</tt> seems an unlikely value for <tt>festival_year</tt> and <tt>year</tt> values. It should be:
    and a.festival_year = :P6_YEAR
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank &lt;= (select hb_piccolo from festival_years
                   where year = :P6_YEAR)
    ...or even better:
    and a.festival_year = to_number(:P6_YEAR)
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank &lt;= (select hb_piccolo from festival_years
                   where year = to_number(:P6_YEAR))
    ...if the <tt>festival_year</tt> and <tt>year</tt> columns are of type NUMBER. There's a possibility that this bug is in fact the source of your error...
    Furthermore, this is a long piece of SQL. It may be that APEX can't cope with the length. However it's also very repetitive: we see the same SQL pattern repeated many times and UNIONed together. One way to reduce the length of the query would be to replace some (or all) of those repeating patterns. This will not only make the query more APEX-friendly, but it will probably be more efficient and easier to maintain too.
    I recommend that you Re: 2. How do I ask a question on the forums? that will enable others to have a go at this. Reproducing the app on apex.oracle.com and posting guest developer credentials would also be helpful.

  • Urgent : Performance Issue DELETE , INSERT INTO SELECT, UPDATE

    Hi,
    NEED ASSISTANCE TO OPTIMIZE THE INSERT STATEMENT (insert into select):
    =================================================
    We have a report.
    As per current design following steps are used to populate the custom table whcih is used for reporting purpose:
    1) DELETE all the recods from the custom table XXX_TEMP_REP.
    2) INSERT records in custom table XXX_TEMP_REP (Assume all the records related to type A)
    using
    INSERT..... INTO..... SELECT.....
    statement.
    3) Update records in XXX_TEMP_REP
    using some custom logic for the records populated .
    4) INSERT records in custom table XXX_TEMP_REP (Records related to type B)
    using
    INSERT..... INTO..... SELECT.....
    statement.
    Stats gathered related to Insert statement are:
    Event Wait Information
    SID 460 is waiting on event : db file sequential read
    P1 Text : file#
    P1 Value : 20
    P2 Text : block#
    P2 Value : 435039
    P3 Text : blocks
    P3 Value : 1
    Session Statistics
    redo size : 293.84 M
    parse count (hard) : 34
    parse count (total) : 1217
    user commits : 3
    Transaction and Rollback Information
    Rollback Used : 35.1796875 M
    Rollback Records : 355886
    Rollback Segment Number : 12
    Rollback Segment Name : _SYSSMU12$
    Logical IOs : 1627182
    Physical IOs : 136409
    RBS Startng Extent ID : 14
    Transaction Start Time : 09/29/10 04:22:11
    Transaction_Status : ACTIVE
    Please suggest how this can be optimized.
    Regards,
    Narender

    Hello,
    Is there any relation with the Oracle Forms tool ?
    Francois

  • ORA-01461: can bind a LONG value only for insert into a LONG column ORA-020

    Getting error --
    ORA-01461: can bind a LONG value only for insert into a LONG column ORA-02063: preceding line from APPS
    A page has 3 fields and a Add button
    (1) first field is a LOV "select with submit"
    (2) second field is getting its value from select statement with where clause = ID selected from field1
    (3) field 3 is the value of field1
    In After submit Process , I write simple insert as follows in the
    BEGIn
    INSERT INTO TABLE_NAME (ELEMENT_NAME,ELEMENT_TYPE_ID )
    VALUES (:P3_NAME ,to_number(:P3_ELEMENT_TYPE_ID));
    COMMIT;
    END;
    when i click on Add i get the error above

    try doing the bind locally before executing the remote dml...
    declare
    l_long long := :P3_NAME;
    begin
    insert into table_name (ELEMENT_NAME,ELEMENT_TYPE_ID )
    values (l_long ,to_number(:P3_ELEMENT_TYPE_ID));
    end;
    ...and if that doesn't work, please let us know the definition of you TABLE_NAME table.
    thanks,
    raj

  • Why this Error comes "ORA-01461: can bind a LONG value only for insert into

    I'm using Oracle 9.2 with Weblogic 8 server. After Googling i got to resolve this issue "ORA-01461: can bind a LONG value only for insert into a LONG column" by adding : oracle.jdbc.RetainV9LongBindBehavior=true in server properties for the datasource.
    But why did this error come and after keeping the above property why did this error go away ?
    Can anyone help me on this.....

    You have an error in the code:
    1. you don't provide a value for 'what' - you have to tell Oracle what it should execute when it submits the job.
    And remember - with ISUBMIT the next_date parameter has datatype VARCHAR2 - SUBMIT uses datatype DATE. So make sure you provide a VARCHAR2 value and do not rely on implicit conversion.
    >
    PROCEDURE DBMS_JOB.ISUBMIT
    (job IN BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN VARCHAR2
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);
    PROCEDURE DBMS_JOB.SUBMIT
    (job OUT BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN DATE DEFAULT SYSDATE
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);

  • ORA- 01461 : Can Bind a long value only for insert into a column error

    I was trying to create a new job using dbms_job.isubmit
    begin
    sys.dbms_job.isubmit(job => 1111,
    what => '',
    next_date => to_date('21-10-2011 03:00:00', 'dd-mm-yyyy hh24:mi:ss'),
    interval => 'TRUNC(SYSDATE+1)+3/24');
    commit;
    end;
    However, I am getting the error 'ORA- 01461 : Can Bind a long value only for insert into a column error'.
    I tried a lot but cant get rid of.
    Any help gurus ?

    You have an error in the code:
    1. you don't provide a value for 'what' - you have to tell Oracle what it should execute when it submits the job.
    And remember - with ISUBMIT the next_date parameter has datatype VARCHAR2 - SUBMIT uses datatype DATE. So make sure you provide a VARCHAR2 value and do not rely on implicit conversion.
    >
    PROCEDURE DBMS_JOB.ISUBMIT
    (job IN BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN VARCHAR2
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);
    PROCEDURE DBMS_JOB.SUBMIT
    (job OUT BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN DATE DEFAULT SYSDATE
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);

  • ORA-01461: can bind a LONG value only for insert into a LONG colu

    Hello - I have a variable defined in a package as VARCHAR2(32720). This is not a table column. I am building a string inside the vairable, loading in invoice data in sections one at a time. It seems that once I get a larger number of invoices (say 100+) to load in, I get the "ORA-01461: can bind a LONG value only for insert into a LONG column" error. I am not trying to insert into a table column; just stringing together data in this large variable.
    Why would I be getting this error ? And is there a workaround ? The variable is read back out iin 80 byte strings which are then loaded to a table column that is varchar2(80).
    Thanks !!
    Jim Ernst
    Invacare Corporation

    Here is the definition of the field:
    l_EDI820_Data VARCHAR2(32720);
    And here is the loop used to populate the field. As i mentioned, it seems that once the process gets over 100 invoices coming in that the field hits the error; seems as if we are hitting say 4000 characters or near it at that point...
    FOR r_INVOICE_DETAIL IN cr_INVOICE_DETAILS LOOP
    l_EDI820_Data := l_EDI820_Data
    ||l_RMR_Statement
    ||r_INVOICE_DETAIL.INVOICE_NUM
    ||'*PI*'
    ||LTRIM(TO_CHAR(NVL(r_INVOICE_DETAIL.PAYMENT_AMOUNT,0))) -- Net Amount to be applied
    ||'*'
    ||LTRIM(TO_CHAR(r_INVOICE_DETAIL.INVOICE_AMOUNT,'999999.99')) -- Gross Amount
    ||l_Delimiter;
    l_TOTAL_SEGMENTS := l_TOTAL_SEGMENTS + 1;
    END LOOP; -- r_INVOICE_DETAIL
    There are some other statements that are adding additional data onto l_EDI820_Data ; this one is the loop that is basedon the invoices coming in.
    This code writes it to the table (field EDI820_DATA in the table is VARCHAR2(94)):
    l_EDI820_String_Length := LENGTH(RTRIM(l_EDI820_Data));
    l_EDI820_SUBSTR_START := 1;
    l_RECORD_SEQ_NO := 1;
    WHILE SUBSTR(l_EDI820_Data, l_EDI820_SUBSTR_START, 80) <> ' ' LOOP
    INSERT INTO XXAP_NACHA_EDI820_GTEMP_TBL
    SELECTED_CHECK_ID
    ,EDI820_SEQ
    ,EDI820_DATA
    VALUES (
    r_CHECK_IDS.SELECTED_CHECK_ID
    ,l_RECORD_SEQ_NO
    ,'705'||SUBSTR(l_EDI820_Data, l_EDI820_SUBSTR_START, 80)
    -- * Increment starting point for substring and also record sequence number
    l_EDI820_SUBSTR_START := l_EDI820_SUBSTR_START + 80;
    l_RECORD_SEQ_NO := l_RECORD_SEQ_NO + 1;
    END LOOP; -- WHILE Loop

  • Weird exception in 12c (ORA-01461: can bind a LONG value only for insert into a LONG column)

    I have a Windows app that accesses an Oracle 12c database via ODBC (the driver version is 12.01.00.01).
    I have a table that has a key column named REGION_ID (NVARCHAR2(9)), and about a dozen other columns, three of which are named REGION1, REGION2, and REGION3, all of type NVARCHAR2(40).
    When I try to insert a string into the REGION1 field that's greater than 9 characters (the length of REGION_ID), I get an ORA-01461 error ('Can bind a LONG value only for insert into a LONG column). If I define the length of REGION_ID to be NVARCHAR2(15), then I can add strings to the REGION1 field with a length up to 15 before I get the ORA-01461 exception again. Oddly, if I change the REGION1 column name to REGIONONE, I do not get any errors, and everything works fine. It's almost as if the column name REGION1 is being confused with REGION_ID behind the scenes.
    Any ideas? I’m using SQLBindParameter to bind the columns, and all of the calls succeed. I get the exception when I execute the insert statement. This same code worked for previous versions of Oracle (11g, 10g, and 9i). And if I use an 11g client driver against the 12c server, I do not get the exception.
    Thanks!

    Sorry, I was just now able to install the patch for bug 18232462, and it did indeed solve the issue I described above. Thanks!

  • APEX 4.0.1 ORA-01461: can bind a LONG value only for insert into a LONG col

    Hello,
    I tried to use the "Database Object Dependencies" in the "Utilties"-section to get an idea of what objects are used in a application. But I got the following error:
    ORA-01461: can bind a LONG value only for insert into a LONG column
    The application consists of 100+ pages and uses abt. 10 schemas. I'm using APEX 4.0.1 on a 10.2.0.4 DB.
    Doing this on a small application there are no errors.
    Any hint would be welcome to solve this error.

    Any Thoughts?

  • ORA-01461: can bind a LONG value only for insert into a LONG column - Issue

    We are getting an error from Oracle DB --- Cause: java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
    The application was working fine with Oracle 10.2.0.4 and ojbc14 driver 10.2.0.1 Error occurs only after an upgrade to Oracle 10g 10.2.0.5. So after some googling, we found that a driver upgrade would eliminate this error. So the 10.2.0.5 version of the driver was used. But the ORA error still occurs. The readme of ojdb14.jar specified this - BUG 8847022 - ORA-01461: CAN BIND A LONG VALUE ONLY FOR INSERT INTO A LONG COLUMN
    The problem is that we are not able to reproduce this using a sample program however it is happening consistently in the client environment.
    we get the error ORA-01461, when the oracle version is upgraded to 10.2.0.5. This error occurs when we try to insert a file(BLOB) data with the file length greater than 4KB to a table.
    Exception trace
    uncategorized SQLException for SQL []; SQL state [72000]; error code [1461];
    --- The error occurred in nl/sss/gict/mcb/data/dao/config/StateQueries.xml.
    --- The error occurred while applying a parameter map.
    --- Check the setReceivedFile-InlineParameterMap.
    --- Check the statement (update failed).
    --- Cause: java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
    ; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
    --- The error occurred in nl/sss/gict/mcb/data/dao/config/StateQueries.xml.
    --- The error occurred while applying a parameter map.
    --- Check the setReceivedFile-InlineParameterMap.
    --- Check the statement (update failed).
    --- Cause: java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
    Oracle version installed in acceptance:
    1 Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    2 PL/SQL Release 10.2.0.5.0 - Production
    3 CORE 10.2.0.5.0 Production
    4 TNS for Linux: Version 10.2.0.5.0 - Production
    5 NLSRTL Version 10.2.0.5.0 - Production

    Is the server running Java 1.4? If it is Java 5 or higher there is no need to keep using OJDBC14, you can upgrade to OJDBC5.
    If you cannot do that, then I ask you: why make this post? What are you expecting someone to do? Your problem is with the OJDBC driver, you are not going to get tech support for it in this Java programming forum.

Maybe you are looking for

  • I am unable to scan using the hp office jet pro 8500 wireless all in one printer from an I-MAC

    I have a new I-MAC OS Lion computer and an older HP Officejet Pro 8500 wireless all-in-one printer, scanner, fax, photo.  I cannot scan, though I can print and I can fax.  The error message says I must be connected to the network, and yet I am connec

  • SOAP to RFC Scenario

    Hi, I have a scenario, SOAP to RFC with R/3 as receiver and MDM as sender. From PI side the scenario is working fine, but when the actual data is passed from MDM the data is not getting posted to R/3. Please guide how to test this scenario end to end

  • Getting PDF annotations in ColdFusion

    Currently, I am using coldfusion 9 and I am trying to get information about annotations from within a PDF file.  The problem is that there are two types of annotations: text and popup.  I am using iText and I can get an annotation array that has 7 ob

  • Ipods only last a few years.

    The battery has recently died on both me and my wife's ipod (3rd generation -2004). Just spoken to apple care and thier response was "tough". Has anyone tried to replace the battery themselves? Very annoyed that this apple product obviously has a des

  • Dual Desktop Displays? What do I need?

    I have a 23 inch display hooked to my MacBook Pro. I recently got a second display. What do I need to run dual monitors? How do I hook up the second one?