Need help in plsql cursor

Hi All,
I need to insert values into a table A of similar structure of other table B.(both havin same no of colums and same type).
Im using a cursor to fetch the values from the table B and in loop im fetching the values from the cursor to the temporary variable of the same type as the table B and im trying to insert values into table A using the following statement
insert into table A values(temp variable);
when i tried executing the procedure it is showing an error "Not enough values".
I not clear whether we can use the insert statement as above or is there any other way to achieve the same.
Please help.
Regards,
Mohan

You can use an INSERCT..SELECT instead of a PL/SQL procedure:
Insert into TableA(col1, col2, col3)
select column1, column2,column3
  from tableB;But if you do need (want) use PL/SQL write it this way:
declare
cursor cb is
select select column1, column2,column3
  from tableB;
begin
  for recB in cb loop
     Insert into TableA(col1, col2, col3)
        values (recB.column1,recB.column2,recB.column3);
  end loop;
end;Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/10/crittografia-in-plsql-utilizzando-dbms_crypto/]

Similar Messages

  • Need help about ref cursor using like table

    Hi Guys...
    I am devloping package function And i need help about cursor
    One of my function return sys_refcursor. And the return cursor need to be
    join another table in database . I don't have to fetch all rows in cursor
    All i need to join ref cursor and another table in sql clause
    like below
    select a.aa , b.cc form ( ref_cursor ) A, table B
    where A.dd = B.dd
    I appeciate it in advance

    My understanding is that you have a function that returns a refcursor and is called by a java app.
    Because this is a commonly used bit of code, you also want to reuse this cursor in other bits of sql and so you want to include it like table in a bit of sql and join that refcursor to other tables.
    It's not as easy as you might hope but you can probably achieve this with pipelined functions.
    Is it a direction that code should be going down? yes, eventually. I like the idea of pulling commonly used bits of code into a SQL statement especially into the WITH section, provided it could be used efficiently by the CBO.
    Is it worth the effort given what you have to do currently to implement it? possibly not.
    what else could you do? construct the sql statement independently of the thing that used it and reuse that sql statement rather than the refcursor it returns?
    Message was edited by:
    dombrooks

  • Need Help: Using Ref Cursor in ProC to call a function within a Package

    I'm calling a function within a package that is returning a REF CURSOR.
    As per the Oracle Pro*C Programmer's Guide, I did the following:
    1) declared my cursor with a: EXEC SQL BEGIN DECLARE SECTION and declared the cursor as: SQL_CURSOR my_cursor;
    2) I allocated the cursor as: EXEC SQL ALLOCATE :my_cursor;
    3) Via a EXEC SQL.....END-EXEC begin block
    I called the package function and assign the return value to my cursor
    e.g. my_cursor := package.function(:host1, :host2);
    Now, the only difference between my code and the example given in the Pro*C Programmer's Guide is that the example calls a PROCEDURE within a package that passes back the REF CURSOR as an OUT host variable.
    Whereas, since I am calling a function, the function ASSIGNS the return REF CURSOR in the return value.
    If I say my_cursor := package.function(:host1, :host2); I get a message stating, "PLS-00201: identifier MY_CURSOR" must be declared"
    If I say :my_cursor := package.function(:host1, :host2); I get a message stating, "ORA-01480: trailing null missing from STR bind value"
    I just want to call a package function and assign the return value to a REF CURSOR variable. There must be a way of doing this. I can do this easily in standard PL/SQL. How can this be done in Pro*C ???
    Thanks for any help.

    Folks, I figured it out. For those who may face this problem in the future you may want to take note for future reference.
    Oracle does not allow you to assign the return value of a REF CURSOR from a FUNCTION ( not Procedure - - there is a difference) directly to a host variable. This is the case even if that host variable is declared a CURSOR variable.
    The trick is as follows: Declare the REF CURSOR within the PL/SQL BEGIN Block, using the TYPE statement, that will contain the call to the package function. On the call, you then assign the return REF CURSOR value that the function is returning to your REF CURSOR variable declared in the DECLARE section of the EXEC SQL .... END-EXEC PL/SQL Block.
    THEN, assign the REF CURSOR variable that was populated from the function call to your HOST cursor varaible. Then fetch this HOST Cursor variable into your Host record structure variable. Then you can deference individual fields as need be within your C or C++ code.
    I hope this will help someone facing a deadline crunch. Happy computing !

  • Ugent: I need help with plsql:

    Some body helps me to do the following updated using plsql:
    I have two tables, xx_firm and xx_contact, related by “firm_seq”; one to many.
    The xx.contact has the following fields:
    cntc_firm_seq
    cntc_title_desc
    cntc_aap_contact
    were firm_seq (from xx_firm) is equal to cntc_firm_seq. Meaning that a firm can have one or many contacts, but one of this contacts must be storage the value “765”.
    I need able to update the field “cntc_title_desc” to 765 only if not of its contacts have that value.
    Thanks,

    there is an error in my sql and hope you may be able to spot it:
    update xx_contact c
    set cntc_title_desc='756'
    where cntc_firm_seq =(select f.firm_seq --was c.firm_seq
    from xx_firm f
    where f.firm_seq = c.cntc_firm_seq
    and c.cntc_title_desc <> '765';

  • Need help getting DataProvider cursor methods to work in JSC

    Hi, I'm a newbie to Creator as well as JSF. I'm using JSC Update 1. I've
    worked through a couple of the beginning tutorials including "Performing
    Inserts, Updates, and Deletes" without a problem. I'm now trying to
    craft a simple jsf database form application on my own using the sample
    travel database and I'm stuck!
    I put text fields on the form corresponding to each of the 4 fields in
    the PERSON table and bound them to the fields in the table which, on
    examination, resulted in a CachedRowSetDataProvider (personDataProvider)
    in Page1 and a CachedRowSetXImpl (personRowSet) in SessionBean1. I then put 4 buttons on the form (First, Previous, Next, Last) for record
    navigation. Here is the code I put in the first two actions (the others are
    the same except for the cursor methods):
    public String btn_firstrec_action() {
    try {
    personDataProvider.cursorFirst();
    } catch (Exception e){
    error("cursorFirst failed: " + e.getMessage());
    log("cursorFirst failed " , e);
    return null;
    public String btn_next_action() {
    try {
    personDataProvider.cursorNext();
    } catch (Exception e){
    error("cursorNext failed: "+ e.getMessage() );
    log("cursorNext failed " , e);
    return null;
    etc.
    When I run the application using the bundled app server I get strange
    behavior when I click the navigation buttons. There are 6 records in the
    table. The application opens up displaying the data for the first
    record. Clicking "Next" takes me to record 2--so far so good. However,
    with repeated clicks on "Next", "Previous", "First" the data displayed in
    the form remains the same. If I click "Last" (personDataProvider.cursorLast(); ), the data from record 6 is rendered OK!
    I worked a little in the debugger. I added a cursorChanging method and
    put a break point in there. Then I watched the index attributes for rk1
    an rk2 as I continued the execution. I had to hit Alt+F5 (Continue)
    2 to 4 times on each button click depending on the action--4X
    with "Next" and "Previous". For each button click the index values would
    change at first to what logically seemed the correct values but
    then snap back to 0 or 1 as I kept continuing depending on the sequence--
    wierd to me.
    I also tried configuring all the form fields in a virtual form with
    "Participate" on for the text fields and "Submit" on for the buttons
    with the same result (I was really "shooting in the dark" here!).
    I'm obviously missing something here--this shouldn't be this difficult!
    I have scanned through a lot of the excellent tutorials, articles and forum posts as well as some of the sample apps but haven't as yet found a similar example of using the DataProvider cursor methods which seems pretty basic to me but, I could have easily missed seeing what I needed.
    Any help would be greatly appreciated--I'm really counting on this tool
    to get an overdue project going so I'm somewhat desperate.
    Thanks, Len Sisson

    This happened to me as well the first time I used the JSC (and I was a newbie in web). I believe it is because everytime you hit the button, actually the sequence of program will back to init(), button_action(), prerender(), destroy(). So, try to remember the last state of the cursor position using session variable. And then you put a code in the init() to move back to the last cursor position.
    Check the sample program provided by JSC (SinglePageCrudForm). This sample demonstrate how to put a code in init(), destroy() in order to 'remember' the last position.
    hope that helps
    Message was edited by:
    discusfish

  • Need help with Ref Cursor

    Dear All,
    Version : '11.2.0.2.0'
    I have a procedure which gets called from a screen ( on .Net) if use pushes a particular button.
    The procedure takes 15 minutes to complete.
    My requirement is to intimate the front end(.Net) as soon as the procedures gets called successfully without waiting for its completion as it is going to take 15 mins.
    The reason being, the front end will popup a message saying that " The process is going to take long time, A mail will be sent to u after its completion"  once it has been intimated that the procedure has been called successfully.
    Could you please suggest can i return a cursor to front end without even manipulating the data.
    i hope my question is understandable.

    9876564 wrote:
    Dear All,
    Version : '11.2.0.2.0'
    I have a procedure which gets called from a screen ( on .Net) if use pushes a particular button.
    The procedure takes 15 minutes to complete.
    My requirement is to intimate the front end(.Net) as soon as the procedures gets called successfully without waiting for its completion as it is going to take 15 mins.
    The reason being, the front end will popup a message saying that " The process is going to take long time, A mail will be sent to u after its completion"  once it has been intimated that the procedure has been called successfully.
    Could you please suggest can i return a cursor to front end without even manipulating the data.
    i hope my question is understandable.
    It seems to me that your problem is not an Oracle one, but a user interface one.
    I'm assuming the slowness of the procedure is due to how long it's taking to query the data, and if you can't speed that up then, to have the procedure return a ref cursor, the connection between the front end and the procedure must be maintained (the process on Oracle must belong to a session, and the front end needs to be connected to that session).
    So, you can't have Oracle go off and start a seperate process and then pass back the ref cursor when it's finished, because even though you can spawn off seperate processes such as using DBMS_JOB or DBMS_SCHEDULER, they will run in their own 'session' and the calling code won't keep a hold on any of those sessions... they're effectively stand-alone and seperate.
    What you'll have to do is likely get your .net application to spawn off a child process to the main app, that presents the message saying it'll take some time, does the call to Oracle and waits for Oracle to return the resultant ref cursor, which it can then pass back to the main application etc.  Due to .net allowing for multi-tasking, that is where the split processing should take place.

  • Need help with OCI8::Cursor object

    I'm using ActiveRecord::Base.connection.execute to run a SQL statement against an Oracle schema that is "external" to my Rails database.
    I'm building the connection on the fly using connection parameters stored in my Rails database (MySQL).
    So far so good...I can create the connection and run the query...I'm getting back an OCI8::Cursor object and that's where I'm stuck.
    I need to display the results of the query in a Rails view.
    New to Ruby and I'm not sure how to proceed.
    Here's what I'm getting back:
    #<OCI8::Cursor:0xb76c679c @stmttype=1, @svc=#<OCISvcCtx:0xb76c6c24>, @env=#<OCIEnv:0xb7765928>, @defns=[nil, #<OCIDefine:0xb76c5d10>, #<OCIDefine:0xb76c5cd4>, #<OCIDefine:0xb76c5c5c>, #<OCIDefine:0xb76c5bf8>, #<OCIDefine:0xb76c5bd0>, #<OCIDefine:0xb76c5ba8>, #<OCIDefine:0xb76c5b80>, #<OCIDefine:0xb76c5b58>, #<OCIDefine:0xb76c5b30>, #<OCIDefine:0xb76c5b08>, #<OCIDefine:0xb76c5ae0>, #<OCIDefine:0xb76c5ab8>, #<OCIDefine:0xb76c5a90>, #<OCIDefine:0xb76c5a68>, #<OCIDefine:0xb76c5a40>, #<OCIDefine:0xb76c5a18>, #<OCIDefine:0xb76c59f0>, #<OCIDefine:0xb76c59c8>, #<OCIDefine:0xb76c59a0>, #<OCIDefine:0xb76c5978>, #<OCIDefine:0xb76c5950>, #<OCIDefine:0xb76c5928>, #<OCIDefine:0xb76c5914>, #<OCIDefine:0xb76c58d8>, #<OCIDefine:0xb76c58b0>, #<OCIDefine:0xb76c5888>, #<OCIDefine:0xb76c5860>, #<OCIDefine:0xb76c5838>, #<OCIDefine:0xb76c5810>, #<OCIDefine:0xb76c57e8>, #<OCIDefine:0xb76c57c0>, #<OCIDefine:0xb76c5798>, #<OCIDefine:0xb76c5770>, #<OCIDefine:0xb76c5748>, #<OCIDefine:0xb76c5720>, #<OCIDefine:0xb76c56f8>, #<OCIDefine:0xb76c56d0>, #<OCIDefine:0xb76c56a8>, #<OCIDefine:0xb76c5680>, #<OCIDefine:0xb76c5658>, #<OCIDefine:0xb76c5630>, #<OCIDefine:0xb76c5608>, #<OCIDefine:0xb76c55e0>, #<OCIDefine:0xb76c55b8>, #<OCIDefine:0xb76c5590>, #<OCIDefine:0xb76c5568>, #<OCIDefine:0xb76c5540>, #<OCIDefine:0xb76c5518>, #<OCIDefine:0xb76c54f0>, #<OCIDefine:0xb76c54c8>, #<OCIDefine:0xb76c54a0>], @binds=nil, @ctx=[32, #<Mutex:0xb76c6c38>, nil, 65535], @parms=[#<OCIParam:0xb76c66c0>, #<OCIParam:0xb76c66ac>, #<OCIParam:0xb76c6698>, #<OCIParam:0xb76c6684>, #<OCIParam:0xb76c6670>, #<OCIParam:0xb76c665c>, #<OCIParam:0xb76c6648>, #<OCIParam:0xb76c6634>, #<OCIParam:0xb76c6620>, #<OCIParam:0xb76c65f8>, #<OCIParam:0xb76c65e4>, #<OCIParam:0xb76c65d0>, #<OCIParam:0xb76c65bc>, #<OCIParam:0xb76c65a8>, #<OCIParam:0xb76c6594>, #<OCIParam:0xb76c6580>, #<OCIParam:0xb76c656c>, #<OCIParam:0xb76c6558>, #<OCIParam:0xb76c6544>, #<OCIParam:0xb76c6530>, #<OCIParam:0xb76c651c>, #<OCIParam:0xb76c6508>, #<OCIParam:0xb76c64f4>, #<OCIParam:0xb76c64e0>, #<OCIParam:0xb76c64cc>, #<OCIParam:0xb76c64b8>, #<OCIParam:0xb76c64a4>, #<OCIParam:0xb76c6490>, #<OCIParam:0xb76c647c>, #<OCIParam:0xb76c6418>, #<OCIParam:0xb76c638c>, #<OCIParam:0xb76c62c4>, #<OCIParam:0xb76c61e8>, #<OCIParam:0xb76c6080>, #<OCIParam:0xb76c6058>, #<OCIParam:0xb76c5fcc>, #<OCIParam:0xb76c5fb8>, #<OCIParam:0xb76c5f68>, #<OCIParam:0xb76c5f54>, #<OCIParam:0xb76c5ea0>, #<OCIParam:0xb76c5e64>, #<OCIParam:0xb76c5e14>, #<OCIParam:0xb76c5e00>, #<OCIParam:0xb76c5dec>, #<OCIParam:0xb76c5dd8>, #<OCIParam:0xb76c5dc4>, #<OCIParam:0xb76c5db0>, #<OCIParam:0xb76c5d9c>, #<OCIParam:0xb76c5d88>, #<OCIParam:0xb76c5d74>, #<OCIParam:0xb76c5d60>], @stmt=#<OCIStmt:0xb76c6760>>
    My problem is that I simply don't have a firm enough grasp on the basics of Ruby to dissect this thing and get at it's innards.
    If someone could drop me a code snippet that shows how to reference the contents of this in my erb file I think I'll be off to the races.

    If you want low level access to Oracle database then you can use ruby-oci8 API directly without using ActiveRecord.
    You can read about ruby-oci8 API at http://ruby-oci8.rubyforge.org/en/api.html
    But if you want to use ActiveRecord then install and use oracle_enhanced adapter, see http://wiki.github.com/rsim/oracle-enhanced
    If you have any questions about oracle_enhanced adapter then probably it is better to ask them in http://groups.google.com/group/oracle-enhanced discussion group.
    It is not recommended approach to establish ActiveRecord connection and then use low level ruby-oci8 API.
    And if you have some problem then please describe exactly what you are doing and what you would like to achive and then also what error do you get.

  • Need help with **** Invalid Cursor State ****

    Hi,
    can someone tell me why am i getting this error....
    //******java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
    Any help is greatly appreciated.....
    Thanks in advance.
    //***********this is the output on servlet side**************//
    Starting service Tomcat-Standalone
    Apache Tomcat/4.0.3
    Starting service Tomcat-Apache
    Apache Tomcat/4.0.3
    init
    DBServlet init: Start
    DataAccessor init: Start
    Accessor init: Loading Database Driver: sun.jdbc.odbc.JdbcOdbcDriver
    DataAccessor init: Getting a connection to - jdbc:odbc:SCANODBC
    username SYSDBA
    password masterkey
    DataAccessor init: Preparing searchPolicy
    DataAccessor init: Prepared policySearch
    DataAccessor init: Prepared ssnSearch
    DataAccessor init: End
    After the myDataAccessor
    Database Connection...
    in doGet(...)
    SSSSSSSGetpolicynumber
    In GetPolicyInformation
    b05015195
    Getting Policy Informaton for = b05015195
    okay, building vector for policy
    in GetPolicyInformation for = b05015195
    starting query... policy Information
    finishing query... Policy Information
    Inside the while(next) loop
    sun.jdbc.odbc.JdbcOdbcResultSet@4db06e
    sun.jdbc.odbc.JdbcOdbcResultSet@4db06e
    b05015195
    policy information constructor with resultset
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
    at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3266)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:
    5398)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:326)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:383)
    at viewscreenappletservlet.policyinformation.<init>(policyinformation.ja
    va:56)
    at viewscreenappletservlet.DatabaseAccessor.getPolicyInformation(Databas
    eAccessor.java:145)
    at viewscreenappletservlet.Servlet.policyDisplay(Servlet.java:108)
    at viewscreenappletservlet.Servlet.doGet(Servlet.java:91)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServl
    et.java:446)
    at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java
    :180)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:193)
    at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:213)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:193)
    at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:213)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:190)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
    torBase.java:475)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
    2343)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:180)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
    rValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
    468)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    ve.java:174)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcesso
    r.java:1012)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.ja
    va:1107)
    at java.lang.Thread.run(Thread.java:484)
    result set closed
    1
    sending response
    Sending policy vector to applet...
    Data transmission complete.

    1) JDBC-ODBC driver is buggy
    2) Some drivers (truly speaking most of them) doesn't
    support cursors or supports them in a wrong way
    Paul

  • Need help with loop cursor

    Hi,
    I'm doing a data conversion and am fairly new to PL/SQL.
    I have a cursor and in the loop i have a select statement
    which returns ORA-01403(no data found). I need to skip this
    row in the cursor and continue with the next.
    BEGIN
    OPEN cur_fill_split;
    LOOP
    FETCH cur_fill_split into S_ASR,S_CLIENT_NO, S_DIRCODE, S_SPLIT_RATE, I_WAYS,
    S_BRANCH_NUMBER, S_BRANCH_NAME, S_DIV_NUMBER, S_DIV_NAME, S_ITEMCODE, S_LINE;
    EXIT WHEN cur_fill_split%NOTFOUND;
    select order_number INTO N_ORDER_NUMBER from order_header
    where cmr_number||client_number||dir_number = s_asr||s_client_no||s_dircode;
    SELECT SEQ INTO I_SEQ FROM ORDER_DETAIL
    WHERE ORDER_NUMBER = N_ORDER_NUMBER
    AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
    ********(errors on the above select)********
    END LOOP;
    CLOSE cur_fill_split;
    END;
    Thanks,
    Brian

    Hi,
    I think there r 2 methods, one is by giving begin - end inside the loop as shown below 1st ex:
    & the 2nd method is by selecting the record count & then based on that value executing further commands.
    I think 2nd method is more safer than the 1st method.
    Method 1:
    1)
    -- ---------------Procedure Begin------------------
    BEGIN
    OPEN cur_fill_split;
    LOOP
    FETCH cur_fill_split into S_ASR,S_CLIENT_NO, S_DIRCODE, S_SPLIT_RATE, I_WAYS,
    S_BRANCH_NUMBER, S_BRANCH_NAME, S_DIV_NUMBER, S_DIV_NAME, S_ITEMCODE, S_LINE;
    EXIT WHEN cur_fill_split%NOTFOUND;
    select order_number INTO N_ORDER_NUMBER from order_header
    where cmr_number||client_number||dir_number = s_asr||s_client_no||s_dircode;
    BEGIN
    SELECT SEQ INTO I_SEQ FROM ORDER_DETAIL
    WHERE ORDER_NUMBER = N_ORDER_NUMBER
    AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    END;
    END LOOP;
    CLOSE cur_fill_split;
    END;
    -- ---------------Procedure End------------------
    Method 2)
    By selecting the record count & based on that records, deciding the program control.
    -- ---------------Procedure Begin------------------
    declare
    rec_cnt number := 0;
    BEGIN
    OPEN cur_fill_split;
    LOOP
    FETCH cur_fill_split into S_ASR,S_CLIENT_NO, S_DIRCODE, S_SPLIT_RATE, I_WAYS,
    S_BRANCH_NUMBER, S_BRANCH_NAME, S_DIV_NUMBER, S_DIV_NAME, S_ITEMCODE, S_LINE;
    EXIT WHEN cur_fill_split%NOTFOUND;
    select order_number INTO N_ORDER_NUMBER from order_header
    where cmr_number||client_number||dir_number = s_asr||s_client_no||s_dircode;
    /* Here we are using cnt variable & checking for
    the record count, if count = 0, then it will skip */
    select count(*) into rec_cnt from ORDER_DETAIL
    WHERE ORDER_NUMBER = N_ORDER_NUMBER
    AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
    if rec_cnt > 0 then
    SELECT SEQ INTO I_SEQ FROM ORDER_DETAIL
    WHERE ORDER_NUMBER = N_ORDER_NUMBER
    AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
    end if;
    END LOOP;
    CLOSE cur_fill_split;
    END;
    -- ---------------Procedure End------------------
    Try it out & mail me
    Good luck

  • Need help in Plsql for Oracle Reports

    Hi i need urgent requirement for this, Kindly guide me. Since i couldnt do.
    Main Table:
    For example: Conside this table: (Card_no, month and year are unique constraint)
    Card_No Name Amount_1 Amount _2 Total Month Year
    1 Justin 50 1000 1050 Jan 2011
    1 Justin 100 500 600 Feb 2011
    2 Charles 50 100 150 Jan 2011
    1 Justin 100 50 150 Jan 2012
    1 Justin 50 1000 1050 Feb 2012
    1 Justin 100 500 600 Mar 2012
    2 Charles 50 100 150 Jan 2012
    1 Justin 100 50 150 Jan 2012
    Now i need Reports like this:
    1. When i select Year as 2012 and select amount1, i need report like this
    Card_No Name Jan Feb Mar Apr May June . . . . Dec Total
    1 Justin 100 50 100 0 0 0 . . . 0 250
    2 Charles 50 0 0 0 0 0 . . . 0 50
    2. If i select many years and select amount1, i need report like this
    Card_No Name Year Jan Feb Mar Apr May June . . . . Dec Total
    1 Justin 2012 100 50 100 0 0 0 . . . 0 250
    1 Justin 2011 50 100 0 0 0 0 0 150
    2 Charles 2012 50 0 0 0 0 0 . . . 0 50
    2 Charles 2011 50 0 0 0 0 0 . . . 0 50
    These are the two requirements
    Kindly guide me and many more suggestion also will be helpful
    Thanks in advance

    Actually you need to use matrix report in you report style to meet your requirement
    however please try below file if you use oracle 10g (I am not much sure as it was checked long time back)
    https://docs.google.com/file/d/0B6k7l8hLvpK2UnJwUDFRR1N5d2s/edit
    Best of luck
    Edited by: AppsLearner on Aug 3, 2012 12:49 AM

  • Urgen I need help with a cursor

    this my cursor, I created it in a button trigger
    DECLARE
    ins_mue_id resultado_v.mue_id%TYPE;
    ins_pru_cod resultado_v.des_pru_codigo%TYPE;
    cursor res_cur IS
    select mue_id, des_pru_codigo from resultado_v where mue_id = :entrar_muestra.mue_mue_id;
    BEGIN
    OPEN res_cur;
    LOOP
    FETCH res_cur INTO ins_mue_id, ins_pru_cod;
    EXIT WHEN res_cur%NOTFOUND;
    INSERT INTO resultados (res_mue_id, res_pru_codigo) values (ins_mue_id, ins_pru_cod);
    commit;
    END LOOP;
    CLOSE res_cur;
    END;
    Something's is wrong because no results were obtained. Please I need yours help

    First of all, I have to correct my previous posting : point 2 was wrong, that type of error can't happen in a cursor, probably I was inattentive :-(
    That said, if the query works correctly in Sql*Plus, then the only difference I can guess is in fields definitions : how are mue_id and :entrar_muestra.mue_mue_id defined ?
    As Frank suggested I'd put a message within the loop to see if and what is read.

  • Need Help Fixing My Cursor!

    My cursor is stuck on the righthand margin...can someone tell me how to get it back on the left and typing appropriate letters?  Thx, R

    Hi,
    Do data will be lost: Pull the battery while the device is on, leave it out for 1 minute.
    replace and let the device reboot 1-3 minutes.
    See if the curser can function,
    Thanks,
    Please remember to resolve your thread. Put the check mark in the green box that contained your answer! Thanks
    Click Accept as Solution for posts that have solved your issue(s)!
    Be sure to click Like! for those who have helped you.
    Install BlackBerry Protect it's a free application designed to help find your lost BlackBerry smartphone, and keep the information on it secure.

  • Need help on simple cursor

    Hi All,
    I am trying to list name of columns based on input table names
    Not sure why below simple code is not working
    Can you please suggest what is wrong?
    SQL>declare
      2  v_list varchar2(200);
      3  cursor c1 (i_table_name varchar2) is
      4  select * from all_tab_columns where
      5  owner='SCOTT' and table_name in i_table_name;
      6  begin
      7  v_list := '(''DEPT'')';
      8  dbms_output.put_line(v_list);
      9  FOR rec in c1(v_list)
    10  loop
    11  dbms_output.put_line(rec.column_name);
    12  end loop;
    13  end;
    14  /
    ('DEPT')
    PL/SQL procedure successfully completed.

    There is a fundamental concept you are missing.
    You define a STRING variable:
    v_list varchar2(200);
    It is NOT a list. It is a single value string variable.
    Then you attempt to use a literal string value as a list:
    select * from all_tab_columns where  owner='SCOTT' and table_name in i_table_name;
    Putting 5 words in to a string does not make it a list:
    v_list varchar2(200) := 'word1,word2,word3,word4,word5';
    A list needs to be defined as an ARRAY type:
    type TStringArray is table of varchar2(30);
    stringList TStringArray;
    An array consists of cells or items. Which means a list of 5 items will be an array of 5 items:
    stringList := new TStringArray( 'word1','word2','word3','word4','word5');
    This is a basic data structure concept in programming. And you need to understand it fully BEFORE writing a single code statement. It is that critical to understand. Programming is all about manipulating data structures. Not commands and statements.

  • Need help creating a cursor effect.

    I'm working on a little project that's like a text-based adventure, but played on a tumblr, so the readers submit their siggestions for actions.
    I'm looking to create animations for each post, so that it looks like the reader is typing in the text on the "game."
    I have the text-generation effect down using this code:
    var myString:String = "text data goes here.";
    var myArray:Array = myString.split("");
    addEventListener(Event.ENTER_FRAME, frameLooper);
    function frameLooper(event:Event):void
              if(myArray.length > 0)
                        tf.appendText(myArray.shift());
              else
                        removeEventListener(Event.ENTER_FRAME, frameLooper);
    //code sporked from Adam Khoury's Flash Typing Text Effect Tutorial video
    So that runs okay, but after that is done, I want there to be a final > prompt followed by a flashing cursor,as if asking for input.
    If anyone has a suggestion, that would be much appreciated.
    Thanks in advance!

    There's not much need to show anymore.  I already provided the code you can try to get a blinking cursor, but also said how it is iffy as far as it actually working. 
    The only difference I would offer for the code I provided earlier based on the image you show would be to add a new line before the ">", as in...
         removeEventListener(Event.ENTER_FRAME, frameLooper);
         tf.appendText("\n>");
         stage.focus = tf;
         tf.setSelection(tf.text.length,tf.text.length);  // in an ideal world this line, in league with the focus line preceding it will add the cursor... it just doesn't always work as advertised... especially for me

  • Need Help on Plsql!

    Hi,
    I am trying to Write a Pl/sql Script for Updating the object Count Status While dropping a user/Schema. i really don't know about the plsql Scripting, i am in learning stage i used below Script
    set serveroutput on;
    declare
    test26 varchar2(100);
    begin
    for test1 in (select count(*) out from dba_objects where owner='TEST08')
    loop
    if test1.out <= 0
    then
    dbms_output.put_line('done');
    elsif test1.out >= 0 then
    select count(*) out into test26 from dba_objects where owner='TEST08';
    dbms_output.put_line(test1.out);
    end if;
    end loop;
    end;
    i am getting the Result(Show Only the Current Count Status), but the Problem is , not Continuously updating the result. i need the result for every 15 seconds it should show the Count status of the Schema i.e 1456 after 15second 1359,1247,1001,997,551,201,55,......
    Please Advice....
    Thanks
    Shan

    You can use dbms_application_info.set_session_longops (from another session in your case as you are monitoring DDL operations which are visible to other sessions).
    Otherwise the long running processes should be "instrumented" to provide progress feedback using dbms_application_info.set_session_longops.
    DECLARE
            rindex    BINARY_INTEGER;
            slno      BINARY_INTEGER;
            totalwork number;
            sofar     number;
            obj       BINARY_INTEGER;
            st date;
            et date;
            chkfreq int := 3; ---- How frequently to poll in seconds
    BEGIN
    rindex := dbms_application_info.set_session_longops_nohint;
    sofar := 0;
    -- totalwork := 5; ---- determine total work that need to be done
    select count(*)
         into totalwork
         from dba_objects
         where owner='TEST08';
    WHILE sofar < totalwork LOOP
        st := sysdate;
        et := st + (1/(24*3600)) * chkfreq;
        while (st <= et) loop
            select sysdate into st from dual;
        end loop;
    --  sofar := sofar + 1;  ---- check how much work has been done
      select totalwork - count(*)
         into sofar
         from dba_objects
         where owner='TEST08';
      dbms_application_info.set_session_longops(rindex, slno,
        'Operation Somthing', obj, 0, sofar, totalwork, 'table', 'tables');
    END LOOP;
    END;
    /The progress can be monitored using yet another session, using v$session_longops.
    select * from v$session_longops where sid = <monitoring sessions SID>;vr,
    Sudhakar B.

Maybe you are looking for

  • Vid card issues I think??

    Good day, I'm having some major issues with my card "I think" When playing MOH Pacific Assault, Battlefield Vietnam, and Doom3 my sys locks up and/or I get major video corruption. I have tried updating all of the drivers forward and backward and no l

  • Problem installing Speech Analysis Module

    I have CS6 and trial of CC which I'm evaluating now. When I installed the French speech module it defaulted to CS6. Is there some way to direct it to install in CC? The same module is specified for both versions. Thanks

  • Library organization

    Hi, I don't understand why the music folder separates tracks according to artist and the featured artist. For example, "Dreamgirls" is split into multiple ablums depending on who the artist and featured artists are for that song. How can I fix this s

  • How to make your movie from a template in AE CS6?

    Hello, Firstly, I'm new to this forum and Adobe After Effects. Hence, please excuse my beginner's language. I recently modified a slideshow template in AE CS6. After doing all the necessary modifications in the template project, I do not know how to

  • N9 error -15:0:0 in Wi-Fi Hotspot

    General system failure Use following error code to contact suport <-15:0:0> What's up?