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
749 Views Asked by TBose At
1
There are 1 best solutions below
Related Questions in PLSQL
- How to send message to syslog agent in plsql
- In PLSQL, How to fetch "User Tables" but not limited to Owner wise only, that have been created under different Schemas of different Users
- How to add the decimal point based on the condition in oracle?
- I am writing the sql query to get the latest supervisor and their job
- How to pass a array object to an oracle stored procedure?
- Difference between an "IS" or "AS" function/procedure declaration PL/SQL
- Best way to create a conditional SQL query? CASE, DECODE, or IF/THEN?
- Can anyone please post working code to send email using sendgrid on Azure databse using PLSQL procedure
- Retrieve record specific date and time in Oracle SQL
- Need to use join result into second cursor in PL/SQL
- ORACLE: Build 'INSERT INTO' statements from 'SELECT *' results
- ORACLE: Build 'INSERT INTO' statements from SELECT * results
- Error in Syntax - Oracle APEX - apex_authorization.is_authorized function
- How to convert CLOB to varchar , and separate them by comma
- Please, my Oracle EBS query when creating a custom report still contains duplicate data,
Related Questions in CURSOR
- How can I make my text visible when my custom curser hovers over it
- Wpf Textbox Cursor on mouse hover
- Change cursor after two clicks using only html and css?
- DB2 - stored procedure - very slow cursor when using IN parameter in fetch first clause
- In React flow, I want to add custom many cursors however, the cursor is not relative to the canvas; it relative to the outer div; how to handle this?
- Setting Debug points for a Chainlit application
- Recharts, how to position the tooltip to the left and top side of the cursor
- Issue with Cursor Movement in Code Selection and Line Start in Terminal-like Environment
- VS Code will backspace or indent-backwards whenever I alt+tab to another program and alt+tab back
- Lock mouse inside window using Python's moderngl_window
- Javascript listener mousemove giving wrong position to custom cursor
- summernote editor - while typing english cursor moves to the top
- Cursor does not appear on initial click in UITextField
- JavaScript zoom to cursor on absolutely positioned element - how to calculate new center coordinates?
- Change WinForm Textbox Cursor-Color
Related Questions in SYS-REFCURSOR
- Unable to get any result set in .NET Core Web API while using Dapper
- How to display REF_CURSOR out Parameter from a procedure -Oracle12C
- Cannot Iterate Dynamically Created SYS_REFCURSOR in Oracle Function
- To handle closing of sysrefcursor returned from a Plsql Stored Procedure
- How to get output of a pl/sql query /Stored procedure in a result set format using oracle sql Developer?
- Efficient Oracle PLSQL stored procedure to return sys_refcursor for similar, but different, SQL statements
- Explicit cursor to SYS_REFCURSOR
- SQLException ORA-00604 and ORA-01003, when calling a procedure with out parameter SYS_REFCURSOR
- Oracle Cursor - Return result and rowcount
- how to take second column if first column not found in table in oracle DB
- how to join cursor returned from procedure with other tables in oracle
- Getting Invalid Identifier error while passing the rowid to a ref cursor for data deletion
- Function retuning Sys Refcursor
- How to output array data from a function in Oralce PL/SQL
- How to get the results of a dynamic created SQL in Oracle SQL
Related Questions in BULK-COLLECT
- Visibility of types inside a procedure (pl/sql)
- Oracle plsql: how lo load json file into nested tables
- [PLSQL]How to know the exact row which raise SAVE EXCEPTION in BULK COLLECT
- Oracle script to create dynamic query based on SQL held in a field
- Bulk collect into multiple columns
- Bulk collection in oracle
- Insert collection data into a table using a procedure (kindly read the question for detailed explanation)
- Difference between bulk collect and cursor
- Using a BULK COLLECT variable in a procedure and referencing it's columns without declaring it all again
- oracle FOR LOOP does not iterate in SYS_REFCURSOR
- Getting ORA-01002:fetch out of sequence error when doing Bulk-collect
- PL/SQL Bulk collect not enough values error
- Return deleted rows in a cursor in PL/SQL
- How to fetch the Rowid with all the columns of a table using bulk collect for a cursor in oracle
- save exceptions is not capturing the complete error description for the ORA-01438
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 # Hahtags
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.