Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > bsearch/qsort problem for effective_dated search non-exact

Reply
Thread Tools

bsearch/qsort problem for effective_dated search non-exact

 
 
c_programmer
Guest
Posts: n/a
 
      06-07-2005
I have a problem.
There is a effective dated list FAMILY_ACCOUNTS stored in the memory.
How to achieve the equivalent of the following SQL statement:


select * from FAMILY_ACCOUNTS FA
where EFFECTIVE_DATE =
(select max(EFFECTIVE_DATE) from FAMILY_ACCOUNTS FA2 where
FA.FAMILY_ACCOUNTS_KEY = FA2.FAMILY_ACCOUNTS_KEY)
and EFFECTIVE_STATUS ="ACTIVE"
and EFFECTIVE_DATE <= given_date
and FAMILY_ACCOUNTS_KEY = given_key

using bsearch and qsort?
 
Reply With Quote
 
 
 
 
Richard Bos
Guest
Posts: n/a
 
      06-08-2005
(c_programmer) wrote:

> I have a problem.
> There is a effective dated list FAMILY_ACCOUNTS stored in the memory.
> How to achieve the equivalent of the following SQL statement:
>
> select * from FAMILY_ACCOUNTS FA
> where EFFECTIVE_DATE =
> (select max(EFFECTIVE_DATE) from FAMILY_ACCOUNTS FA2 where
> FA.FAMILY_ACCOUNTS_KEY = FA2.FAMILY_ACCOUNTS_KEY)
> and EFFECTIVE_STATUS ="ACTIVE"
> and EFFECTIVE_DATE <= given_date
> and FAMILY_ACCOUNTS_KEY = given_key
>
> using bsearch and qsort?


That's impossible to answer unless you tell us, quite precisely:
- how FAMILY_ACCOUNTS is declared, in your C program;
- what this SQL code does (I can tell that it selects something based on
a set of requirements, but how, for example, does max() work?);
- what the correspondence is between the elements of the SQL data set
and your C objects.

Richard
 
Reply With Quote
 
 
 
 
c_programmer
Guest
Posts: n/a
 
      06-08-2005
(Richard Bos) wrote in message news:<>...
> (c_programmer) wrote:
>
> > I have a problem.
> > There is a effective dated list FAMILY_ACCOUNTS stored in the memory.
> > How to achieve the equivalent of the following SQL statement:
> >
> > select * from FAMILY_ACCOUNTS FA
> > where EFFECTIVE_DATE =
> > (select max(EFFECTIVE_DATE) from FAMILY_ACCOUNTS FA2 where
> > FA.FAMILY_ACCOUNTS_KEY = FA2.FAMILY_ACCOUNTS_KEY)
> > and EFFECTIVE_STATUS ="ACTIVE"
> > and EFFECTIVE_DATE <= given_date
> > and FAMILY_ACCOUNTS_KEY = given_key
> >
> > using bsearch and qsort?

>
> That's impossible to answer unless you tell us, quite precisely:
> - how FAMILY_ACCOUNTS is declared, in your C program;
> - what this SQL code does (I can tell that it selects something based on
> a set of requirements, but how, for example, does max() work?);
> - what the correspondence is between the elements of the SQL data set
> and your C objects.
>
> Richard


You don't know SQL?
FAMILY_ACCOUNT is some struct, that have EFFECTIVE_STATUS AC or DE,
EFFECTIVE_DATE i.e. 20050608 and some key i.e. Account No. For single
account we can have more then one row let say:

key1 20050601 AC
key1 20050603 AC
key1 20050605 AC
key1 20050607 DE


Our bsearch run with key1 and 20050602 should return row from 20050601
with key1 and 20060606 should return row from 20050605 and with key1
20050609 shouldn't return anything at all.
 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      06-09-2005
(c_programmer) wrote:

> (Richard Bos) wrote in message news:<>...
> > (c_programmer) wrote:
> >
> > > select * from FAMILY_ACCOUNTS FA
> > > where EFFECTIVE_DATE =
> > > (select max(EFFECTIVE_DATE) from FAMILY_ACCOUNTS FA2 where
> > > FA.FAMILY_ACCOUNTS_KEY = FA2.FAMILY_ACCOUNTS_KEY)
> > > and EFFECTIVE_STATUS ="ACTIVE"
> > > and EFFECTIVE_DATE <= given_date
> > > and FAMILY_ACCOUNTS_KEY = given_key
> > >
> > > using bsearch and qsort?

> >
> > That's impossible to answer unless you tell us, quite precisely:
> > - how FAMILY_ACCOUNTS is declared, in your C program;
> > - what this SQL code does (I can tell that it selects something based on
> > a set of requirements, but how, for example, does max() work?);
> > - what the correspondence is between the elements of the SQL data set
> > and your C objects.

>
> You don't know SQL?


Only superficially.

> FAMILY_ACCOUNT is some struct,


_Some_ struct. Which part of "precisely" didn't you understand? You
cannot sort "some" struct. You can only sort a specific struct.

Richard
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
| SEO , Search Engine Optimizer, SEARCH OPtiMIzAtIoN with SeaRch OPtiMizer optimizer.seo@gmail.com Digital Photography 0 04-22-2007 04:20 AM
Google search result like site search!! How? =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?= ASP .Net 3 05-06-2005 02:08 AM
removing search engines from the search bar whatever.or.not@gmail.com Firefox 1 02-17-2005 12:06 PM
Search Bar not displaying search Engines Zimran Douglas Firefox 1 01-07-2005 02:30 PM
search within a search within a search - looking for better way...my script times out Abby Lee ASP General 5 08-02-2004 04:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57