Re: Query on array-elements inside object

From: Jie Liang <jliang(at)ipinc(dot)com>
To: Umashankar Kotturu <adityauma(at)hotmail(dot)com>
Cc: pgsql-sql(at)hub(dot)org
Subject: Re: Query on array-elements inside object
Date: 2000-09-05 18:03:25
Message-ID: 39B5356C.6385103A@ipinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi, there

I believe that if you create a function with PL/pgSQL that take a text array as
parameter:
create function cancer(_text) returns bool as '
declare
.....
begin
use a while loop here to scan the whole array
if string match 'cancer' immediately return true otherwise
end the loop
return false
end;
' language 'plpgsql';

Umashankar Kotturu wrote:

> Hi,
>
> I am new to Postgres as well as object database. Wondering if one of you can
> tell me on how to write a sql query to select an object that has a
> particular element in an array.
>
> Example
>
> If I create an object-table with 2 elements.
> a) PatientID -> numeric
> b) DiseaseArray -> array of text
>
> - This DiseaseArray has elements like "cancer", "tb" etc...
>
> Now how will I write a sql-query to select all patients that have "cancer"
>
> Any pointers will be helpful.
>
> regards,
> Uma.
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.

--
Jie LIANG

Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang(at)ipinc(dot)com
www.ipinc.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Larry Rosenman 2000-09-05 19:56:30 7.0.2: Arrays
Previous Message Jie Liang 2000-09-05 17:53:22 Re: Re: Order by in stored functions