Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMw6V-0002JD-Qe for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Nov 2018 14:25:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gMw6T-0002XS-1C for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Nov 2018 14:25:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMvq7-0006G8-RR for pgsql-bugs@lists.postgresql.org; Wed, 14 Nov 2018 14:08:20 +0000 Received: from bosmailout06.eigbox.net ([66.96.189.6]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMvq3-0001n1-SO for pgsql-bugs@lists.postgresql.org; Wed, 14 Nov 2018 14:08:19 +0000 Received: from bosmailscan02.eigbox.net ([10.20.15.2]) by bosmailout06.eigbox.net with esmtp (Exim) id 1gMvq1-0001m7-B6 for pgsql-bugs@lists.postgresql.org; Wed, 14 Nov 2018 09:08:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=savitr.com; s=dkim; h=Sender:Content-Type:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=x2SuoG16izf+jTThiC9l/aKiwBg9dZc/OIpvY1KmQfI=; b=CQD0COL06lH/GrL8ZGJ0666YL2 9jk0l4ImT93ODjwEpU/bIYrV4jEK/Pog4Fb7mG2xyk8ga5X/vAzjYwDkHrHxkA9hLzQsF9PPlfaXd NkSwjcmV2zvzqHHc3E3oEMPyA66ecrCngZJ7DinzIXEztHXvf9sYtR2NLBTfOBIbiawl8CegcMqrR 8La/y1CaYXQd/Ot/KMQLttKbAo1PniB0VNVeHPNN38VstneE2XRvpUc7pvxaNrXKsNkGW+6MmEv9N 0kaYAje/fYW6qsJa/hrXRDlBWaJys5CViYomEho0E8FRWKXY3BOyodqwvaFZn5PHXfWCYirgPQ+NL Gdvh98yg==; Received: from [10.115.3.31] (helo=bosimpout11) by bosmailscan02.eigbox.net with esmtp (Exim) id 1gMvq1-00010b-82 for pgsql-bugs@lists.postgresql.org; Wed, 14 Nov 2018 09:08:13 -0500 Received: from bosauthsmtp05.yourhostingaccount.com ([10.20.18.5]) by bosimpout11 with id zq891y00e06Zqne01q8CfD; Wed, 14 Nov 2018 09:08:13 -0500 X-Authority-Analysis: v=2.2 cv=PN5/wbiC c=1 sm=1 tr=0 a=eBvjjtMVdWwtQGedh7GyLg==:117 a=QaKC5jHk6XKL7nT7bQKkrw==:17 a=JHtHm7312UAA:10 a=Dw5fQzikE0oA:10 a=DAwyPP_o2Byb1YXLmDAA:9 a=eKyuMFWrcCqgyJEG2WcA:9 a=FrxVD7QTIGadO-ml:21 a=aUoFncIURHWJ3Kx1:21 a=CjuIK1q_8ugA:10 a=yMhMjlubAAAA:8 a=SSmOFEACAAAA:8 a=1eYMmsvMJEer-wEuvAcA:9 a=2w-6Xo4gY-b3IHsR:21 a=gKO2Hq4RSVkA:10 a=UiCQ7L4-1S4A:10 a=hTZeC7Yk6K0A:10 a=frz4AuCg-hUA:10 Received: from [183.82.103.162] (port=45725 helo=savitr95) by bosauthsmtp05.eigbox.net with esmtpa (Exim) id 1gMvpw-0004TF-Vn for pgsql-bugs@lists.postgresql.org; Wed, 14 Nov 2018 09:08:09 -0500 From: "Purushotham" To: Subject: Am unable to return after update/insert execute, let me know is it the way to create or else any other way? Date: Wed, 14 Nov 2018 19:38:07 +0530 Message-ID: <000001d47c23$79f5d2c0$6de17840$@savitr.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01D47C51.93BA43C0" X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdR8I3e3VMim3G21ReajFqxA6qR8mQ== Content-Language: en-in X-EN-UserInfo: 7b8102fa21bd5f995506c1a171e869ba:931c98230c6409dcc37fa7e93b490c27 X-EN-AuthUser: purushotham@savitr.com Sender: "Purushotham" X-EN-OrigIP: 183.82.103.162 X-EN-OrigHost: unknown List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multipart message in MIME format. ------=_NextPart_000_0001_01D47C51.93BA43C0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit -- FUNCTION: fundq.funduseraccessalert(integer, integer, timestamp without time zone, character varying) -- DROP FUNCTION fundq.funduseraccessalert(integer, integer, timestamp without time zone, character varying); CREATE OR REPLACE FUNCTION fundq.funduseraccessalert( currentuserid integer, qfmid integer, usercurrentdate timestamp without time zone, userflag character varying) RETURNS TABLE(qfimid integer, userid integer, statusid bit, useraccessdate timestamp without time zone, lastupdateddate timestamp without time zone, username character varying, useremail character varying, userphone character varying, userstatus text) LANGUAGE 'plpgsql' COST 100 VOLATILE SECURITY DEFINER ROWS 1000 AS $BODY$ DECLARE isActive integer; existuserdate timestamp without time zone;lastUser integer; BEGIN isActive=(select count(*) from fund_user_alerts where qfim_id=qfmId and status=b'1'); existuserdate=(select lastuser_on from fund_user_alerts where qfim_id=qfmId and status=b'1' ORDER BY lastuser_on DESC LIMIT 1); IF isActive > 0 THEN IF userflag='Ok' THEN INSERT INTO fund_user_alerts(qfim_id,user_id,status,lastuser_on,updated_date) values(qfmId,currentuserId,b'1',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP ); RETURN QUERY select qfim_id as QfimId,user_id as UserId,fa.status as StatusId,lastuser_on as UseraccessDate,updated_date as lastupdatedDate, p.first_name as UserName, p.email as UserEmail, p.phone as UserPhone, 'true'::text as UserStatus from fund_user_alerts fa inner join person p on p.id = fa.user_id where qfim_id=qfimId and fa.user_id=currentuserid and fa.status=b'1'; ELSE IF userflag='Submit' THEN UPDATE fund_user_alerts SET lastuser_on=(now() + interval '1' hour),updated_date=CURRENT_TIMESTAMP WHERE qfim_id=qfmId and user_id=currentuserid and status=b'1'; RETURN QUERY select qfim_id as QfimId,user_id as UserId,fa.status as StatusId,lastuser_on as UseraccessDate,updated_date as lastupdatedDate, p.first_name as UserName, p.email as UserEmail, p.phone as UserPhone,'true'::text as UserStatus from fund_user_alerts fa inner join person p on p.id = fa.user_id where qfim_id=qfimId and fa.user_id=currentuserid and fa.status=b'1'; ELSE IF userflag='Fund' THEN IF ((now() - interval '1' hour) < (existuserdate) ) THEN RETURN QUERY select qfim_id as QfimId,user_id as UserId,fa.status as StatusId,lastuser_on as UseraccessDate,updated_date as lastupdatedDate, p.first_name as UserName, p.email as UserEmail, p.phone as UserPhone, (CASE WHEN (currentuserid=user_id) then 'true'::text else 'false'::text end) as UserStatus from fund_user_alerts fa inner join person p on p.id = fa.user_id where qfim_id=qfmId and fa.status=b'1'; ELSE UPDATE fund_user_alerts SET updated_date=CURRENT_TIMESTAMP, status=b'0' WHERE qfim_id=qfmId and status=b'1'; INSERT INTO fund_user_alerts(qfim_id,user_id,status,lastuser_on,updated_date) values(qfmId,currentuserId,b'1',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP ); RETURN QUERY select qfim_id as QfimId,user_id as UserId,fa.status as StatusId,lastuser_on as UseraccessDate,updated_date as lastupdatedDate, p.first_name as UserName, p.email as UserEmail, p.phone as UserPhone, 'true'::text as UserStatus from fund_user_alerts fa inner join person p on p.id = fa.user_id where qfim_id=qfimId and fa.status=b'1'; END IF; ELSE IF userflag='LogOFF' THEN UPDATE fund_user_alerts SET updated_date=CURRENT_TIMESTAMP, status=b'0' WHERE user_id=currentuserid and status=b'1'; select qfim_id as QfimId,user_id as UserId,fa.status as StatusId,lastuser_on as UseraccessDate,updated_date as lastupdatedDate, p.first_name as UserName, p.email as UserEmail, p.phone as UserPhone,'true'::text as UserStatus from fund_user_alerts fa inner join person p on p.id = fa.user_id where user_id=currentuserid and fa.status=b'0'; ELSE INSERT INTO fund_user_alerts(qfim_id,user_id,status,lastuser_on,updated_date) values(qfmId,currentuserId,b'1',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP ); RETURN QUERY select qfim_id as QfimId,user_id as UserId,fa.status as StatusId,lastuser_on as UseraccessDate,updated_date as lastupdatedDate, p.first_name as UserName, p.email as UserEmail, p.phone as UserPhone, 'true'::text as UserStatus from fund_user_alerts fa inner join person p on p.id = fa.user_id where qfim_id=qfimId and fa.status=b'1'; END IF; END IF; END IF; END IF; ELSE INSERT INTO fund_user_alerts(qfim_id,user_id,status,lastuser_on,updated_date) values(qfmId,currentuserId,b'1',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP ); RETURN QUERY select qfim_id as QfimIdtemp,user_id as UserIdtemp,fa.status as StatusIdtemp,lastuser_on as UseraccessDatetemp, updated_date as lastupdatedDatetemp,p.first_name as UserNametemp, p.email as UserEmailtemp, p.phone as UserPhonetemp, 'true'::text as UserStatustemp from fund_user_alerts fa inner join person p on p.id = fa.user_id where qfim_id=qfimId and fa.status=b'1'; END IF; END; $BODY$; ALTER FUNCTION fundq.funduseraccessalert(integer, integer, timestamp without time zone, character varying) OWNER TO "GIPFundQ"; Best regards PuruShotham Goud V +91 9573 9573 54 ------=_NextPart_000_0001_01D47C51.93BA43C0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

-- FUNCTION: fundq.funduseraccessalert(integer, = integer, timestamp without time zone, character = varying)

 

-- DROP FUNCTION fundq.funduseraccessalert(integer, = integer, timestamp without time zone, character = varying);

 

CREATE OR REPLACE FUNCTION = fundq.funduseraccessalert(

         &= nbsp;      currentuserid = integer,

         &= nbsp;      qfmid integer,

         &= nbsp;      usercurrentdate timestamp without = time zone,

         &= nbsp;      userflag character = varying)

    RETURNS = TABLE(qfimid integer, userid integer, statusid bit, useraccessdate = timestamp without time zone, lastupdateddate timestamp without time = zone, username character varying, useremail character varying, userphone = character varying, userstatus text)

    LANGUAGE = 'plpgsql'

 

    COST 100

    VOLATILE SECURITY DEFINER =

    ROWS = 1000

AS $BODY$

 

DECLARE = isActive integer; existuserdate timestamp without time zone;lastUser = integer;

 

 

  =

BEGIN

 

= isActive=3D(select count(*) from fund_user_alerts where qfim_id=3DqfmId = and status=3Db'1');

= existuserdate=3D(select lastuser_on from fund_user_alerts where = qfim_id=3DqfmId and status=3Db'1' ORDER BY lastuser_on DESC LIMIT = 1);

IF isActive > 0 THEN  =

         &= nbsp;           &n= bsp;           IF = userflag=3D'Ok' THEN

         &= nbsp;           &n= bsp;          =

         &= nbsp;           &n= bsp;          =             &= nbsp;  INSERT INTO = fund_user_alerts(qfim_id,user_id,status,lastuser_on,updated_date) =              =

         &= nbsp;           &n= bsp;          =     values(qfmId,currentuserId,b'1',CURRENT_TIMESTAMP= ,CURRENT_TIMESTAMP );

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p; 

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  RETURN QUERY

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  select qfim_id as QfimId,user_id as UserId,fa.status as = StatusId,lastuser_on as UseraccessDate,updated_date as = lastupdatedDate,

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  p.first_name as UserName, p.email as UserEmail, p.phone as = UserPhone, 'true'::text as UserStatus 

         &= nbsp;           &n= bsp;          =     from fund_user_alerts  fa inner join person = p on p.id =3D fa.user_id

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  where qfim_id=3DqfimId and fa.user_id=3Dcurrentuserid and = fa.status=3Db'1';

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p; 

         &= nbsp;           &n= bsp;          ELSE IF = userflag=3D'Submit' THEN 

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  UPDATE fund_user_alerts SET  lastuser_on=3D(now() + = interval '1' hour),updated_date=3DCURRENT_TIMESTAMP

         &= nbsp;           &n= bsp;          =     WHERE qfim_id=3DqfmId and user_id=3Dcurrentuserid and = status=3Db'1';  

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p; 

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  RETURN QUERY

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  select qfim_id as QfimId,user_id as UserId,fa.status as = StatusId,lastuser_on as UseraccessDate,updated_date as = lastupdatedDate,

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  p.first_name as UserName, p.email as UserEmail, p.phone as = UserPhone,'true'::text as UserStatus 

         &= nbsp;           &n= bsp;          =     from fund_user_alerts  fa inner join person = p on p.id =3D fa.user_id

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  where qfim_id=3DqfimId and fa.user_id=3Dcurrentuserid and = fa.status=3Db'1';

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p; 

         &= nbsp;           &n= bsp;          ELSE IF = userflag=3D'Fund' = THEN           &nb= sp;        

         &= nbsp;           &n= bsp;          =             &= nbsp;    IF  ((now() - interval '1' hour)  < = (existuserdate) )  = THEN           &nb= sp;       

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;    RETURN QUERY

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;    select qfim_id as QfimId,user_id as UserId,fa.status as = StatusId,lastuser_on as UseraccessDate,updated_date as = lastupdatedDate,

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      p.first_name as UserName, p.email as = UserEmail, p.phone as UserPhone,

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      (CASE WHEN (currentuserid=3Duser_id) = then

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      'true'::text else 'false'::text end) as = UserStatus

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;      from fund_user_alerts  fa inner = join person p on p.id =3D fa.user_id

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      where qfim_id=3DqfmId and = fa.status=3Db'1';         &n= bsp;           &nb= sp;           &nbs= p;            =

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p; 

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;    ELSE 

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;      UPDATE fund_user_alerts SET  = updated_date=3DCURRENT_TIMESTAMP, status=3Db'0'

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;      WHERE qfim_id=3DqfmId and = status=3Db'1';  

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;     

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      INSERT INTO = fund_user_alerts(qfim_id,user_id,status,lastuser_on,updated_date) =             &= nbsp;  

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  =     values(qfmId,currentuserId,b'1',CURRENT_TIMESTAMP= ,CURRENT_TIMESTAMP );

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;     

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      RETURN QUERY

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      select qfim_id as QfimId,user_id as = UserId,fa.status as StatusId,lastuser_on as UseraccessDate,updated_date = as lastupdatedDate,

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      p.first_name as UserName, p.email as = UserEmail, p.phone as UserPhone, 'true'::text as UserStatus  =

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;      from fund_user_alerts  fa inner = join person p on p.id =3D fa.user_id

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      where qfim_id=3DqfimId and = fa.status=3Db'1';         &n= bsp;           &nb= sp;           &nbs= p;           =    

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;    END IF;

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p; 

         &= nbsp;           &n= bsp;          ELSE IF = userflag=3D'LogOFF' THEN 

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      UPDATE fund_user_alerts SET = updated_date=3DCURRENT_TIMESTAMP, status=3Db'0'

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;      WHERE user_id=3Dcurrentuserid and = status=3Db'1'; 

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;     

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;      select qfim_id as QfimId,user_id as = UserId,fa.status as StatusId,lastuser_on as UseraccessDate,updated_date = as lastupdatedDate,

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      p.first_name as UserName, p.email as = UserEmail, p.phone as UserPhone,'true'::text as UserStatus =

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;      from fund_user_alerts  fa inner = join person p on p.id =3D fa.user_id

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;      where user_id=3Dcurrentuserid and = fa.status=3Db'0';

         &= nbsp;           &n= bsp;          = ELSE

         &= nbsp;           &n= bsp;            INSERT = INTO = fund_user_alerts(qfim_id,user_id,status,lastuser_on,updated_date)  =

         &= nbsp;           &n= bsp;          =   values(qfmId,currentuserId,b'1',CURRENT_TIMESTAMP,CURRENT_TIM= ESTAMP );

         &= nbsp;           &n= bsp;            =

         &= nbsp;           &n= bsp;          =    RETURN QUERY

         &= nbsp;           &n= bsp;             = select qfim_id as QfimId,user_id as UserId,fa.status as = StatusId,lastuser_on as UseraccessDate,updated_date as = lastupdatedDate,

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  p.first_name as UserName, p.email as UserEmail, p.phone as = UserPhone, 'true'::text as UserStatus 

         &= nbsp;           &n= bsp;          =     from fund_user_alerts  fa inner join person = p on p.id =3D fa.user_id

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;  where qfim_id=3DqfimId and fa.status=3Db'1';

         &= nbsp;           &n= bsp;          END  = IF;

         &= nbsp;           &n= bsp;          END  = IF;

         &= nbsp;           &n= bsp;          END  = IF;

         &= nbsp;           &n= bsp;          END  = IF;

ELSE

  =             &= nbsp; INSERT INTO = fund_user_alerts(qfim_id,user_id,status,lastuser_on,updated_date)  =

         &= nbsp;      = values(qfmId,currentuserId,b'1',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP = );

 

  RETURN QUERY

   select qfim_id as QfimIdtemp,user_id as = UserIdtemp,fa.status as StatusIdtemp,lastuser_on as = UseraccessDatetemp,

         &= nbsp;      updated_date as = lastupdatedDatetemp,p.first_name as UserNametemp, p.email as = UserEmailtemp, p.phone as UserPhonetemp,

         &= nbsp;      'true'::text as = UserStatustemp 

    from fund_user_alerts  fa = inner join person p on p.id =3D fa.user_id

         &= nbsp;      where qfim_id=3DqfimId and = fa.status=3Db'1';

END = IF;

  

 

END;

 

$BODY$;

 

ALTER = FUNCTION fundq.funduseraccessalert(integer, integer, timestamp without = time zone, character varying)

    OWNER TO = "GIPFundQ";

 

 

Best = regards

PuruShotham Goud = V

+91 9573 9573 = 54

 

------=_NextPart_000_0001_01D47C51.93BA43C0--