返回多行的 PostgreSQL 函数出现问题

发布于 2024-10-25 06:41:57 字数 7911 浏览 0 评论 0原文

您好,我想从函数返回多行,但我遇到了这个持续存在的错误,任何人都可以帮我,谢谢!

这是错误代码:

    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;

提前致谢!

Hello i want to return a multiple row from a function but i have this persistant error anybody can give me a hand, thanks!!

Here is the error code:

    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')

Here is the function.

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;

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

反话 2024-11-01 06:41:57

无论错误消息显示哪一行,这里都有一个引发错误的简单示例。

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 评论。

Regardless of what line the error message says, here is a simpel example that raises the error.

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

And the output from 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

Your trying to stuff characters into integer like a_horse_with_no_name commented.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文