Difference between revisions of "Public.getmanagedservicecountforintf (function)"

From dbscript Online Help
Jump to: navigation, search
(New page: == wikibot == {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" |- | '''function | public.getmanagedservicecountforintf |- |} <pre> CREATE OR REPLACE FUNCTIO...)
 
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
|-
+
|- valign="top"
| '''function
+
| '''Function
 
| public.getmanagedservicecountforintf
 
| public.getmanagedservicecountforintf
|-
 
 
|}
 
|}
  
 +
=== Source ===
 
<pre>
 
<pre>
 
CREATE OR REPLACE FUNCTION public.getmanagedservicecountforintf(integer, character varying)
 
CREATE OR REPLACE FUNCTION public.getmanagedservicecountforintf(integer, character varying)

Latest revision as of 10:19, 27 August 2011

wikibot[edit]

Function public.getmanagedservicecountforintf

Source[edit]

CREATE OR REPLACE FUNCTION public.getmanagedservicecountforintf(integer, character varying)
 RETURNS double precision
 LANGUAGE plpgsql
AS $function$
   DECLARE
	nid ALIAS FOR $1;
	ipid ALIAS FOR $2;
	orec RECORD;
	counter float8;
   BEGIN
	counter = 0;
	FOR orec IN SELECT DISTINCT ifservices.nodeid, ifservices.ipaddr, ifservices.serviceid 
		FROM ipinterface, ifservices 
		WHERE ifservices.nodeid = nid 
			AND ifservices.ipaddr = ipid 
			AND ipinterface.nodeid = nid 
			AND ipinterface.ipaddr = ipid 
			AND ipinterface.ismanaged = 'M' 
			AND ifservices.status = 'A'
	LOOP
		BEGIN
			counter := counter + 1;
		END;
	END LOOP;
	RETURN counter;
   END;
$function$