Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to define such view?
Message
 
 
À
01/03/2005 12:18:52
Jim Winter
Jim Winter Consulting
Hinesburg, Vermont, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Divers
Thread ID:
00991616
Message ID:
00991670
Vues:
15
>>>>Hi everybody,
>>>>
>>>>I have a problem to which I don't see an immediate solution, so I am hoping that great minds from UT can help me with it.
>>>>
>>>>I have a view
>>>>CREATE SQL VIEW LV_SAVED_SEARCHES AS ;
>>>>SELECT Saved_searches.* ;
>>>>	FROM mmviscollect!saved_searches ;
>>>>	WHERE Saved_searches.cusgrlink_fk = ( ?vp_cusgrlink_fk ) ;
>>>>		OR Saved_searches.cusgrlink_fk = ( ?vp_vcam_fk ) ;
>>>>	ORDER BY Saved_searches.isequence_number
>>>>
>>>>Now, in its current way it will always return all records, because we defined all of them for VCAM user. I want it to return "my" records if it finds that cUsgrLink_fk matches my cUsgrLink_fk. However, if I don't have records for my ID, I want it to return all records. Could you please help me a little bit?
>>>>
>>>>Thanks in advance.
>
>Nadya,
>
>OK, not tested, but this might work:
>CREATE SQL VIEW LV_SAVED_SEARCHES AS ;
>SELECT Saved_Searches.* ;
>  FROM mmviscollect!saved_searches ;
> WHERE Saved_searches.cusgrlink_fk = ( ?vp_vcam_fk ) ;
>   AND NOT EXISTS(SELECT * FROM mmviscollect!saved_searches ;
>                   WHERE Saved_searches.cusgrlink_fk = ( ?vp_cusgrlink_fk )) ;
> UNION ;
>SELECT Saved_Searches.* ;
>  FROM mmviscollect!saved_searches ;
> WHERE Saved_searches.cusgrlink_fk = ( ?vp_cusgrlink_fk )
>
>BTW, if you're comparing both parameters against the same foreign key, how can one return all the records and the other not be identical to return any records?
>
>Regards,
>
>
>HTH,

Well, it works. But I can not use * (I have memo fields) and I can not use field name in the Order By clause. I would not be able to use View Designer, since it doesn't support UNION. Luckily I don't have to make this view :)

Thanks again.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform