postgres函数SELECT INTO

时间:2019-07-05 17:13:35

标签: postgresql function

SELECT u.email, u.id
INTO useremail1, userid1
FROM users AS u
WHERE u.mobilestatus='1'
    AND u.emailstaus='1'
    AND u.user_from='2'

显示错误

  

错误:“,”或附近的语法错误,第8行:选择INTO   u.email,u.id useremail1,userid1来自...

**********错误**********

错误:“,”或附近的语法错误 SQL状态:42601

CREATE OR REPLACE FUNCTION public.caluserapp()
RETURNS TABLE( userid1 integer
             , useremail1 character varying
             , usermobile1 integer
             , userfrom1 integer
             , mobilestatus1 integer
             , emailstatus1 character varying
             , nocid1 character varying
             , nocuniqueid1 character varying
             , noctype1 integer
             )
AS $$
DECLARE
    i         integer;
    distrow   text;
    resultout text;
BEGIN
    FOR distrow IN
        SELECT u.email
             , u.id
        INTO useremail1, userid1
        FROM users AS u
        WHERE u.mobilestatus='1'
            AND u.emailstaus='1'
            AND u.user_from='2'
    LOOP 
        resultout:=(select email from officers where id=id );
        i := i + 1;
    END LOOP;
  END;
$$ LANGUAGE plpgsql;

0 个答案:

没有答案