PostgreSQL函数返回多行的问题

时间:2011-03-24 04:13:42

标签: postgresql plpgsql rowtype

你好我想从一个函数返回一个多行,但我有这个持久性错误,任何人都可以帮我一把,谢谢!!

以下是错误代码:

    ERROR:  invalid input syntax for integer: "<html><HEAD id='header' father='*html'>
        <title id="ttl" father="*head">KarinApp(Karina Application Web Maker)</title>
                <link id="favIcon" href="http://www.karinapp.com/favicon.ico" rel="SHORTCUT ICON" />
            <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" />
        <link id="general_css" father="*head" rel="stylesheet" type="text/css" href="http://www.karinapp.com/modules/appgen/css/main.css" />
        <script id='SCRIPT1' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/jQuery.js" father="*head"><!--empty--></script>
        <script id='SCRIPT2' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.core.js"><!--empty--></script>
        <script id='SCRIPT3' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.widget.js"><!--empty--></script>
        <script id='SCRIPT4' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.mouse.js"><!--empty--></script>
        <script id='SCRIPT5' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.draggable.js"><!--empty--></script> 
        <script id='SCRIPT6' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.droppable.js"><!--empty--></script>
        <script id='SCRIPT8' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.position.js"><!--empty--></script>
        <script id='SCRIPT9' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.resizable.js">\n<!--empty--></script>
        <script id='SCRIPT10' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.dialog.js"><!--empty--></script>
        <script id='SCRIPT12' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.button.js"><!--empty--></script>
        <script id='SCRIPT12' type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/ui/jquery.ui.autocomplete.js"><!--empty--></script>
        <script id='SCRIPT13' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/general.js"><!--empty--></script>
        <script id='SCRIPT14' type="text/javascript" father="*head" src="http://www.karinapp.com/modules/general/scripts/Catcher.js"><!--empty--></script>
        <script id='SCRIPT15' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/loadPage.js"><!--empty--></script>
 <SCRIPT id="accordionScr" father="*head"  type="text/javascript"          src="/modules/general/scripts/ui/jquery.ui.accordion.js"><!--empty--></SCRIPT>       
<script id='SCRIPT16' language="javascript" type="text/javascript" src="http://www.karinapp.com/modules/general/scripts/editor/edit_area_full.js"><!--empty--></script>
        <script id='SCRIPT17' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/appgen/scripts/main.js"><!--empty--></script>
        <script id='SCRIPT18' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/appgen/scripts/config.js"><!--empty--></script>
        <script id='SCRIPT19' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/appgen/scripts/style.js"><!--empty--></script>
                <script id='HandleScr' father="*head" type="text/javascript" src="/modules/appgen/scripts/handle.js"><!--empty--></script>
        <script id='SCRIPT20' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/appgen/scripts/scripts.js"><!--empty--></script>
        <script id='SCRIPT21' father="*head" type="text/javascript" src="http://www.karinapp.com/modules/appgen/scripts/properties.js"><!--empty--></script>

        <script id='SCRIPT22' type="text/javascript">
            window.onload = function(){
                postLoad();
            }
                        function __init__(){
                                 main();
                        }
        </script>
<SCRIPT father='*head' id="batuteJS" type="text/javascript" src="/modules/appgen/scripts/batute.js"><!--empty--></SCRIPT>
        </HEAD>
<BODY id="general_bod">
<DIV id="body" father="*html"><!--empty--></DIV>
                                <DIV id="confPg" father="*body">
                <LABEL id="radio0_lab" father="confPg">
                    <INPUT type="radio" id="radio0" father="radio0_lab" name="cnfpg" value="save"/>Modificar pagina</LABEL><BR/>
                <LABEL id="radio1_lab" father="confPg">
                    <INPUT type="radio" id="radio1" father="radio1_lab" name="cnfpg" value="add2pg"/>Salvar pagina como</LABEL>
            </DIV></BODY></html>"
CONTEXT:  PL/pgSQL function "mdlreg" line 66 at SQL statement
In statement:
SELECT * FROM mdlreg('appgen', 'karinapp.com', 'dev', '186.120.130.244')

这是功能。

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;

提前致谢!

1 个答案:

答案 0 :(得分:1)

无论错误消息表示哪一行,这里都是一个简单的例子,会引发错误。

CREATE TABLE issue_9000(f INTEGER);
INSERT INTO issue_9000 (f)
SELECT 'ABCDEFG';

PGADMIN的输出

ERROR:  invalid input syntax for integer: "ABCDEFG"
LINE 2: SELECT 'ABCDEFG';
               ^

********** Error **********

ERROR: invalid input syntax for integer: "ABCDEFG"
SQL state: 22P02
Character: 35

您尝试将字符填充为整数,例如a_horse_with_no_name注释。