title: Problem with a PostgreSQL function that return multiple rows
body: <p>Hello i want to return a multiple row from a function but i have this persistant error anybody can give me a hand, thanks!!</p>
  
  <p>Here is the error code:</p>
  
  <pre><code>    ERROR:  invalid input syntax for integer: "&lt;html&gt;&lt;HEAD id='header' father='*html'&gt;
          &lt;title id="ttl" father="*head"&gt;KarinApp(Karina Application Web Maker)&lt;/title&gt;
                  &lt;link id="favIcon" href="http://www.karinapp.com/favicon.ico" rel="SHORTCUT ICON" /&gt;
              &lt;link id="jQueryUI" type="text/css" href="http://www.karinapp.com/modules/general/css/karinapp-style/jquery-ui-1.8.4.custom.css" rel="stylesheet" /&gt;
          &lt;link id="general_css" father="*head" rel="stylesheet" type="text/css" href="http://www.karinapp.com/modules/appgen/css/main.css" /&gt;
          &lt;script id='SCRIPT1' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/jQuery.js" father="*head"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT2' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.core.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT3' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.widget.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT4' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.mouse.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT5' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.draggable.js"&gt;&lt;!--empty--&gt;&lt;/script&gt; 
          &lt;script id='SCRIPT6' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.droppable.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT8' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.position.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT9' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.resizable.js"&gt;\n&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT10' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.dialog.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT12' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.button.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT12' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.autocomplete.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT13' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/general.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT14' type="text/javascript" father="*head" src="http://www.karinapp.com/modules/general/scripts/Catcher.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT15' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/loadPage.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
   &lt;SCRIPT id="accordionScr" father="*head"  type="text/javascript"          src="/modules/general/scripts/ui/jquery.ui.accordion.js"&gt;&lt;!--empty--&gt;&lt;/SCRIPT&gt;       
  &lt;script id='SCRIPT16' language="javascript" type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/editor/edit_area_full.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT17' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/appgen/scripts/main.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT18' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/appgen/scripts/config.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT19' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/appgen/scripts/style.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
                  &lt;script id='HandleScr' father="*head" type="text/javascript" src="/modules/appgen/scripts/handle.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT20' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/appgen/scripts/scripts.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
          &lt;script id='SCRIPT21' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/appgen/scripts/properties.js"&gt;&lt;!--empty--&gt;&lt;/script&gt;
  
          &lt;script id='SCRIPT22' type="text/javascript"&gt;
              window.onload = function(){
                  postLoad();
              }
                          function __init__(){
                                   main();
                          }
          &lt;/script&gt;
  &lt;SCRIPT father='*head' id="batuteJS" type="text/javascript" src="/modules/appgen/scripts/batute.js"&gt;&lt;!--empty--&gt;&lt;/SCRIPT&gt;
          &lt;/HEAD&gt;
  &lt;BODY id="general_bod"&gt;
  &lt;DIV id="body" father="*html"&gt;&lt;!--empty--&gt;&lt;/DIV&gt;
                                  &lt;DIV id="confPg" father="*body"&gt;
                  &lt;LABEL id="radio0_lab" father="confPg"&gt;
                      &lt;INPUT type="radio" id="radio0" father="radio0_lab" name="cnfpg" value="save"/&gt;Modificar pagina&lt;/LABEL&gt;&lt;BR/&gt;
                  &lt;LABEL id="radio1_lab" father="confPg"&gt;
                      &lt;INPUT type="radio" id="radio1" father="radio1_lab" name="cnfpg" value="add2pg"/&gt;Salvar pagina como&lt;/LABEL&gt;
              &lt;/DIV&gt;&lt;/BODY&gt;&lt;/html&gt;"
  CONTEXT:  PL/pgSQL function "mdlreg" line 66 at SQL statement
  In statement:
  SELECT * FROM mdlreg('appgen', 'karinapp.com', 'dev', '186.120.130.244')
  </code></pre>
  
  <p>Here is the function.</p>
  
  <pre><code>DECLARE regmoment TIMESTAMP;
  DECLARE mdlid bigint;
  
  DECLARE regid visitsmdl_reg%ROWTYPE;
  DECLARE mdlcode pages_reg%ROWTYPE;
  DECLARE mdNm modules_reg%ROWTYPE;
  
  
  BEGIN
  regmoment = CURRENT_TIMESTAMP;
  
  SELECT modules_reg.id INTO mdlid 
  FROM domain_reg, sbdomain_reg, 
  modules_reg, sbdomdl_asc
  WHERE(modules_reg.mdname = $1 AND 
  sbdomdl_asc.module = modules_reg.id AND 
  sbdomdl_asc.domain = sbdomain_reg.id AND 
  sbdomain_reg.domain = domain_reg.id AND
  domain_reg.dname = $2 AND 
  sbdomain_reg.sbname = $3);
  
  IF mdlid IS NULL  THEN
      SELECT modules_reg.id INTO mdlid 
      FROM domain_reg, sbdomain_reg, 
      modules_reg, sbdomdl_asc
      WHERE(modules_reg.indexmdl = 't' AND 
      sbdomdl_asc.module = modules_reg.id AND 
      sbdomdl_asc.domain = sbdomain_reg.id AND 
      sbdomain_reg.domain = domain_reg.id AND
      domain_reg.dname = $2 AND 
      sbdomain_reg.sbname = $3);
      IF mdlid IS NULL OR mdlname != 'index' THEN
            INSERT INTO visitsmdl_reg (module, regtime, machaddr) VALUES(3, regmoment, $4);
  
            SELECT visitsmdl_reg.id, pages_reg.code
            INTO regid, mdlcode
            FROM modules_reg, visitsmdl_reg, pages_reg 
            WHERE(visitsmdl_reg.regtime = regmoment
            AND modules_reg.id = 3
            AND modules_reg.id = pages_reg.mdl);
  
            RETURN (regid || mdlcode);
  
      ELSE
      INSERT INTO visitsmdl_reg (module, regtime, machaddr) VALUES(mdlid, regmoment, $4);
  
      SELECT visitsmdl_reg.id, pages_reg.code,  modules_reg.mdname
      INTO regid, mdlcode, mdNm
      FROM modules_reg, visitsmdl_reg, pages_reg 
          WHERE(visitsmdl_reg.regtime = regmoment
      AND visitsmdl_reg.module = mdlid 
          AND modules_reg.id = mdlid
          AND pages_reg.mdl = mdlid);
  
  
      RETURN (regid || mdlcode || mdNm);
  
      END IF;
  
  ELSE
  
  
  INSERT INTO visitsmdl_reg (module, regtime, machaddr) VALUES(mdlid, regmoment, $4);
  
  
  SELECT visitsmdl_reg.id, pages_reg.code
  INTO regid, mdlcode
  FROM modules_reg, visitsmdl_reg, pages_reg WHERE(visitsmdl_reg.regtime = regmoment 
  AND visitsmdl_reg.module = modules_reg.id AND modules_reg.mdname = $1
  AND modules_reg.id = pages_reg.mdl);
  
  
  RETURN (regid || mdlcode);
  
  END IF;
  END;
  </code></pre>
  
  <p>Thanks in advance!</p>