Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Closed]Dynamic query with field names listed in listbox

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[Closed]Dynamic query with field names listed in listbox
 Login/Join
 
Gold member
posted
Hi All,

I gone through many post and I didn't get exactly what I wanted.

I have a list box with list of values which are actually fields from different tables.

I need to write a dynamic SQL query with those fields selected in the list box.

If user has selected values from the listbox(it might be fields from single table or multiple tables). Say if the selected fields are from the single table its going to be a simple select query without any joins.

I am trying this to avoid unnecessary joins to tune the performance.

Can someone suggest me with ideas.

Thanks,
Ramya
Webfocus 8105

This message has been edited. Last edited by: Ramya,
 
Posts: 73 | Registered: January 02, 2012Report This Post
Platinum Member
posted Hide Post
Hey .

use following blog:-

http://pravinsinghwebfocus.blo...-column-control.html

thanks
Neelima


WebFocus 8104,8204
Excel/PDF/HTML/HTMLTABLE/XML/ALPHA/GIF file/GRAPH/Active technologies
 
Posts: 186 | Location: INDIA | Registered: July 11, 2013Report This Post
Gold member
posted Hide Post
Hi Neelima,

Yes the blog gives me the approach what exactly is required.

But there the number of fields are limited. So he has used so many number of variables.

In my case I have 10 tables with 100 fields in each, So I don't think this approach is going to help me out.

Thanks,
Ramya


WebFocus 7702
HTML
 
Posts: 73 | Registered: January 02, 2012Report This Post
Platinum Member
posted Hide Post
A report user is going to scroll a dropdown to pick from a list of one thousand possible options? That seems excessive and not user friendly. just my two cents. Smiler


WebFOCUS 7.7.05 (Someday 8)
Windows 7, All Outputs
In Focus since 1983.
 
Posts: 103 | Registered: April 27, 2011Report This Post
Platinum Member
posted Hide Post
quote:
seems excessive and not user friendly.

Me agree much so. Perhaps a UX / UI designer is you need?

Kofi


Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
 
Posts: 106 | Registered: April 06, 2009Report This Post
Platinum Member
posted Hide Post
Or meebe you be needing guided adhoc?


Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
 
Posts: 106 | Registered: April 06, 2009Report This Post
Gold member
posted Hide Post
quote:
meebe you be needing guided adhoc

Hi Kevin,

User is not going to select all the 100 fields at once. Each user may want to select a minimum number of fields according to what is required for them.

one option I am thinking is,We can write a query with all the 10 tables and only the select list can differ according to what the user is selecting.

So now a question is,If a user is selecting fields from only one table, then its going to take a long time for the user to get the result as I have used all the 10 tables in the query.

I am just looking out for some options.

Thanks,
Ramya
WebFocus 8105,HTML,Javascript
 
Posts: 73 | Registered: January 02, 2012Report This Post
Master
posted Hide Post
Ramya,

I do not have a complete solution for you, but I have an idea that might help.

A listbox is an HTML select tag. A select tag has a "text" property and a "value" property. Text is what the user sees in the listbox. Value is not seen by the user and can be the same as the text property or it can be different.

You could put the field names in the text property, and the name of the tables they belong to could go in the value property. So when a user selects a field name you can check the value property to get the table name.

After collecting all the field and table names, you can delete any duplicate table names and then write your dynamic query.

Example code:

-HTMLFORM BEGIN
<script type="text/javascript">
function build_listbox() {
	var fields_and_tables = {
	  "records" : [
	     { "fieldname" : "customer_id", "tablename" : "customer_table" },
	     { "fieldname" : "customer_name", "tablename" : "customer_table" },
	     { "fieldname" : "product_id", "tablename" : "product_table" },
	     { "fieldname" : "price", "tablename" : "product_table" },
	     { "fieldname" : "in_stock", "tablename" : "product_table" },
	     { "fieldname" : "shipping_address", "tablename" : "customer_table" },
	     { "fieldname" : "special_instructions", "tablename" : "notes_table" }
	  ]
	};

	var listbox = document.getElementById("listbox1");

	for (i = 0; i < fields_and_tables.records.length; i++) {
		var option = document.createElement("option");
		option.text = fields_and_tables.records[i].fieldname;
		option.value = fields_and_tables.records[i].tablename;
		listbox.add(option);
	}
}

