General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
I think the problem is that you may be looking at this from an Xbase perspective rather than an SQL perspective. Remember, SQL returns sets of records (even sets of one or even zero records). Your subquery should return a set of one record with one field (probably named CNT) that has the count of records that meet the subquery's criterion. The SQL engine in VFP doesn't understand how to do the greater than comparison in your main query between
lFullyPaid .and. ;
ceiling( (DaysToPaid() - IntCalc.ic_days) / 30 ) + 1
and the resultant set from the subquery. The long and short of it is the line in the help on SQL - Select that "you can not nest field functions" which includes COUNT(*). You are going to have to break this up into multiple queries. Sorry.
>Please have a look at the lines marked with "$". VFP returned the error "This type of query not allowed" when I tried to open the view. Does that refere to the subquery?
>Is this type of subquery allowed in views in 6.0?
>
>Thanks - Miles Thompson
>
>create sql view lv_intcalcsource as ;
>select InvHead.cinvoi_key, ;
> <snip>
> InvHead.cPenRevAcc ;
> from hea!InvHead inner join hea!Company ;
> on InvHead.cCompa_Key = Company.cCompa_Key ;
> where ;
> ( DaysToPaid() > IntCalc.ic_days .and. .not. lFullyPaid ) ;
> .or. ;
> ( lFullyPaid .and. ;
> ceiling( (DaysToPaid() - IntCalc.ic_days) / 30 ) + 1 > ;
>$ (select count(*) ;
>$ from InterestDetails ;
>$ where InvHead.cInvoi_Key = cDet_InvoiKey) ) ;
> order by Company.cCompanyName, InvHead.dCompletionDate
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only