<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="https://www.sqlines.com/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://www.sqlines.com/feed.php">
        <title>SQLines Tools db2-to-postgresql</title>
        <description></description>
        <link>https://www.sqlines.com/</link>
        <image rdf:resource="https://www.sqlines.com/lib/images/favicon.ico" />
       <dc:date>2026-04-10T06:15:44+00:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://www.sqlines.com/db2-to-postgresql/create_procedure?rev=1671729451&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sqlines.com/db2-to-postgresql/cursor_with_return?rev=1702513231&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sqlines.com/db2-to-postgresql/declare?rev=1621280277&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sqlines.com/db2-to-postgresql/prepared_cursor?rev=1621332310&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sqlines.com/db2-to-postgresql/set?rev=1620987561&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sqlines.com/db2-to-postgresql/values?rev=1663000704&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://www.sqlines.com/lib/images/favicon.ico">
        <title>SQLines Tools</title>
        <link>https://www.sqlines.com/</link>
        <url>https://www.sqlines.com/lib/images/favicon.ico</url>
    </image>
    <item rdf:about="https://www.sqlines.com/db2-to-postgresql/create_procedure?rev=1671729451&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-12-22T17:17:31+00:00</dc:date>
        <title>CREATE PROCEDURE Statement - IBM DB2 to PostgreSQL Migration</title>
        <link>https://www.sqlines.com/db2-to-postgresql/create_procedure?rev=1671729451&amp;do=diff</link>
        <description>SQLines SQL Converter can help you convert IBM DB2 stored procedures to PostgreSQL:

IBM DB2:


  --#SET TERMINATOR /

  CREATE PROCEDURE sp_updateDeptLoc (IN p_loc VARCHAR(25), IN p_deptno CHARACTER(5)) 
  LANGUAGE SQL
  BEGIN 
    UPDATE dept SET location = p_loc WHERE deptno = p_deptno;
  END
  /</description>
    </item>
    <item rdf:about="https://www.sqlines.com/db2-to-postgresql/cursor_with_return?rev=1702513231&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-12-14T00:20:31+00:00</dc:date>
        <title>DECLARE CURSOR WITH RETURN - IBM DB2 to PostgreSQL Migration</title>
        <link>https://www.sqlines.com/db2-to-postgresql/cursor_with_return?rev=1702513231&amp;do=diff</link>
        <description>DB2 allows you to return one or more result sets from a stored procedure. You can declare a cursor specifying WITH RETURN clause that allows you to open the cursor and return its rows to the application, for example:

IBM DB2:


  --#SET TERMINATOR /
  
  CREATE PROCEDURE sp_selectDept(IN p_deptno CHARACTER(5))
  RESULT SETS 1 
  LANGUAGE SQL
  BEGIN
    DECLARE cur CURSOR WITH RETURN FOR 
      SELECT * FROM dept WHERE deptno = p_deptno;
    OPEN cur;
  END
  /</description>
    </item>
    <item rdf:about="https://www.sqlines.com/db2-to-postgresql/declare?rev=1621280277&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2021-05-17T19:37:57+00:00</dc:date>
        <title>DECLARE Statement - IBM DB2 to PostgreSQL Migration</title>
        <link>https://www.sqlines.com/db2-to-postgresql/declare?rev=1621280277&amp;do=diff</link>
        <description>In DB2 the DECLARE statement allows you to declare variables, handlers, exception and cursors in stored procedures. You have to use it inside a BEGIN-END block, for example:

IBM DB2:


  --#SET TERMINATOR /

  CREATE PROCEDURE sp_updateDeptLoc(IN p_loc VARCHAR(25), IN p_deptno CHARACTER(5)) 
  LANGUAGE SQL
  BEGIN
    DECLARE v_loc VARCHAR(25);
    DECLARE v_deptno CHAR(5);
    SET v_loc = p_loc;
    SET v_deptno = p_deptno;
    UPDATE dept SET location = v_loc WHERE deptno = v_deptno;
  END
  …</description>
    </item>
    <item rdf:about="https://www.sqlines.com/db2-to-postgresql/prepared_cursor?rev=1621332310&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2021-05-18T10:05:10+00:00</dc:date>
        <title>Dynamic SQL using Prepared Cursors - IBM DB2 to PostgreSQL Migration</title>
        <link>https://www.sqlines.com/db2-to-postgresql/prepared_cursor?rev=1621332310&amp;do=diff</link>
        <description>In DB2 you can use the prepared statements to dynamically (at runtime) define the SQL query for a cursor, for example:

IBM DB2:


  --#SET TERMINATOR /
  
  CREATE PROCEDURE sp_selectDept(IN p_deptno CHARACTER(5))
  RESULT SETS 1 
  LANGUAGE SQL
  BEGIN
    DECLARE query VARCHAR(50);
    DECLARE cur CURSOR WITH RETURN FOR s1;
    SET query = 'SELECT * FROM dept';  -- or some complex logic to dynamically build SQL here
    PREPARE s1 FROM query;
    OPEN cur;
  END
  /</description>
    </item>
    <item rdf:about="https://www.sqlines.com/db2-to-postgresql/set?rev=1620987561&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2021-05-14T10:19:21+00:00</dc:date>
        <title>SET Statement - IBM DB2 to PostgreSQL Migration</title>
        <link>https://www.sqlines.com/db2-to-postgresql/set?rev=1620987561&amp;do=diff</link>
        <description>In DB2 the SET statement allows you to assign values to variables in stored procedures, functions or triggers, for example:

IBM DB2:


  CREATE PROCEDURE sp_updateDeptLoc(IN p_loc VARCHAR(25), IN p_deptno CHARACTER(5)) 
  LANGUAGE SQL
  BEGIN
    DECLARE v_loc VARCHAR(25);
    DECLARE v_deptno CHAR(5);
    SET v_loc = p_loc;
    SET v_deptno = p_deptno;
    UPDATE dept SET location = v_loc WHERE deptno = v_deptno;
  END
  /</description>
    </item>
    <item rdf:about="https://www.sqlines.com/db2-to-postgresql/values?rev=1663000704&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-09-12T16:38:24+00:00</dc:date>
        <title>VALUES Statement - IBM DB2 to PostgreSQL Migration</title>
        <link>https://www.sqlines.com/db2-to-postgresql/values?rev=1663000704&amp;do=diff</link>
        <description>In DB2 you can use the VALUES statement to return one or more rows with one or more columns. In PostgreSQL you can use multiple SELECT statements with UNION ALL operator.

DB2:


  -- Return 3 rows with 1 column in each row
  VALUES 1, 2, 3;


PostgreSQL:</description>
    </item>
</rdf:RDF>
