About cursor

Hi All,
Today we had detailed discussion on cursor.
We had task, query needs to written over 7-8 tables and as a result data set can be 100,000 of rows.
These all records needs to write in flat file.
For example these are the accounting entries for couple of accounts for e.g lets say for 10 accounts.
What we done, designed a cursor which is taking account no as parameter and extracted the details for given account.
write those records in file the close the cursor.
Again opened same cursor for new account and write data in file and close the cursor. Same set operations are done 10 times.
Debate was that, some people was saying that opening of cursor is heavy task. So instead of opening the cursor for each account, fetch all required data in one go and write the result in file.
If we query whole data set means 100,000 records, it can also be a problem.?
Question:-
Is this true Oracle perform heavy task at the time of opening the cursor.
Which one is correct fetch again-2 data for different accounts or whole data set in one go.
We did small POC on it, when we fetched the data in chunks it took 9 seconds but when we fetched whole data set in one go it took 19 seconds.
Still the peoples are saying if it is taking much time it is acceptable but opening of cursor again and again is not acceptable.
Please suggest.....
Thanks
Sandeep

As Sybrand said, a simply soft parse is all that is needed to re-use the same SQL cursor in the Shared Pool.
To put this into context and show just why the concept of cursor-are-heavy is laughable and a total fallacy - how long do you think it takes to open and close a half million cursors? Minutes? Perhaps hours?
Not even close. It takes less than 10 seconds. From a 10.2.0.1 dev database of mine (on a small 2 CPU blade server):
SQL> declare
  2          MAX_LOOP        constant number := 500000;
  3          cursor c is select * from user_objects;
  4          t1      number;
  5          t       number;
  6  begin
  7          t1 := dbms_utility.get_cpu_time; -// returns time in 100th of seconds
  8 
  9          for i in 1..MAX_LOOP
10          loop    --// we simply open and close cursors to determine the impact of this only
11                  open c;
12                  close c;
13          end loop;
14 
15          t := (dbms_utility.get_cpu_time-t1) / 100;
16 
17          dbms_output.put_line( to_char(t)||' secs' );
18          dbms_output.put_line( to_char(t/MAX_LOOP,'990.000000')||' sec/cursor' );
19  end;
20  /
8.68 secs
0.000017 sec/cursor
PL/SQL procedure successfully completed.
SQL> Oracle is designed around and for cursor processing. A cursor is an "+executable SQL program+" - and as a SQL data processing platform, Oracle exists to run cursors fast and in a scalable fashion.
The concept that cursors are somehow "heavy" in Oracle, it utterly and totally flawed.

