db2_next_result

(PECL ibm_db2 >= 1.0.0)

db2_next_result Requests the next result set from a stored procedure

Beschreibung

db2_next_result(resource $stmt): resource

A stored procedure can return zero or more result sets. While you handle the first result set in exactly the same way you would handle the results returned by a simple SELECT statement, to fetch the second and subsequent result sets from a stored procedure you must call the db2_next_result() function and return the result to a uniquely named PHP variable.

Parameter-Liste

stmt

A prepared statement returned from db2_exec() or db2_execute().

Rückgabewerte

Returns a new statement resource containing the next result set if the stored procedure returned another result set. Returns false if the stored procedure did not return another result set.

Beispiele

Beispiel #1 Calling a stored procedure that returns multiple result sets

In the following example, we call a stored procedure that returns three result sets. The first result set is fetched directly from the same statement resource on which we invoked the CALL statement, while the second and third result sets are fetched from statement resources returned from our calls to the db2_next_result() function.

<?php
$conn 
db2_connect($database$user$password);

if (
$conn) {
  
$stmt db2_exec($conn'CALL multiResults()');

  print 
"Fetching first result set\n";
  while (
$row db2_fetch_array($stmt)) {
    
var_dump($row);
  }

  print 
"\nFetching second result set\n";
  
$res db2_next_result($stmt);
  if (
$res) {
    while (
$row db2_fetch_array($res)) {
      
var_dump($row);
    }
  }

  print 
"\nFetching third result set\n";
  
$res2 db2_next_result($stmt);
  if (
$res2) {
    while (
$row db2_fetch_array($res2)) {
      
var_dump($row);
    }
  }

  
db2_close($conn);
}
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

Fetching first result set
array(2) {
  [0]=>
  string(16) "Bubbles         "
  [1]=>
  int(3)
}
array(2) {
  [0]=>
  string(16) "Gizmo           "
  [1]=>
  int(4)
}

Fetching second result set
array(4) {
  [0]=>
  string(16) "Sweater         "
  [1]=>
  int(6)
  [2]=>
  string(5) "llama"
  [3]=>
  string(6) "150.00"
}
array(4) {
  [0]=>
  string(16) "Smarty          "
  [1]=>
  int(2)
  [2]=>
  string(5) "horse"
  [3]=>
  string(6) "350.00"
}

Fetching third result set
array(1) {
  [0]=>
  string(16) "Bubbles         "
}
array(1) {
  [0]=>
  string(16) "Gizmo           "
}

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Seltsames Verhalten von execute() oder Fehler meinerseits

Hello You can check below steps - Check for errors after executing the statement. Bind parameters to placeholders in the SQL query. Confirm t ...

Geschrieben von nolanmaris am 20.05.2024 12:12:16
Forum: SQL / Datenbanken
Ein Problem mit der Lampe

Yes ..i was facing the same issue .

Geschrieben von nolanmaris am 20.05.2024 12:02:55
Forum: Off-Topic Diskussionen
Hello

Hello , I am new member here. I have around 8years of experience in developing User Interfaces for Mobile/Tablet/Desktop using HTML, CSS, JavaScri ...

Geschrieben von nolanmaris am 20.05.2024 12:01:22
Forum: User stellen sich vor
Daten einer Abfrage mit Hilfe von Thumbnails nebeneinander ausgeben

Warum soll ich float meiden? Siehe https://www.linkedin.com/pulse/css-float-vs-grid-flexbox-sachin-tiwari Falls es mit Englisch nicht so klappt: ...

Geschrieben von scatello am 18.05.2024 05:57:56
Forum: PHP Developer Forum