function show() {
  var x = document.getElementById("listbox1");
  alert('text = "' + x.options[x.selectedIndex].text + '", value = "' + x.options[x.selectedIndex].value + '"');
}
</script>
<body onload="build_listbox();show()">
<select id="listbox1" onchange="show()"></select>
</body>
-HTMLFORM END


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Gold member
posted Hide Post
quote:
all the field and table names, you can delete any duplicate table names and then write your dynamic query.


Hi Squatch,

That's the great idea. Will give a try and let you know on how it goes.

Thanks,
Ramya
WebFocus 8105,HTML,Javascript
 
Posts: 73 | Registered: January 02, 2012Report This Post
Gold member
posted Hide Post
quote:
select tag has a "text" property and a "value" property. Text is what the user sees in the listbox. Value is not seen by the user and can be the same as the text property or it can be different.You could put the field names in the text property, and the name of the tables they belong to could go in the value property. So when a user selects a field name you can check the value property to get the table name.After collecting all the field and table names, you can delete any duplicate table names and then write your dynamic query.



Hi Squatch,


Since the final listbox from which I am pulling values to report is dynamic, I am unable to predefine the fields with 'display text' and 'value'. If its static, your suggestion works perfectly.

Any ideas on how to handle this in dynamic listbox?

Thanks
Ramya
Webfocus 8105, HTML, Javascript
 
Posts: 73 | Registered: January 02, 2012Report This Post
Master
posted Hide Post
quote:

Any ideas on how to handle this in dynamic listbox?

Yes.

You need to create a WebFOCUS report that will return field names and table names. Your data source might be able to do this, but if it cannot do this, you could create a new data source with all the field names and table names.

The WebFOCUS report needs to return this data in XML format. I will use the CAR file as an example. Pretend MODEL is field names and COUNTRY is table names:

TABLE FILE IBISAMP/CAR
PRINT 
     CAR.CARREC.MODEL
     CAR.ORIGIN.COUNTRY
ON TABLE PCHOLD FORMAT XML
END

When you have created the XML report that returns field names and table names, create your list box in App Studio. Then follow these steps:

1. In the "Requests & Data sources" panel, New --> External Request --> WebFOCUS Procedure. Select the WebFOCUS XML report you created.

2. Click on your list box, then open the "Settings" panel. Dynamic --> Explicit (Requests panel). Select the WebFOCUS XML report from the "Request" drop down control. For "Value from" select the field that contains your table names (COUNTRY in my example above). For "Display from" select the field that contains your field names (MODEL in my example above). Select a sort order of "Ascending".

Then you will need a way to look at all the user selected fields and get all the unique table names. You should be able to do that with JavaScript.

This message has been edited. Last edited by: Squatch,


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Gold member
posted Hide Post
Squatch,

I got it. But we don't populate the listbox from external procedure. Its just 3 listboxes in the left and user selects the value from all 3 and sends it to the final listbox.

Same way you suggested, I have tried giving two different values one in display text and other in value text in source listboxes in the left.

When I pass it to the right final listbox, I can still pass either text or value. I am just trying some luck using hidden objects where I will pass both text and value and manipulate it when taking it to report.

Kindly suggest if this work around will do

Thanks,
Ramya
WebFocus 8105, HTML, Javascript
 
Posts: 73 | Registered: January 02, 2012Report This Post
Master
posted Hide Post
When you wrote earlier that the final listbox was dynamic, I thought you meant WebFOCUS dynamic.

If you have two different values for display text and value text in source listboxes, you should be able to copy them both to the final listbox.

Like this:

var listbox = document.getElementById("final_listbox_on_right");

// Pass both display text and value text to final listbox on right
var option = document.createElement("option");
option.text = (display text from source listbox on left side);
option.value = (value text from source listbox on left side);
listbox.add(option);

The "text" is what is between the OPTION opening and closing tags. But it looks like WebFOCUS listboxes add a "displaytext" attribute as well:

<OPTION value=Red displaytext="Apple">Apple</OPTION>


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Gold member
posted Hide Post
quote:
listbox.add(option);


Thanks a lot SquatchSmiler

That got worked. I got to know a simple new thing today. When we add an item to listbox, both text and value attribute gets added.

Thanks,
Ramya
WebFocus 8105,HTML,Javascript
 
Posts: 73 | Registered: January 02, 2012Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Closed]Dynamic query with field names listed in listbox

Copyright © 1996-2020 Information Builders