Making a pivoted view writtable - oracle11g

We are current on Oracle 11g.
I created a view (View A) which joins multiple tables. I then create a another view (View B) using PIVOT.
The requirement is to make View B writable, so I use the Trigger to do an INSTEAD OF.
The challenge is that inside of the trigger, I have to write an individual INSERT statement for each non-null pivoted column and these columns can grow. I don't want to be modify the trigger every time a column is added. Is there an elegant to way to handle this situation?
Thanks
P.S. I have made a honest effort to search the net, but come up empty, so you know or think there's a duplicate article out there, simply let us know and don't down vote the question. Appreciated very much! :)

Related

Multiple datasources for same SQL DB

I have an app page that shows information from the same table in 2 places on a page.
In the place A, I want an editable field that is owned by the current user.
In the place B, I want to see the list of entries for all users.
I thought I could somehow have two pointers into the same table by configuring more than one datasource for the table, and bind placeA/B widgets to the two separate datasource.
However, I could not find out how I can bind a panel or widget to a specific datasource within a table.
What bugs me is that clearly the UI allows me to add multiple datasources for a table, so I probably misunderstand what the usercase for multiple datasources are.
My current plan is to ivestigate whether I can create a computed datasource that limits results to just the current user, but I don't understand how I could updated a computed datasource (which is something I want to do).
This is probably less than clear, happy to add clarifying information.
Many thanks in advance for any help
Never mind. App maker behaves as I thought it should be. The two datasources are behaving as two cursors into the same table. For some reason, I could not seem to find the 2nd datasource in the widget dropdown for datasource, but I could find it by selecting "Advanced" and then finding datasource starting from "datasources" instead of "widget.datasource".
Nothing to see here, move along now ;)

How do I create an Access Form for Table 1 where two Table 1 fields have different data from a single field in Table 2?

I’m absolutely stumped by what I suspect is probably simple for those experienced with Access. I’m brand new to Access (2010) and studying a lot, but unfortunately still confused by many basic concepts. I’m embarrassed to admit that I have spent about 40 hours trying (unsuccessfully) to solve the specific issue below. Please forgive me if I haven’t included enough detail here - I’m not sure how much someone needs to know to address this. I’m happy to edit and/or provide more information.
My question:
How do I create a Form for creating new records / editing existing records in Table1 where two fields in Table1 have different values from a single field in Table2? (I have better detail below)
I want the Form to have all the records from Table1. I have tried many different ways with queries, sub-forms, etc., but can’t pull it off. I’m fairly certain the issue is related to how I address Table2. Ideally, the user would be able to select from dropdowns in the form for the two fields to be updated in Table1.
I am including screenshots of a mockup of my intended Form concept, the object Relationships as I currently have them, the design and datasheet views of Table1 and the design and datasheet views of Table2.
“Table1” above is “t_PEOPLE” in the images while “Table2” is “t_COLORS.”
The object relationship types are currently one-to-many with enforced referential integrity (cascade update related fields) and the join properties are "include ALL records from 't_PEOPLE' and only those records from 't_COLORS' where the joined fields are equal."
I'm happy to send the actual database file if that helps.
I will be very grateful for any guidance - thank you!!
The general approach to this is as follows:
A) If I understand what you're trying to do here, your t_colors table is usually referred to as a Reference table or Lookup table. You need to make one form to add, edit, and delete records in this t_colors table. How the user accesses that form varies. I'll get to that in a minute.
B) The form for your People table needs to have drop down menus for your two color selections. In the dropdown menus' RowSource, you will use a query that looks up values in your t_colors table.
C) Depending what you are using your colors for in t_people, you should consider making a third table with PeopleID and ColorID in it. It would then link to both t_people and t_colors. This would allow you to have multiple colors specified for a single person, and you wouldn't be limited to two. In your People form, you would use a subform for these colors. The subform would probably need to be a datasheet form or a continuous form. If you are using a datasheet form for your people form, then you would need to use a datasheet form for the colors subform.
If the user wants to use a color that isn't already in your t_colors table, you need to give them a way of inserting that color. There are various approaches to this. You could use a union query in the dropdowns RowSource that shows a "" option. If selected you would bring up your Colors form and when they close the colors form you have to requery your dropdown menu. Or you could insert the color for them using VBA when they enter a value that is "Not In List" (an event that Combobox's have).
Please note that the relationships you've defined are not overly helpful or important in this case. Yes, they can be helpful when it comes to using the Update Cascade or Delete Cascade features. But quite truthfully, relationships are basically for programmers, to make sure you get an error if and when referential integrity is violated. Users should never see these errors and properly designed forms will prevent them from occurring. The main reason to use them is that it will force you to design your forms properly by giving you an error when something is wrong, hopefully during your own testing phase of the project.

DataGrid-- one column uses different data from the others

I have a DataGrid I'm binding to a DataTable, and displaying three BoundColumns as a result.
I would like to have a fourth column that connects with different data-- for instance, if column #3 in the DataGrid is a UserID, I would like to use that to query against a database and retrieve the user's first name, and display it in the fourth column.
Are there any recommended approaches to this? I'm not a DataGrid expert but should I be looking at a TemplateColumn or something along those lines?
Which event should I hook all this querying to, OnItemDataBound?
The recommended approach is return the user's first name as part of the original query and just use a BoundColumn. If you need to modify data before displaying, then yes you can use a TemplateColumn and the OnItemDataBound event to manipulate your data.
Running queries OnItemDataBound is not something I would ever encourage. So if your grid will show 100 records at once, you want to run 100 extra queries per page load? This is something that if you implement, could possibly run within reason during testing. Once under load though, you'll see have hundreds of extra queries running isn't a good idea... it can just be solved by fixing the original query or maybe making a denormalized table depending on your DB structure and the complexity of your query.
When I ran into similar issue, I went the denormalized table route.
Use a join in your sql statement to get the other value.

Showing Details in sub Grid

Orders grid is containing a sub-grid for order details. Normally I am doing this by implementing RowDataBound event. but I think it is bad idea to fetch order details from database for every row of orders grid. Is there a better way?
Thanks
As far as "bad idea", I assume you mean from a performance standpoint. In my opinion the scenario you describe isn't necessarily a bad idea, depending on the performance expectations of your application. The method you suggest is the easiest to implement that I can think of, and could be the best way if your page isn't going to be hit very often.
Having said that, I can think of two other ways to approach this.
1) Join your order details at the DB level, and render the table manually using a repeater, adding outer rows only when the main order record changes. This method would require only one trip to the database for each page render but requires more coding for presentation.
2) Pre-fetch all of your order details on page load into a DataTable or collection and load your details from there on your outer gridview RowDataBound. This method would also reduce trips to the database down to two (one for the orders, one for order details) but wouldn't require as much presentation coding.

Grid Nic Add stationary row

I am using GridNic for printing reports. I want to add a row at the bottom containing total of a column. I searched across the web but couldn't find a solution.
I tried to add an extra array index in dataset containing total of a column, but when I sort the table it no longer remains at the bottom.
Also, I'll really appreciate if somebody can share GridNic documentation with me. The documentation on GridNic site is not really helpful.
thanks in advance!!
Brute force: cannot find elegant solution
Works for me on SlickGrid:
In sort handle before call sort method clone your total row, then call sort method, then place copy back
Hope will help

Resources