Submit nested UDTTs to a stored procedure in set based notation - sql

I am helping a colleague with a system he has been tasked with where we have a form that has multiple sections and many of those sections can have sub-sections and those 2nd level sub-sections can have (third level) sub-sections themselves.
So, we have multiple User Defined Table Types, one that has the top level table structure, then inside of the first section there is a UDTT (let's call it subject as it is both sides of the problem in question), then inside of each 'side' we have another UDTT, perhaps their contact information, multiple phone numbers with a type column for each.
And there are n top level sections where up to n of them can have second or even third level UDTTs associated with them.
Now, I like using UDTTs to import large datasets from some kind of external source (usually a webpage where somebody has uploaded a large Excel or CSV file), but I have never had the circumstance where I have needed to pass multilevel UDTTs to a single stored procedure and I am not even sure how that would work, but in my quest for efficiency I am trying to find a way to do this without a while or for loop.
So... any suggestions?

You can't submit UDTT in a nested structure because a UDTT cannot contain a UDTT as a column within it.
However you can solve the problem by flattening the data and using a key field to links the children to the parent. For this you would need 1 parameter per different UDTT structure you are using and then rows within those parameters are linked using the key field to build your hierarchy.
You can then recover you original structure within the stored procedure depending on what actions you wish to take.

Related

PowerApps filter returning incomplete data record...?

I have an Azure SQL database, and my records inside table Spiderfood_RITMData in that database includes 13 different fields. Lots of stuff. I have confirmed in SQL-SMS that the records have data in each field.
There are way more items in the database than PowerApps can see using LOOKUP (1600-9000 records or more). However, I know FOR A FACT that there is only ONE record that has any given value in the NUMBER column. It's not a primary key, but it is unique in the table.
In PowerApps, I am trying to pull that field so that I can eventually parse out the individual items.
So, the commands I'm trying are:
ClearCollect(MLE_test1, Filter('Spiderfood_RITMData', "RITM2170467" in Number));
ClearCollect(MLE_test2, Search('Spiderfood_RITMData',"RITM2170467", "Number"));
However, the Collection results for MLE_test1 and MLE_test2 both are empty EXCEPT for the value of NUMBER. Say what?!
I'm trying to use the examples posted on https://learn.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-filter-lookup but I am honestly getting baffled by this.
How should I be formatting this call such that I can pull the whole record?
Big picture explanation: I need to do a lot of data LOOKUPS into my table Spiderfood_RITMData table, but it has way more than 2000 rows, and PowerApps will not perform the Lookup correctly. So my presumably smart idea is to create a MUCH SMALLER "version" of Spiderfood_RITMData as a local collection, using a more delegateable function (such as FILTER or IN). If I filter by all records containing the values of NUMBER, then I go from, say a 10,000-record SQL table to a 10-record Collection. And I can do LOOKUPS against that collection for the rest of the function (uh, I think -- I'm still trying to experiment accordingly). Please let me know if this is crazy or not.
LookUp is just used to get one record, instead try this:
ClearCollect(MLE_test1, Filter('Spiderfood_RITMData', "RITM2170467" = Number));
This gets a collection with all the items where Number is = to "RITM2170467"
Collections are limited to only 2000 records in each collections.
I had same issue. Go to App settings. Under Upcoming Features make sure Explicit column selection is turned off. Hope this does it for you.

Best way to handle multi-valued fields as a view/grid

In several notes applications, instead of handling related data as separate documents, if the size of the data is small (less than the 32k limit), I'll make several multi valued fields and display it in what I call a "List Panel". It's a table where each column displays one multi-value field. Since fielda(1) goes with fieldb(1) that goes with fieldc(1) there is a concept of rows. (I did a similar thing in my auditing routine discussed here )
It is always assumed that each field has exactly the same number of elements.
All the multi-value fields are then stored on the single document. This avoids several coding conventions that made my eyes bleed like having date changed, who changed it, new value fields for each field we wanted to audit. Another thing that this kept to a minimum was having to provide multiple fields for the same thing that locked you into a limit. Taxrate1, Taxrate2, Taxrate3, etc...
In my "Listpanel" the first column is a vertical checkbox. (One for each element in my lists) This is so I can select one item to bring up and edit, or select multiple values to delete "rows" or apply some kind of mass change to them.
What would be the best way to handle this under xPages to get this functionality? I tried making a table but am having the devil of a time to get the checkboxes to line up with their corresponding data items.
Views and dojo-grids seem to assume we're using a document for each row.....
This TableWalker may provide what you want http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Tutorial-Introduction-to-XPages-Exercise-23
It was created when XPages was all very new, so it's SSJS rather than Java. But if you're comfortable wiith Java, converting it probably won't be a challenge.
You could use a repeat control to display the values and build a table using the table row tags in the repeat. You would want to calculate the id of the checkbox to be able to take an action on that selected row. The repeat var would be just one of your multi-value fields and you use the index of the repeat to get the value for that row from the other multi-value fields.

How to make a MS Acess Report where you have one page per record?

I cannot figure this out for the life of me.
I want a report object where each page (no matter how big, small, etc) corresponds to one record in the underlying source query (each record corresponds to a Client along with some financial data).
I've tried grouping by Client, inserting page breaks, trying to integrate forms, etc. Nothing. Everything just combines together into one giant list -- there's no separation per page.
Select the Group Header and view Properties (F4). It should be named something like GroupHeader0. For the Force New Page attribute, select Before Section, After Section, or Before & After Section.
The hardest part of this for me was finding the correct item to click that has the Force New Page attribute -- it isn't the field itself, but the Section (which is named "GroupHeaderX" by default).

Loop/Iterate through a SQL query in Access (without VBA)

I have a rather unique problem that sits between the solution sets I've been able to find. I have a database containing tables that need iterative select queries with updating input parameters. As an example, I have an equipment table that contains a pairing of a technology with a sister tech, and the mechanisms through which they communicate:
Table Fields:
TechID1
TechID1Port
TechID2
TechID2Port
Example: Radio communicates (through its low/high band antenna) with Basestation (through its antenna port)
I have working SQL code that runs when users select TechID1 from a Combobox and the Combobox value filters the WHERE statement. However, I need to add levels of interaction based on a just added Combobox (values:1-n). The end goal is to iterate the query as done here, but without VBA, as this solution needs to be replicated for many Access tables and seamlessly transferred to Oracle/SQL Server in the medium-term.
Example of desired nth level results based on Radio selection: List of all techs that directly interact with Radio (plus associated info), with an appended list of all techs that interact with Basestation and other 1st level results (no duplicates or trackbacks to Radio), etc to the nth level.
For the above to work without VBA, I realize there is likely a series of similar/identical queries that need to run, with the ability to analyze only the row entries for the interaction level below the current run. One simple potential solution I've looked at is nested subforms that allow users to expand higher interactions as they wish, but I can't find a way to subform and filter a table onto itself.
Big thanks in advance!
J
Have you tried to use temporary tables.
You would be able to filter with different (sub)query's

Updating information in an Access table linked to SharePoint

I have a table in Access linked to a SharePoint list. The table is comprised of about 15 fields whose contents are originally pulled from another data source (in Excel format). There are an additional 10 or so fields after the original 15 that make up a questionnaire (added via SharePoint) that contain answers to questions about the first 15 fields.
The data in the first 15 fields needs to be updated periodically when new data from my external source is available to download. A lot of the information will remain the same, however some of the fields within each of the rows will change and need to be updated. It is also important that the 10 fields that contain the questionnaire are not modified at all during this process.
Is there a way for me to easily update the cells that have changed using an Update query or something similar? The data does have a unique identifier column (ID NUMBER) that is present on the current SharePoint list and the external data source.
I was thinking from a logical standpoint to put the new external data into a table, find the ID Number in the SP list and new external data, compare the values in the rest of the row on the SP list to the row of the external data, and if a value is different update the cell with the value from the external data. Not sure how to accomplish this using Access queries though.
I really appreciate any help at all! If you need more information, please let me know. If you think there's a more logical way to do this, please let me know your feedback!!
Here's how to get started:
http://workerthread.wordpress.com/2009/02/03/using-access-2007-to-update-sharepoint-lists/
After you get the connection set up, it's just a matter of writing the queries correctly. If you need to run multiple queries periodically, you can setup a form with buttons, and attach some VBA code to the buttons that runs the queries.
MS Access - execute a saved query by name in VBA