How can the PHP function ora_fetch be properly used in conjunction with ora_exec when fetching data from an Oracle database?

When using the PHP function ora_exec to execute a query on an Oracle database, the ora_fetch function can be used to fetch the results row by row. It is important to use ora_fetch in a loop until all rows are fetched. Each call to ora_fetch will return the next row of data.

// Execute a query using ora_exec
$stmt = ora_exec($conn, "SELECT * FROM table_name");

// Fetch and process results row by row using ora_fetch
while (ora_fetch($stmt)) {
    $data = ora_getcolumn($stmt, 1); // Assuming column index 1
    // Process the fetched data here
}