/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2010 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
SET SCAN OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK

DECLARE

  --
  -- Local constants and variables
  --
  l_sql varchar2(32000);

BEGIN

  --
  -- Register Query Tag Cloud
  --
  l_sql :=
'        SELECT tc.tag_id
              ,tc.tag
              ,1 weight
              ,tc.count counter
              ,tc.count repeated
              ,least(tc.count*85, 240) font_size
              ,tc.count*2 meuPeso
        FROM   xxas_com_tag_cloud tc
        WHERE  tc.count > 0
        AND   (:pFilterText IS NULL OR
               tc.tag LIKE ''%'' || :pFilterText || ''%'')
        ORDER BY count desc ';

  xxas_com_sr_pkg.seed_query_service
    (p_service_name      => 'QueryTagCloud'
    ,p_securing_function => 'XXAS_SRV_Q_TAG_CLOUD_PERM'
    ,p_sql               => l_sql
    ,p_parameters        => xxas_com_sr_param_varray
                              (xxas_com_sr_param_type('pFilterText', xxas_com_sr_pkg.g_VARCHAR2))
    ,p_page_size         => 30);

END;
/
COMMIT;
EXIT;
