Populate a form from a select list - plsql

I have tried multiple attempts at populating a report from selecting a value in a select list. I have come close but not close enough for the right answer. Does anyone have a solution?
Here is the code
Currently I have a select list that has the option of choosing an employees track and the employees track is populated in the select list based on :app_user.
List of Values
List of values definition:
SELECT track_name AS display_value,
track_id AS return_value
FROM ref_track
ORDER BY 1
Source Value for select list:
SELECT "REF_TRACK"."TRACK_NAME" AS display_value,
"REF_TRACK"."TRACK_ID" AS return_value
FROM "REF_STAFF",
"REF_PLAN",
"WORK_ITEM",
"REF_RELEASE",
"REF_TRACK"
WHERE "REF_RELEASE"."RELEASE_ID" = "REF_PLAN"."RELEASE_ID"
AND "REF_TRACK"."TRACK_ID" = "REF_PLAN"."TRACK_ID"
AND "WORK_ITEM"."WR_ID" = "REF_PLAN"."WORK_ITEM_ID"
AND Nvl("REF_STAFF"."REF_STAFF_TRACK_ID", "REF_PLAN"."TRACK_ID") =
"REF_PLAN"."TRACK_ID"
AND (( "REF_STAFF"."STAFF_USER_ID" = :APP_user ))
I now have a report beneath it that is being populated when the page loads that also generates data based on :App_user.
Report Source Code:
SELECT "REF_PLAN"."PLAN_ID" "PLAN_ID",
"REF_PLAN"."WORK_ITEM_ID" "WORK_ITEM_ID",
"REF_PLAN"."TRACK_ID" "TRACK_ID",
"REF_PLAN"."PLANNED_TOT_HRS" "PLANNED_TOT_HRS",
"REF_PLAN"."PLAN_START_DATE" "PLAN_START_DATE",
"REF_PLAN"."PLAN_END_DATE" "PLAN_END_DATE",
"REF_PLAN"."COMMENTS" "COMMENTS",
"REF_PLAN"."RELEASE_ID" "RELEASE_ID",
"WORK_ITEM"."WR_ID" "WR_ID",
"WORK_ITEM"."WR_NUM" "WR_NUM",
"REF_RELEASE"."RELEASE_ID" "RELEASE_ID2",
"REF_RELEASE"."RELEASE_NUM" "RELEASE_NUM",
"REF_TRACK"."TRACK_ID" "TRACK_ID2",
"REF_TRACK"."TRACK_NAME" "TRACK_NAME",
"REF_STAFF"."REF_STAFF_TRACK_ID" "REF_STAFF_TRACK_ID",
"REF_STAFF"."STAFF_USER_ID" "STAFF_USER_ID"
FROM "REF_STAFF",
"REF_PLAN",
"WORK_ITEM",
"REF_RELEASE",
"REF_TRACK"
WHERE "REF_RELEASE"."RELEASE_ID" = "REF_PLAN"."RELEASE_ID"
AND "REF_TRACK"."TRACK_ID" = "REF_PLAN"."TRACK_ID"
AND "WORK_ITEM"."WR_ID" = "REF_PLAN"."WORK_ITEM_ID"
AND Nvl("REF_STAFF"."REF_STAFF_TRACK_ID", "REF_PLAN"."TRACK_ID") =
"REF_PLAN"."TRACK_ID"
AND (( "REF_STAFF"."STAFF_USER_ID" = :APP_USER ))
AND "REF_PLAN"."TRACK_ID" = :P47_TRACK_LIST
I tried adding this line to pick from the select list.
Is there any way to manipulate this code to be able to select a track from my list and populate data based on the track selection in my report. I would also like to let you know that my select list values are based on a submit page. Please let me know if you can help me. Its frustrating when I look at something for a complete day and cant figure the code out. Also, if there is any other way around it or other options to explore please let me know.

If you want the report to update when you change the selected value of the select list, you can do this in 2 ways. But both come down to the same principle: your selected value has to be submitted to the session state in order for the report to filter on it.
Solution 1: have the select list submit/redirect the page. This will submit the value of your select list to the session, and reloads the page. With the redirect you will fill up the browser history though: select a value a couple of times, and you use 'back' on the browser to navigate back through the choices you made. Or use a submit, this'll reload the page too, but won't fill the history as much. There'll still be one extra history entry though (initial, and first reload, following reloads are not in history).
Find the option by editing your select list, going to the Settings region, and change the page action when value changed.
Solution 2: refresh the report region through a dynamic action. This will not reload the page, it'll 'refresh' just your report. This might be the most userfriendly, it depends if you like a page reload or not :)
You'll need a dynamic option, configured like this:
With these true action details:
And most important, to make sure your selected value is submitted to the session state: add the item to the list of items to be submitted when the report is refreshed.
I set up an example here

