Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 44ADCF6332A for ; Thu, 19 Jul 2012 06:15:45 -0300 (ADT) Received: from mail.avineonindia.com ([175.101.1.171] helo=aipl-2s5532s.avineonindia.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Srmpg-0002Dw-18 for pgsql-admin@postgresql.org; Thu, 19 Jul 2012 09:15:44 +0000 Received: from MAIL.avineonindia.com (Not Verified[10.0.1.9]) by aipl-2s5532s.avineonindia.com with MailMarshal (v6, 8, 3, 9481) id ; Thu, 19 Jul 2012 14:44:32 +0530 X-Footer: YXZpbmVvbmluZGlhLmNvbQ== Received: from aiplina82109cp ([10.0.12.99]) (authenticated user mlanka@avineonindia.com) by MAIL.avineonindia.com for pgsql-admin@postgresql.org; Thu, 19 Jul 2012 14:44:31 +0530 Reply-To: From: "Madhu.Lanka" To: Subject: need help to write a function in postgresql Date: Thu, 19 Jul 2012 14:44:28 +0530 Organization: Avineon India Pvt. Ltd. Message-ID: <000b01cd658e$e66ae920$b340bb60$@avineonindia.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000C_01CD65BD.00232520" X-Mailer: Microsoft Outlook 14.0 Thread-Index: Ac1ljtpifI2xg+j8QUyWUWcMcDw/Yw== Content-Language: en-us X-Pg-Spam-Score: 0.8 (/) X-Archive-Number: 201207/40 X-Sequence-Number: 39757 This is a multipart message in MIME format. ------=_NextPart_000_000C_01CD65BD.00232520 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Friends Can u please help to write a function for the following scenario? I have 3 table's user_roles, principals and roles. I have to write a function in postgresql which should excepts 2 parameters (name, password) With those 2 parameters the query should be executed and return the result.(Result of the query will be 1 or more rows). The query is working fine if executed it manually by hardcoding the values for name and password, but is as to be written in function so that I can send different values. "select u.role_id,u.user_id,p.name,p.creation_date,p.telephone_number,p.email,p.rema rks,p.city,p.state,p.country,p.postal_address,p.company_name,p.department_na me,p.contact_person, p.role_group,p.role_description,p.first_name,p.last_name,p.pincode,p.status, p.department_id,p.designation_id,r.role_name,r.right_edit,r.right_filter,r.r ight_search,r.right_browse, r.right_print, r.right_download,r.right_admin_user,r.right_image_creator,r.right_vector_dow nload,r.right_wps,r.right_queries_filter,r.right_google_map,r.right_user_man agement, r.right_route_analysis, r.right_legend,r.right_treeview,r.insert,r.update,r.delete,r.query,r.lock from user_roles u,.principals p,roles r where p.PRINCIPAL_ID = u.USER_ID and r.role_id = u.role_id and p.name=? and p.password=?" Thanks in Advance. Regards Madhu.Lanka ------=_NextPart_000_000C_01CD65BD.00232520 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi = Friends

 

Can u please help to write a function for the = following scenario?

 

I have 3 = table’s user_roles, principals and roles.

I have to write a function in postgresql which should = excepts 2 parameters (name, password)

With those 2 parameters the query should be executed = and return the result.(Result of the query will be 1 or more = rows).

The query is working fine if = executed it manually by hardcoding the values for name and password, but = is as to be written in function so that I can send different = values.

 

“select = u.role_id,u.user_id,p.name,p.creation_date,p.telephone_number,p.email,p.r= emarks,p.city,p.state,p.country,p.postal_address,p.company_name,p.departm= ent_name,p.contact_person,

p.role_group,p.role_description,p.first_name,p.last_nam= e,p.pincode,p.status,p.department_id,p.designation_id,r.role_name,r.right= _edit,r.right_filter,r.right_search,r.right_browse,

r.right_print, = r.right_download,r.right_admin_user,r.right_image_creator,r.right_vector_= download,r.right_wps,r.right_queries_filter,r.right_google_map,r.right_us= er_management,

r.right_route_analysis, = r.right_legend,r.right_treeview,r.insert,r.update,r.delete,r.query,r.lock= from user_roles u,.principals p,roles r where p.PRINCIPAL_ID =3D = u.USER_ID and

r.role_id =3D = u.role_id and p.name=3D? and = p.password=3D?= 221;

 

 

Thanks in = Advance.

 

Regards

Madhu.Lanka

------=_NextPart_000_000C_01CD65BD.00232520--