How do I use LIKE in a postgresql function for loop query -


having view named jap.lots_name_view products names name

                       name                        

flame 19#pouch acosta produce ctn b flame 19#pouch acosta produce ctn b flame 19#pouch so2 j.a.p. black 5l styro b red globe 21#plainso chelan starr 7l sty red globe 21#plainso chelan starr 7l sty sugraone 19#pouch free bird ctn b summer royal 19#pouch so2 sf white od 5l styro summer royal 19#pouch top gun cnt 

and having list of categories this: select inid inventory type ='variety' , list below:

    invid      --------------  sugraone  autumn royal  flame  summer royal  red globe 

now question how loop through list out category list using on function counting out on list of inventory items , result below

    invid     |  count     sugraone     | 1  autumn royal | 2  flame        | 3  summer royal | 2  red globe    | 2 

so far tried:

create or replace function jap.category_lookup()  returns table(variety text, count bigint)  $func$  declare    category text;  begin    category in     select quote_ident(invid)       jap.inventories      type 'variety' loop   return query execute   'select count(v.*), category    jap.lots_name_view v      name '% || category || '%';   end loop; end $func$  language plpgsql; 

but errors

error:  operator not exist: || text line 3:         name '% || category || '%'                                    ^ 

what right approach use clause

why use loop query? this:

select count(*), i.invid category jap.lost_name_view v join      jap.inventories      on  v.name '%' || i.invid || '%'  exists (select 1               jap.inventories                            ) group i.invid; 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -