The format of this code is from this thread:
I have ordered the fields in the SQL syntax according to the order in the database.
I’m still getting one error: “Error: ( (01S01)) attempting to access a record from the dbo.Orders file. Returning to previous window.” Followed by: “Error ( (0) attempting to open curent VIEW. Filter and Range Limits ignored”. Followed by the same error as the first, then closes the browse.
I’m still searching, but any help would be appreciated.
Okay, going back to basics. From the snippet posted, it seems you are using ABC templates.
Unless the SQL is extremely simplified for what you actually want, it looks to me as if this query can easily be achieved using a standard ABC browse. Why complicate with PROP:Sql?
I am using an ABC browse. I have tried to achieve this using the templates, but have been unable to get it to give the desired output. The result set I’m looking for is to filter the browse so that only projects assigned to the logged in user show up. There are two tabs, one showing current orders and the other is order history, so I have conditional filtering on the tabs also. There are over 100,000 records and it seems to run a bit faster when I use SQL:prop for other queries. There are also other filter options on the browse from radio button choices. I honestly have not been very successful getting many-to-many relationships to work properly in my applications. I’ve read many articles on the subject, most of them in Dave Harms, Tips and Tricks books. Anyway, any articles that would help to explain the implementation of using many-to-many relationships would be appreciated, along with explanations of embed points.
I have exactly the same requirement in my Apps. By far, the easiest solution (in code and especially maintenance) is to create an SQL view in the backend and define that view as a table in Clarion. This is especially true if you need to show summary totals in your browse.
My suggestion would be to work up a quick browse test after creating one example SQL view and that view as one table in the DCT.
That way you would have a one page log file to look at rather than an 88 page log file.
You have a lot of “File not open” errors in your log. Like Sean says, you need to check those out.
Also, the query that is being sent to the backend is not the one that you started off the thread with. Rather than looking for items that belong to Rick, you seem to be using an outer join to find things that are not assigned to anyone. It is possible that the ( IsAs.ORDERS_ID = 0 ) restriction is causing you a problem. Maybe it should be IS NULL? Clarion often treats NULLS as zero and vice versa but SQL is fussier.
I finally have a functioning test browse using a view, very cool. I’m still using a string, “Rick” in the View filter on the backend though. Is there a way to send a variable to the View? Can it only be done using stored procedures?
Thanks again for all of the feedback. I still need to look into the “File not open” errors too.
Okay, from reading back a little further, it seems you want to filter by the user to whom the projects are assigned. As long as this is just another column in the view, you simply include the user condition in your Clarion browse. If your expected return of data is still a very large set of records (especially everyday use), add other conditions that can easily be specified (for instance, by year).
The user name and projects are in a many to many relationship. I’m trying filter the user view based on their windows login name so they only see the projects their assigned to. I can obtain the username, but am having trouble sending it to the SQL View. I need a variable in the View filter that received the users login name. Does that help to clarify what I’m trying to do and\or thinking of the solution correctly?
The username simply needs to be included in the SQL View:
JOIN assigned a ON a.projectid = p.projectid
JOIN username u ON u.usernameid = p.projectid
u.username = ‘Rick’
I don’t know if I’m missing something, but it’s still not clicking for me. I need a variable where ‘Rick’ is, in the line u.username = ‘Rick’. Otherwise other people will not be able to see what is assigned to them. They’ll only be able to see what’s assigned to ‘Rick’. I apologize if I’m making this more difficult than it needs to be.