I have a requirement where I want to return the deleted records in a sys_refcursor. I can retrieve the data in cursor before the delete statement but is there any way to retrieve them after a delete statement? I mean process will be like at first delete and then open sys_refcursor for fetching deleted records.
Return deleted rows in a cursor in PL/SQL
745 Views Asked by TBose At
1
There are 1 best solutions below
Related Questions in PLSQL
- PLSQL Need REFCURSOR DATE + TIME
- PL SQL After Delete Trigger Not Inserting Record
- Oracle stored procedure wrapping compile error with inline comments
- How to compare multiple columns under same row in a table?
- How to find out which procedures and functions are using a table?
- How to display image in oracle form
- Oracle 11g : staging table
- 04098. "trigger '%s.%s' is invalid and failed re-validation"
- PL/SQL Check if SYSDATE is between two DATETIMES "HH24:mi"
- UTL_file: continue reading even if it encounters blank rows
- add time (char(8)) to date column
- if x not in(select y from table) in oracle
- Generate random ROWID
- Get same day of the same week last year
- Call procedure using anonymous block in pl/sql?
Related Questions in CURSOR
- PLSQL Need REFCURSOR DATE + TIME
- Deleting and Updating values from a cusrsor adapter
- SQLite database query returns only one row
- Which pointer object (i.e., cursor) to use when resetting game.input.onDown
- Using Cursor to Update Of Table in SQL Developer using Spatial Data
- How to travers query results and then call the other Stored Procedure in MySQL Stored Procedure?
- SQL - Adding user defined variables to table (mysql)?
- What code is required to swap a javascript variable (trailimage) to another when clicking within a website
- JavaFX How do you convert coordinates (relative to the screen) to coordinates (relative to a pane)?
- CSS Cursor Event Change
- What is the differece between my codes when I use cursor to fetch my data with repeat and do while?
- Custom cursor not working in IE8
- Custom Cursor using CSS styling - html/css - javascript
- Declare a Cursor From a Table as Variable (In the Select-Statement)
- Node.js + MongoDB : MongoError: cursor killed or timed out
Related Questions in SYS-REFCURSOR
- Return the SQL Statement of an Explicit Cursor
- SQL Developer script output truncates sys_refcursor width
- Dynamic sql with bind variable
- Oracle ref cursor fetch hangs if it contains 1 single record
- writing generic pipelined table PL/SQL function with sys_refcursor as in parameter
- Returning a cursor , calling a procedure from other procedure
- Oracle Other options than SYS_REFCURSOR
- Return deleted rows in a cursor in PL/SQL
- passing sys_refcursor from function to sys_refcursor out parameter in procedure
- CUSOR / SYS_REFCUSOR Problems/ BUG on Oracle 19c
- sys_refcursor from procedure not returning data
- Need to get output as select statement, instead of using dbms_output
- Listview DropDownList FindControl without Edit Button
- EF5 how to access SYS_REFCURSOR in Oracle stored procedure
- Unable to get any result set in .NET Core Web API while using Dapper
Related Questions in BULK-COLLECT
- Insert data from pl/sql table type to another pl/sql table type
- How to store the result of an execute immediate in PLSQL?
- Does bulk collect affect multiple sesssions?
- how dows bulk update flow of execution works
- Return deleted rows in a cursor in PL/SQL
- Fetching a single column with dynamic query
- Oracle plsql: how lo load json file into nested tables
- PL/SQL Bulk collect not enough values error
- Getting ORA-01002:fetch out of sequence error when doing Bulk-collect
- Difference between bulk collect and cursor
- Using a BULK COLLECT variable in a procedure and referencing it's columns without declaring it all again
- usage of LIMIT option in SELECT ... BULK COLLECT INTO
- Oracle dynamic table creation on runtime
- bulk collect into table type of objects
- Skip to next record in a pl sql Cursor with Bulk Collect
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There are probably a few options, but one option would be to use
RETURNINGandBULK COLLECT. Here is a simple example.By creating an object that matches the data we want to keep and a table of that object we can return that into a collection and then easily turn it back into a cursor using the
TABLEfunction.You need to be careful with how many rows you delete as you don't want to run out of memory. I would be cautious with this approach if you delete more than a few hundred rows.
Another suggestion might be to use a GTT, INSERT the rows you plan to delete and then delete from the first table using the GTT as your "key".
This option is maybe better if you are planning to delete a large amount of rows. I used my
ttobject again, but you really don't need it. It just made looping to dump the contents of theSYS_REFCURSOReasier.