Similar Messages

  • How to get information about cursor? I had only a reference on it.

    Hello
    How to get information about cursor, that I receive in my procedure as a reference. For example I need to know, a number of columns. I know nothing about this cursor, except the link on it.
    Best Regards, Kostya Proskudin!

    However, I would seriously reconsider what you are trying to achieve.
    It looks like you are trying to write some ultimately generic cursor processor. i.e. pass any cursor and process it in some generic way.
    Good design should include knowledge of what is expected to be passed and that knowledge can be put into the code.
    Generic code is inherently difficult to maintain and debug and will never 100% deal with all possible situations e.g. even if you know the table being queried in the cursor you can't rely on the data dictionary to give you all the returned columns if some of the returned columns of the cursor are computed columns.
    Be careful you aren't writing something that's going to cause problems later.

  • A strange error about cursor and dblink

    My dbms:Oracle8i Enterprise Edition Release 8.1.7.4.0
    I have a stored procedure, which inserts records from a remote database into a local table.
    The 'insert' statement have similar pattern:
    insert into table_a
    select table_b.columns from table_b@dblink
    where table_a.column in (select table_b.column from table_b@dblink);
    commit;
    There are about 100 'insert' statement in my procedure. But there is same error messages at the same
    place when the procedure is run. The error messages:ora-01000:maximum open cursors exceeded,ora-02063:
    preceding line from dblink. I have manually run the 'insert'statements before the error place and after the error place.
    The before and after statements are both OK.
    From google.com, I have learned that 'commit' will clear the implicit cursors from 'insert' statement. So I think
    the problem is ora-02063. Again, keywords 'ora-01000 ora-02063'from google.com, I found 'alter session close
    database link dblink' might solve the problem. I have add the 'alter session' statement after each 'commit' in
    my procedure. Unfortunately, same error happened again at the same place.
    I am puzzled. Would you like to give some advice? Thanks a lot!

    Hello
    Well, the best place to lookup error messages is here....
    http://www.oracle.com/pls/db92/db92.homepage
    It's also where all the rest of the database documentation is. As for this error, too many open cursors, as it suggests, one session has too many open. From the statement you are using to select the data, it seems like you are forming the statements dynamically, is this the case? If so, you're using cursors, and so there's a good chance you aren't closing them.
    HTH

  • Question about cursors in a function and how to return the results

    Hi all,
    Some tech info:
    I'm using Oracle 11G database and APEX 4.0.2.00.06
    I use three cursors in a function. My function is called in an APEX standard report, like this by example:
    SELECT fnc_exp(tab.arg1, tab,arg2) FROM table_exp tab;
    My question is: how can I return the values calculated from my function to a standard APEX report? Before, this function was used like this by Oracle Forms to fetch the cursors in the right table columns:
    open c_a;
    fetch c_a into :loc.arg1;
    close c_a;
    open c_b;
    fetch c_b into :loc.arg2, :loc.arg3, :loc.arg4, :loc.arg5;
    close c_b;
    Thanks for your advices!
    Maybe my solution is not right, if you have better ideas, please suggest :)
    PS: If you need more details, please ask which you need.

    Hi,
    I don't think you can do exactly like that in APEX.
    Go for a pipelined function if you want the value be returned from the function.

  • About  cursor  resource in illustrator CS4 SDK

    How to add cursor resource in CS4 ?
    /** Defines the cursor displyed when the MarkedObjects tool is selected
    and the cursor is over a document. The first 32 bytes define the cursor and
    the next 32 bytes define the mask, the last item is the h and v
    point of the hot spot.
    resource 'CURS' (kMarkedObjectsCursorID, locked, preload) {
    $"80 00 C0 00"
    $"E0 00 F0 00"
    $"C8 00 88 00"
    $"84 88 44 D8"
    $"42 A8 22 88"
    $"27 BE 19 AA"
    $"10 AA 08 A2"
    $"0F BE 00 00",
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00",
    {0, 0}
    who can know its face ?
    if I want to add a especial cursor ,how to edit these number?

    Hi,
    I also had this problem on a Mac and I found the following solution.
    1. I draw my cursor with Resorcerer.
    2. In Resorcerer, I select my CURS resource then I click the Hex button. In the window, I select and copy the column named Hex Data.
    3. I past the result in TextEdit.
    4. I launch a little application I did with AppleScript to convert the text in the good format to b used with XCode and Illustrator CS4
    Here is my little application to convert a text in TextEdit to the gool format.
    Maybe, this will be useful…
    If there is a better solution, I am intersted.
    JLG.

  • Question about Cursor in Reports

    Hello I new in this forum
    I need some help, i've started using Reports and I need to show in a Jsp report the result of a stored Procedure this procedure returns a cursor , so my question is How I can to show this selection (result of the cursor) in the report? ' cause when creating a Report with the wizard or manually the application asks for the selection

    inolau :
    Thanks for the link, it's was very useful.
    Well a have another question I need to display a report but pl/sql sends an error because the sql sentece is dynamic and do not allow to use a record
    example
    type v_record is record (deptos.no_folio%type,deptos.dependencia%type,empleado.name%type);
    type depto_ref is ref cursor return v_record
    create or replace function fnc_depto (idempl in varchar2) return depto_ref
    is
    v_cursor depto_ref;
    v_select varchar2(2000);
    begin
    v_select ='select deptos.no_folio,deptos.dependencia,empleado.name
    from deptos join empleado on (deptos.no_folio=empleados.no_folio)
    where empleados.idempleado in (' || idempl || ' ) ';
    open v_cursor for
    v_select;
    return v_cursor;
    end;
    when I create the function it's good but when you execute it returns an error that says
    PL/SQL: Statement ignored
    PLS-00455: el cursor 'V_CURSORDETALLE' cannot use it in a sentece OPEN of Dynamic SQL
    Do you know some solution for it?
    thanks for your time
    cheers!
    best regards

  • About cursor and thread

    Exception:
    Non-transactional Cursors may not be used in multiple threads; Cursor was created in Thread[http-8888-Processor25,5,main] but used in Thread[http-8888-Processor24,5,main]
    why?
    Is the creation and use only in the same thread?

    What Linda said is correct. You also asked "why". Non-transactional cursors are very prone to self-deadlock, which is when two cursors are open in a single thread and access the same records. To avoid the self-deadlock problem, we allow two non-transactional cursors in the same thread to share locks. This means that a non-transactional is attached to a thread, and can only be used in the thread it was created in. This is a limitation, but is a much smaller problem than the self-deadlock problem would be.
    In general you should open a cursor just before you need it and close it ASAP. If you find that you're sharing cursors between threads, you may want to ask yourself why you're doing that and re-examine your design. With transactions, you can share cursors between threads, but I consider this to be a very advanced and rare use case.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • About cursor close

    Hi
    Here i am not able to close the cursor....
    After commit also not possible....
    Before commit also not possible...
    Plz can u tell me...
    is
    cursor udtp_cursor is
    select * from TIME_SLOT;
    BEGIN
    for udtp_value in udtp_cursor
    loop
    dbms_output.put_line(udtp_value.SLOT_ID);
    -- insert into TEST_TIMESLOT values (udtp_value.SLOT_ID, 'Shankar');
    end loop;
    -- close udtp_cursor;
    commit;
    END;

    You are doing a cursor for loop. The cursor is automatically closed when the loop completes.

  • About cursor in adobe director

    I work in adobe director 11.5 and i want to chage a cursor arrow to another cursor that i create, so i stuck on it because i don't know how to change it and how to create the cursor(what type of cursor file and what program that use to create the cursor). Pls help me - -.

    A Google search for "adobe director cursor" brings up these three hits in first, second and third place:
    cursor
    cursor()
    Creating an animated color cursor cast member
    Do these not contain the information you need?

  • 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

  • A question about the impact of SQL*PLUS SERVEROUTPUT option on v$sql

    Hello everybody,
    SQL> SELECT * FROM v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0  Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL>
    OS : Fedora Core 17 (X86_64) Kernel 3.6.6-1.fc17.x86_64I would like to ask a question about the SQL*Plus SET SERVEROUTPUT ON/OFF option and its impact on queries on views such as v$sql and v$session. Here is the problem
    Actually I define three variables in SQL*Plus in order to store sid, serial# and prev_sql_id columns from v$session in order to be able to use them later, several times in different other queries, while I'm still working in the current session.
    So, here is how I proceed
    SET SERVEROUTPUT ON;  -- I often activate this option as the first line of almost all of my SQL-PL/SQL script files
    SET SQLBLANKLINES ON;
    VARIABLE mysid NUMBER
    VARIABLE myserial# NUMBER;
    VARIABLE saved_sql_id VARCHAR2(13);
    -- So first I store sid and serial# for the current session
    BEGIN
        SELECT sid, serial# INTO :mysid, :myserial#
        FROM v$session
        WHERE audsid = SYS_CONTEXT('UserEnv', 'SessionId');
    END;
    PL/SQL procedure successfully completed.
    -- Just check to see the result
    SQL> SELECT :mysid, :myserial# FROM DUAL;
        :MYSID :MYSERIAL#
           129   1067
    SQL> Now, let's say that I want to run the following query as the last SQL statement run within my current session
    SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;According to Oracle® Database Reference 11g Release 2 (11.2) description for v$session
    http://docs.oracle.com/cd/E11882_01/server.112/e25513/dynviews_3016.htm#REFRN30223]
    the column prev_sql_id includes the sql_id of the last sql statement executed for the given sid and serial# which in the case of my example, it will be the above mentioned SELECT query on the employees table. As a result, right after the SELECT statement on the employees table I run the following
    BEGIN
        SELECT prev_sql_id INTO :saved_sql_id
        FROM v$session
        WHERE sid = :mysid AND serial# = :myserial#;
    END;
    PL/SQL procedure successfully completed.
    SQL> SELECT :saved_sql_id FROM DUAL;
    :SAVED_SQL_ID
    9babjv8yq8ru3
    SQL> Having the value of sql_id, I'm supposed to find all information about cursor(s) for my SELECT statement and also its sql_text value in v$sql. Yet here is what I get when I query v$sql upon the stored sql_id
    SELECT child_number, sql_id, sql_text
    FROM v$sql
    WHERE sql_id = :saved_sql_id;
    CHILD_NUMBER   SQL_ID          SQL_TEXT
    0              9babjv8yq8ru3    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;Therefore instead of
    SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;for the value of sql_text I get the following value
    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES);Which is not of course what I was expecting to find in v$sql for the given sql_id.
    After a bit googling I found the following thread on the OTN forum where it had been suggested (well I think maybe not exactly for the same problem) to turn off SERVEROUTPUT.
    Problem with dbms_xplan.display_cursor
    This was precisely what I did
    SET SERVEROUTPUT OFFafter that I repeated the whole procedure and this time everything worked pretty well as expected. I checked SQL*Plus documentation for SERVEROUTPUT
    and also v$session page, yet I didn't find anything indicating that SERVEROUTPUT should be switched off whenever views such as v$sql, v$session
    are queired. I don't really understand the link in terms of impact that one can have on the other or better to say rather, why there is an impact
    Could anyone kindly make some clarification?
    thanks in advance,
    Regards,
    Dariyoosh

    >
    and also v$session page, yet I didn't find anything indicating that SERVEROUTPUT should be switched off whenever views such as v$sql, v$session
    are queired. I don't really understand the link in terms of impact that one can have on the other or better to say rather, why there is an impact
    Hi Dariyoosh,
    SET SERVEROUTPUT ON has the effect of executing dbms_output.get_lines after each and every statement. Not only related to system view.
    Here below what Tom Kyte is explaining in this page:
    Now, sqlplus sees this functionality and says "hey, would not it be nice for me to dump this buffer to screen for the user?". So, they added the SQLPlus command "set serveroutput on" which does two things
    1) it tells SQLPLUS you would like it <b>to execute dbms_output.get_lines after each and every statement</b>. You would like it to do this network rounding after each call. You would like this extra overhead to take place (think of an install script with hundreds/thousands of statements to be executed -- perhaps, just perhaps you don't want this extra call after every call)
    2) SQLPLUS automatically calls the dbms_output API "enable" to turn on the buffering that happens in the package.Regards.
    Al

  • How to show the 'hand' cursor on thumbnail link?

    Hi
    I'm a novice user, today is the 3rd time I've even worked in Dreamweaver ..I used to use Frontpage 2000 so this a quite a change for me. <:)
    I'm making a simple picture gallery using image thumbnails and wanted the full view images to load in a custom sized windows. I used the 'onclick'  and 'open browser window'  behaviour for each thumbnail and previewed it in IE & Safari. The windows were great, but I noticed the standard arrow pointer appears over the thumbnails even though they are links to full images..so nobody would know they are clickable. : /
    Is there some way in Dreamweaver CS4 to have the cursor change to the 'hand' form to indicated this is a link? I'm guessing it might be something to do with an 'on mouseover' trigger on the thumbnail, but I didn't see anything about cursors.
    Apologies in advance if I did not explain this in the correct terms or if it's a code issue that can't be addressed in Dreamweaver.
    Shelley

    Why not use a null link on the thumbnail to attach the behaviour to? and add the return false.
    <a href="javascript:;"><img src="FW-gradient-slice.jpg" alt="" name="Image1" width="185" height="176" id="Image1" onclick="MM_openBrWindow('FW-gradient-slice.jpg','','width=600,height=600');return false" /></a>
    Select the thumbnail and in the property inspectory, in the link box, type in javascript:; 
    Then apply the Open Browser window to the thumbnail as usual.
    You may want to look at using David's Smart Link Dreamweaver extension - very easy to use and valid:
    http://foundationphp.com/tools/index.php
    You will also need to add the following rule to the stylesheet (or in the head of the document if the style rules are there), to remove the blue border around the images...
    a img {border: none;}
    Nadia
    Adobe Community Expert : Dreamweaver
    Unique CSS Templates | Tutorials | SEO Articles
    http://www.DreamweaverResources.com
    Web Design & Development
    http://www.perrelink.com.au
    http://twitter.com/nadiap

  • What are the names of the cursors and mouse pointers in Win 8?

    I am writing a VBA program that is to work with pointers and cursors. 
    What would be the code to change them, where are they, and what are their names?
    Can I customize/import my own?
    (Forgive me if this is a duplicate.  They first one burped me out...)
    Everything I know I learned from my cat. No matter what the situation is, there is a napp for that.

    Hi
    Emerogork2,
    To develop a VBA program to work with pointers and cursors ,the following links may be helpful.
    About Cursors(This link shows us that we can custom a cursor )
    http://msdn.microsoft.com/en-us/library/windows/desktop/ms648379(v=vs.85).aspx
    Cursor Class(This is about cursor class and there is an example of custom cursor)
    http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor(v=vs.110).aspx
    Cursors.Hand Property(This includes an example of overriding
    Control.OnMouseHover method)
    http://msdn.microsoft.com/en-us/library/system.windows.forms.cursors.hand(v=vs.110).aspx
    Cursor.Position Property(This includes an example of creating a cursor from the current cursor`s handle)
    http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.position(v=vs.110).aspx
    Considering this is a developing issue, it`s recommended to post it in our MSDN Forum .The people there are more experienced in this area.
    MSDN forum
    https://social.msdn.microsoft.com/Forums/en-US/home
    Best regards

  • Cursor and Update rows based on value/date

    SQL Server 2012
    Microsoft SQL Server Management Studio
    11.0.3128.0
    Microsoft Analysis Services Client Tools
    11.0.3128.0
    Microsoft Data Access Components (MDAC)
    6.1.7601.17514
    Microsoft MSXML 3.0 4.0 5.0 6.0 
    Microsoft Internet Explorer
    9.11.9600.16518
    Microsoft .NET Framework
    4.0.30319.18408
    Operating System
    6.1.7601
    The objective of this is to test the Cursor and use it on a production environment after this is fixed. What I would like to do is update rows in a column i duplicated originally called 'HiredDate' from AdventureWorks2012 HumanResources.Employee table. I
    made a duplicate column called 'DateToChange' and would like to change it based on a date I have picked, which returns normally 2 results (i.e. date is '04/07/2003'). The code runs but will not change both dates. It did run however with an error but changed
    only 1 of the 2 rows because it said ['nothing available in next fetch'].
    The code to add the columns and perform the query to get the results I am running this against:
    -- ADD column 'DateToChange'
    ALTER TABLE [HumanResources].[Employee] ADD DateToChange Date NOT NULL;
    -- Copy 'HireDate' data to 'DateToChange'
    UPDATE HumanResources.Employee SET DateToChange = HireDate;
    -- Change 'DateToChange' to NOT NULL
    ALTER TABLE [HumanResources].[Employee] ALTER COLUMN DateToChange Date NOT NULL;
    SELECT BusinessEntityID,HireDate, CONVERT( char(10),[DateToChange],101) AS [Formatted Hire Date]
    FROM HumanResources.Employee
    WHERE [DateToChange] = '04/07/2003';
    Code:
    USE AdventureWorks2012;
    GO
    -- Holds output of the CURSOR
    DECLARE @EmployeeID INT
    DECLARE @HiredDate DATETIME
    DECLARE @HiredModified DATETIME
    DECLARE @ChangeDateTo DATETIME
    --Declare cursor
    -- SCROLL CURSOR ALLOWS "for extra options" to pul multiple records: i.e. PRIOR, ABSOLUTE ##, RELATIVE ##
    DECLARE TestCursor CURSOR SCROLL FOR
    -- SELECT statement of what records going to be used by CURSOR
    -- Assign the query to the cursor.
    SELECT /*HumanResources.Employee.BusinessEntityID, HumanResources.Employee.HireDate,*/ CONVERT( char(10),[DateToChange],101) AS [Formatted Hire Date]
    FROM HumanResources.Employee
    WHERE DateToChange = '01/01/1901'
    /*ORDER BY HireDate DESC*/ FOR UPDATE OF [DateToChange];
    -- Initiate CURSOR and load records
    OPEN TestCursor
    -- Get first row from query
    FETCH NEXT FROM TestCursor
    INTO @HiredModified
    -- Logic to tell the Cursor while "@@FETCH_STATUS" 0 the cursor has successfully fetched the next record.
    WHILE (@@FETCH_STATUS = 0 AND @@CURSOR_ROWS = -1)
    BEGIN
    FETCH NEXT FROM TestCursor
    IF (@HiredModified = '04/07/2003')/*05/18/2006*/
    -- Sets @HiredModifiedDate data to use for the change
    SELECT @ChangeDateTo = '01/01/1901'
    UPDATE HumanResources.Employee
    SET [DateToChange] = @ChangeDateTo --'01/01/1901'
    FROM HumanResources.Employee
    WHERE CURRENT OF TestCursor;
    END
    -- CLOSE CURSOR
    CLOSE TestCursor;
    -- Remove any references held by cursor
    DEALLOCATE TestCursor;
    GO
    This query is run successfully but it does not produce the desired results to change the dates
    04/07/2003 to 01/01/1901.
    I would like the query to essentially be able to run the initial select statement, and then update and iterate through the returned results while replacing the necessary column in each row.
    I am also open to changes or a different design all together. 
    For this query I need:
    1. To narrow the initial set of information
    2. Check if the information returned, in particular a date, is before [i.e. this current month minus 12 months or
    12 months before current month]
    3. Next replace the dates with the needed date
    [Haven't written this out yet but it will need to be done]
    4. After all this is done I will then need to update a column on each row:
    if the 'date' is within 12 months to 12 months from the date checked
    NOTE: I am new to TSQL and have only been doing this for a few days, but I will understand or read up on what is explained if given enough information. Thank you in advance for anyone who may be able to help.

    The first thing you need to do is forget about cursors.  Those are rarely needed.  Instead you need to learn the basics of the tsql language and how to work with data in sets.  For starters, your looping logic is incorrect.  You open
    the cursur and immediately fetch the first row.  You enter the loop and the first thing in the loop does what?  Fetches another row.  That means you have "lost" the values from the first row fetched.  You also do not test the success of
    that fetch but immediately try to use the fetched value.  In addition, your cursor includes the condition "DateToChange = '01/01/1901' " - by extension you only select rows where HireDate is Jan 1 1901.  So the value fetched into @HiredModified will
    never be anything different - it will always be Jan 1 1901.  The IF logic inside your loop will always evaluate to FALSE.  
    But forget all that.  In words, tell us what you are trying to do.  It seems that you intend to add a new column to a table - one that is not null (ultimately) and is set to a particular value based on some criteria.  Since you intend the
    column to be not null, it is simpler to just add the column as not null with a default.  Because you are adding the column, the assumption is that you need to set the appropriate value for EVERY row in the table so the actual default value can be anything.
     Given the bogosity of the 1/1/1901 value, why not use this as your default and then set the column based on the Hiredate afterwards.  Simply follow the alter table statement with an update statement.  I don't really understand what your logic
    or goal is, but perhaps that will come with a better description.  In short: 
    alter table xxx add DateToChange date default '19010101'
    update xxx set DateToChange = HireDate where [some unclear condition]
    Lastly, you should consider wrapping everything you do in a transaction so that you recover from any errors.  In a production system, you should consider making a backup immediately before you do anything - strongly consider and have a good reason not
    to do so if that is your choice (and have a recovery plan just in case). 

  • Cursor for loop in PlSql

    while i was studying about cursor for loop i found this statement in the web
    "A cursor FOR loop implicitly declares its loop index as a %ROWTYPE record"
    for example an emp table contain following columns empno,ename,sal,hiredate,deptno
    and let us consider an cursor for loop as
    for rec in select empno,sal from emp loop
    if cursor for loop declare loop index as a %rowtype our cursor statement should include all the columns and follow the data type compatabulity.
    But here our cursor statement includes only few columns,if we use %rowtype we have to select all columns but here we are not doing this.
    Can anyone please explain what is happening in cursor for loop?

    for loop cursor is also like the simple explicite cursor..
    the cursor variable will hold only the columns that are given in select statement of the cursor..
    if u declare a cursor as %rowtype, then it should include all the columns of that particular table..
    otherwise u should use only %type for each and every column seperately only...

Maybe you are looking for

  • Can i use multiple AppleID's with one iCloud Account

    Our family stores our purchases in one huge library.  We each log into our accounts separately (e.g. someone uses an iTunes gift card, someone else uses a credit card, etc.) to purchase music.  Each of us can include other's purchases in our play lis

  • Help required to understand interactive SWF appearance on various browsers and pc's

    I have created an interactive newsletter for global distribution. My work machine uses a resolution of 1280 x 1024 However, my company uses different browsers and laptops globally, as we have approx 150,000 employees. The Indesign pages are 1000 x 80

  • Music Videos won't load

    I have tried several times to get the music videos in my music video playlist to load onto my iPod, but it's not working. The videos look like they're in the right format and I think I have the right settings in iTunes. Thanks!

  • Automatically add Date events from Microsoft Word,MS Outlook to ical?

    Hi Was wondering if theres anyway(native or software) for outlook,word or ical to automatically scan and add date events from docs,mail to ical so that i can sync it to my iphone

  • Directory Admin no longer authenticates---HELP

    I used to be able to authenticate with the directory server, now it keeps saying "The login information is not valid for this server. The server failed accept the login information you provided. Check the Name and Password and try to log in again or