By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,144 Members | 849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,144 IT Pros & Developers. It's quick & easy.

bsearch/qsort problem for effective_dated search non-exact

P: n/a
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?
Nov 14 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
c_**********@gazeta.pl (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
Nov 14 '05 #2

P: n/a
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote in message news:<42****************@news.xs4all.nl>...
c_**********@gazeta.pl (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.
Nov 14 '05 #3

P: n/a
c_**********@gazeta.pl (c_programmer) wrote:
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote in message news:<42****************@news.xs4all.nl>...
c_**********@gazeta.pl (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
Nov 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.