title: Issue in my Dynamic Query
body: <pre><code>select * from pg_tables where schemaname ='reports' and tablename like '%enhancedreports03_0%' order by tablename;
  </code></pre>
  
  <blockquote>
    <p>schemaname |           tablename            |     tableowner      | 
    tablespace  | hasindexes | hasrules | hastriggers
    ------------+--------------------------------+---------------------+--------------+------------+----------+-------------  reports    | enhancedreports03_0_1970_01_01 | ss_agent_summarizer |
    rpt_data_tbs | t          | f        | f  reports    |
    enhancedreports03_0_2013_10_08 | ss_agent_summarizer | rpt_data_tbs |
    t          | f        | f</p>
    
    <p>Check constraints:
        "enhancedreports03_0_1970_01_01_check" CHECK (0::double precision >= date_part('epoch'::text, '1970-01-01'::date) AND 0::double precision &lt; date_part('epoch'::text, '1970-01-02'::date))</p>
  </blockquote>
  
  <p>I need to drop the constraints in both the tables..So i tried an dynamic query to generate the result set... </p>
  
  <pre><code>select 'ALTER TABLE  '||schemaname ||'.'||tablename||' DROP CONSTRAINT '||conname||'' from pg_tables a, pg_constraint b
  where schemaname ='reports' and tablename like '%enhancedreports03_0%' and conname like '%enhancedreports03_0_%' order by tablename;
  </code></pre>
  
  <blockquote>
    <blockquote>
      <h2>?column?</h2>
    </blockquote>
  </blockquote>
  
  <pre><code>ALTER TABLE  reports.enhancedreports03_0_1970_01_01 DROP CONSTRAINT
   enhancedreports03_0_1970_01_01_check  ALTER TABLE 
   reports.enhancedreports03_0_1970_01_01 DROP CONSTRAINT
    enhancedreports03_0_2013_10_08_check  ALTER TABLE 
    reports.enhancedreports03_0_1970_01_01 DROP CONSTRAINT
    enhancedreports03_0_2013_10_08_check  ALTER TABLE 
    reports.enhancedreports03_0_1970_01_01 DROP CONSTRAINT
     enhancedreports03_0_2013_10_08_check  ALTER TABLE 
     reports.enhancedreports03_0_2013_10_08 DROP CONSTRAINT
     enhancedreports03_0_1970_01_01_check  ALTER TABLE 
      reports.enhancedreports03_0_2013_10_08 DROP CONSTRAINT
    enhancedreports03_0_2013_10_08_check  ALTER TABLE 
   reports.enhancedreports03_0_2013_10_08 DROP CONSTRAINT
     enhancedreports03_0_2013_10_08_check  ALTER TABLE 
     reports.enhancedreports03_0_2013_10_08 DROP CONSTRAINT
     enhancedreports03_0_2013_10_08_check 
  (8 rows)
  </code></pre>
  
  <p>I need the result set to be like this</p>
  
  <pre><code>ALTER TABLE  reports.enhancedreports03_0_1970_01_01 DROP CONSTRAINT enhancedreports03_0_1970_01_01_check
  ALTER TABLE  reports.enhancedreports03_0_2013_10_08 DROP CONSTRAINT enhancedreports03_0_2013_10_08_check
  </code></pre>
  
  <p>Thanks in advance
  Abdul          </p>