Related

Cognos Report with Multiple value prompts

I currently have a report that have 9 value prompts items,so far I can only load the prompts with the values that the user can select from, however the desired results should be based on user selection for example if user selected from value prompt1 then only values that are related to value prompt1 should be populated in other value prompts and so on. Your assistance in this regards will be highly appreciated, Thanks in advance.!!!
If I understand correctly, you want ValuePrompt2 to populate after a value is selected in ValuePrompt1 and be filtered by that selection. You want ValuePrompt3 to populate after a value is selected in ValuePrompt2 and be filtered by that selection and the selection in ValuePrompt1. Etc.
Given object relationships that follow this pattern: QueryN : ValuePromptN : ParamN : QueryItemN
You need to set up Param1 as a Cascade Source for ValuePrompt2. Cognos figures out the filtering for this.
You also need to set up Param2 as a Cascade Source for ValuePrompt3. But that won't filter ValuePrompt3 by the selection(s) in ValuePrompt1. To do that, you'll need to make Query3 more specific by adding filters that use Param1 and Param2.
QueryItem1 = ?Param1?
QueryItem2 = ?Param2?
(For clarity, you'll probably want to filter Query2 in a similar manner.)
So when you get to ValuePrompt9, it will be sourced from Query9 and have these filters...
QueryItem1 = ?Param1?
QueryItem2 = ?Param2?
QueryItem3 = ?Param3?
QueryItem4 = ?Param4?
QueryItem5 = ?Param5?
QueryItem6 = ?Param6?
QueryItem7 = ?Param7?
QueryItem8 = ?Param8?
...and its Cascade Source property will be set to Param8.
Consider the design of your queries. A prompt page like you propose may be very slow.
Updated based on new requirement...
If you need to select the values in any order, all of the source queries should have filters to use all of the other parameters and none of the prompts should have the cascade source property set. Then, create a new prompt (PromptNH) for each prompt (PromptN), set its Cascade source property to the related parameter (ParamN), set the Auto-submit property of the source prompt (PromptN) to Yes, and hide the prompt (PromptNH). This forces a reprompt after each selection. Keep in mind that in this scenario the prompt page will quickly filter itself into an unusable state.
Thanks for all the valuable inputs, I only needed to enter a measure in my query so that the filtering can only happen where the is volume in those filters

Table input for view

I would like to have the user enter order items on my order form as a table where they input the Qty and Prod #. I've not programmed with that type of field so a blank line would initially display for a new order. They would type a Qty and an item number in the fields and hit enter. When they hit enter from either field, what do I program to check the validity of the two fields. Plus I need the item number to be a drop down/type ahead field. Does anyone have an example of this type of thing they could send me? It would be looking at a view in the product catalog db. Also, after they enter an item to order, that "doc" should get stored/saved and a new blank line should open up.
What type of control do I need to use and should these items be stored in their own form or on the main order document? Could use some guidance here. Thanks.
The question you have is a little broad but I will make a couple suggestions if I can.
You have the main order doc. Then a repeat control with each item. Filter each item by a uniqueID that allows you to join the main doc to the child docs. Each item should be a separate document. You then need to make the items in the repeat control editable.
There is a lot of things going on here and I think you need to get started somewhere. I think the first step is to do a repeat control with response documents.Xpages, Inherited documents in view panel by using #Unique

SQL Server : sum of 2 columns in each row display

I am using SQL Server. I have 2 columns Passed students and Failed Students in my database.
How to write a query which displays both these columns along with a third column which is Total Students which displays the sum of the entries in the row?
EDIT
It is not allowing me to ask another question.So,posting it here:
I have a hyperlink field in my gridview as below:
[Please refer comment for the code.For some reason it doesn't get posted here.]
Its basically a runId.When I click on this hyperlink I am redirected to a page called RunAnalysis.I want to access the value of the runId which was clicked in this page.
I was thinking of using query string but there is no event as far as I know that is fired on click of the hyperlink.
My question is how do I access the runId value in this page ? Can someone tell me if some event is fired so that I can send a query string.
Thanks.
You haven't given a lot of background information so I am assuming many things in my response.
Here is a simple aggregated result set:
SELECT SUM(Passed) AS [Passed],SUM(Failed) AS [Failed],COUNT(*) AS [TotalStudents]
FROM dbo.Students
Now if there is some grouping you want to do then you would add a GROUP BY clause like so...
I'm creating a new column because I don't know your schema:
SELECT GradeLevel, SUM(Passed) AS [Passed],SUM(Failed) AS [Failed],COUNT(*) AS [TotalStudents]
FROM dbo.Students
GROUP BY GradeLevel
ORDER BY GradeLevel

Choosing from multiple query results to display in a single form

I have a form that submits parameters to a query, then opens the resulting record in another form. The problem is, whenever there is more than one record it automatically puts the first one into the from without any kind of option to choose the record I want. I have a macro set up on the search button on the first form that submits the parameters to the query and then displays it in the second form, I've tried to set up another macro in between the two, but I don't know if it's possible to set up the expression creator to check the number of rows resulting from a query. Is it possible to modify the query to create a prompt to choose which record I want? Or should I change something else?
This is the query:(automatically created by access)
SELECT CHILD.CHILD_L_NAME, CHILD.CHILD_F_NAME, CHILD.DOB, CHILD.GENDER, CHILD.DAYS_IN_CARE,
CHILD.HOURS_PER_DAY, CHILD.ENROLLMENT_DATE, CHILD.CHILD_ADDRESS, CHILD.CHILD_CITY,
CHILD.CHILD_ZIP, CHILD.CHILD_STATE, CHILD.CLASSROOM, CHILD.SNACK, CHILD.LAST_UPDATED, CHILD.CIN
FROM CHILD
WHERE (((CHILD.CHILD_L_NAME)=[Forms]![Search]![L_NAME]) AND
((CHILD.CHILD_F_NAME)=[Forms]![Search]![F_NAME])) OR
(((CHILD.CHILD_L_NAME)=[Forms]![Search]![L_NAME]) AND
((CHILD.DOB)=[Forms]![Search]![DOB])) OR
(((CHILD.DOB)=[Forms]![Search]![DOB])) OR
(((CHILD.CHILD_L_NAME)=[Forms]![Search]![L_NAME]));
If I understood well your problem and you use VBA it's quite easy to do.
You can create a reduced query based on the query you're creating with the button. This new query should include all and only the fields that allows you to discriminate beetwen the records to show in the 2nd form.
For instance it could include LastName, FirstName and classroom to select between children with same full name.
You can count the number of records of this 2nd query and if greater than 1 it means that you have more than one children to show.
So you can use this 2nd query to populate a combo-box or a listbox for selecting the record you really want to show.
When number of records is 1 you can simply skip the listbox population using an if statement on recordcount.
Next step is opening the form with the selected (or unique) record.
Bye

Foxpro combobox binding from database

I have Form1. I have table "Category", now I want to display all CategoryName in to combobox cbbCategory in Form1, the category names data are retrieved from Category table, how can I do this?
There are several ways you can do this, from querying the table into an array, writing as a SQL query, etc and setting up the properties.
What I would suggest for a start is this. Open your form.
Right-click anywhere in the form and pick "Data Environment".
If the category table is NOT already shown in the window, right-click and select Add. It will prompt you to pick a table and select your category table. Then close the data environment.
Now, put a combobox on your form if you have not done so already.
Right-click on the combobox and click "Builder". It will walk you through the selection process to get what you want. Start with picking the table... your category table. Then it has picker next to it to identify which column(s) you want to be displayed in the combobox. If your category table has both an ID and a description, I would pick your description FIRST, then the internal ID column second (so we can hide the second column if you dont want to actually show it).
Click on the second tab for "Style", and to clarify the difference between a "Drop-down Combo" vs "Drop-down List" is that a combo will default show you available choices, but if one is not available, allows a user to manually enter a new one which you might want to allow adding to your master category lookup table. "Drop-down List" is fixed to only allow the user to pick an entry from those available and nothing else.
Next, click on the Layout tab. This allows you to adjust the columns widths to see/hide what it will look like during drop-down mode (just stretch/shrink the columns)
Finally, the "Value" tab. It is asking for which column from those you selected to be available do you want to store behind-the-scenes. If an ID column, so be it... if the description, that's fine too. You can leave the last "Field Name" blank for now and it will just store whatever is selected into the comboboxes "Value" property... from which you can do whatever you need to in next phase of you app.

Resources