---
title: "How to retrieve data from object tables on Oracle?"  
description: "How to retrieve data from object tables on Oracle?"  
author: "Sandra Emily"  
published: 2023-08-22  
updated: 2023-08-23  
canonical: https://www.mindstick.com/forum/159649/how-to-retrieve-data-from-object-tables-on-oracle  
category: "database"  
tags: ["database table", "oracle"]  
reading_time: 2 minutes  

---

# How to retrieve data from object tables on Oracle?

How to [retrieve data](https://www.mindstick.com/forum/160347/how-do-you-retrieve-data-from-a-nosql-database-like-mongodb) from object [tables](https://www.mindstick.com/articles/336597/introduction-of-html-tables-for-web-development) on [Oracle](https://www.mindstick.com/articles/13016/alter-table-statement-or-command-in-oracle)?

## Replies

### Reply by Aryan Kumar

There are two ways to [retrieve](https://www.mindstick.com/forum/34400/how-to-retrieve-form-values-in-controller-action) [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) from objects on Oracle:

1. **Using a cursor**

A cursor is a temporary work area that is used to store data retrieved from a database. To retrieve data from an object using a cursor, you can use the following steps:

```plaintext
1. Create a cursor variable and initialize it to the name of the object you want to retrieve data from.
2. Open the cursor.
3. Fetch the data from the cursor one row at a time.
4. Close the cursor.
```

Here is an example of how to retrieve data from an object using a cursor:

SQL

```plaintext
DECLARE
  cursor_name VARCHAR2(30);
  v_data VARCHAR2(255);
BEGIN
  cursor_name := 'my_object';

  OPEN cursor_name;

  LOOP
    FETCH cursor_name INTO v_data;
    EXIT WHEN cursor_name%NOTFOUND;

    dbms_output.put_line(v_data);
  END LOOP;

  CLOSE cursor_name;
END;
```

This code will first declare a cursor variable named `cursor_name` and initialize it to the name of the object you want to retrieve data from. It will then open the cursor and fetch the data from the cursor one row at a time. Finally, it will close the cursor.

1. **Using a PL/SQL function**

A PL/SQL function is a block of code that can be used to perform a specific task. To retrieve data from an object using a PL/SQL function, you can use the following steps:

```plaintext
1. Create a PL/SQL function that returns the data you want to retrieve.
2. Call the function from your application.
```

Here is an example of a PL/SQL function that can be used to retrieve data from an object:

SQL

```plaintext
CREATE OR REPLACE FUNCTION get_object_data(object_name VARCHAR2)
RETURN VARCHAR2
AS
  v_data VARCHAR2(255);
BEGIN
  SELECT data
  INTO v_data
  FROM my_object
  WHERE object_name = :object_name;

  RETURN v_data;
END;
```

This function will return the data associated with the object name passed to it as a parameter.


---

Original Source: https://www.mindstick.com/forum/159649/how-to-retrieve-data-from-object-tables-on-oracle

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
