sql oracle search by multiple terms in business object report - sql

I am writing a report where i would like the end user to be able to search by multiple terms (ie. UK, CZ)
but my code it does not fetch any results
like #variable('2. COUNTRY (UK, CZ, AT or use % for all)')
It works when just using just one term (ie. UK) but not when the user tries to search for more than one value.
I have tried using different statements before the variable but still get no results.
Is a search like this possible?
I'm writing this for Business Objects 5
Thanks
Matt

You're trying to perform a wildcard search (by using the LIKE keyword) in combination with a prompt (I take it it's a multi-value prompt).
Lets go through a few possible scenarios:
Wildcard
Example: the user enters % in the prompt.
SQL translation: Country LIKE '%'
Result: the query returns all records due to the wildcard
Single-value
Example: the user enters UK in the prompt.
SQL translation: Country LIKE 'UK'
Result: the query returns all records with the Country column matching the value UK
Multiple values
Example: the user selects UK and AT in the prompt.
SQL translation: Country LIKE 'UK,AT'
Result: the query returns no records because there is no record that contains the value UK,AT (literally) for the Country column.
What you're trying to do, as far as I can determine, is to allow the user to select multiple values or skip the selection altogether and return all values (for which you used the combination of the LIKE keyword and % wildcard).
However, with multiple values, you need to use the IN keyword instead. In current versions of BusinessObjects (you're using a very old version), it's possible to make prompts optional.
As you don't have this feature, the only alternative is to create a universe condition in which you build a CASE around your #prompt function, to determine if the user entered a % or selected multiple values and then construct your WHERE clause accordingly.
Have a look at this article for an example how to build such a condition.

Related

how can we query prospect based on their field value?

I want to get a prospect list from Pardot using its API and only those prospects that have some field's value according to some rules.
For Example :
those prospects which have a website containing 'some string' and year_in_bussines > 3
Your best option here would be to create a dynamic list with your search criteria, then use the API to query prospects on your list with the query argument list_id.
Do keep in mind, dynamic lists are not updated instantly as prospects match/unmatch the criteria, there can be a delay.

Syntax for adding to this T-SQL Query

I built a simple UI for our users to query on our SQL Server DB. The UI started off as just one input field for a person's name. This field's input would be used to search on 3 fields on our database. The query up until now looks like this:
SELECT [Id], [Url], [PersonName], [BusinessName], [DOB], [POB], [Text]
FROM dbo.DataAggregate
WHERE CONTAINS([PersonName], 'NEAR((john, doe), 2, FALSE)')
OR CONTAINS([BusinessName], 'NEAR((john, doe), 2, FALSE)')
OR CONTAINS([Text], 'NEAR((john, doe), 2, FALSE)')
The above assumes the user queried on John Doe. The requirement for NEAR has to do with the format inconsistencies across data in our fields, but that's not relevant to this question, just an FYI.
Now, I've been instructed to add 4 more input fields in the UI to allow users to further tailor their query. These fields already exist in the DB records. My question is how do I add on to the above query for when the additional fields in the UI are used? Am I simply just adding several AND statements to it or OR statements to it?
Let me give an example to help you help me:
User Query:
Person Name: John Doe
DOB: 01/01/1900
Address: 123 Main St
POB: USA
Occupation: Worker
How would I add to my query to include the data for the other 4 input fields? Initially, to handle which input fields are populated and which are not, do I need IF statements in the query?
Each value in the other 4 input fields would need to be searched for in its own field, plus the Text field - i.e.
-The DOB would need to searched for in the DOB field and Text field
-The Address would need to searched for in the Address field and the Text field
etc.
It just seems there has to be a more efficient way to structure a query like this than having basically 5 sections similar to my above query separated by IF/AND/OR.
Thank you.
If you use parameters you can get round unpopulated inputs with this trick
Where
((#input1 is null) or (somefield = #input1))
Or / And
...
This is going to get messy real quick though, they'll come up with more inputs next week.
Other options
Grid with Filter capability.
Data dump for say Excel
Building the query programatically, with parameters.

Pentaho Report Designer: Passing list of values as parameters to report

Report Objective: Performance analysis of players by statistics comparison
Desired Report Layout
Please refer to the layout and read on. The player names need to be added from a list which could be anything like entry text box, multicheck box, dropdown etc. If I select Jake Tyler in this list, the report should refresh and show me the statistics from him. Then when I select Adam Smith, he should show up as the next entry below Jake with his respective stats.
I know how to pass individual players as parameters in the query using Pentaho parameters and tagging them in the condition using SQL as:
'where PlayerName = ${playername}'
But I need to know how to pass multiple player names in a similar fashion to generate this report using multivalue String parameters.
Can you please please guide me on how to do this? I have heard things like x-actions which could work but I don't know how to use that. I am sure this will help a lot of people who are trying to achieve something similar which might seem complex to them.
You can simply use where PlayerName IN (${playername}).
The list should be correctly passed from the parameter to query.
and the parameter also should get data correctly.
Eg:
select 'Jake Taylor' as pn
union
select 'Adam Smith' as pn
union
select 'Chris Lawson' as pn
or
select distinct column_name from table_name
this can be sent to parameter (in Add parameter window) and your main query can be prepared as I explained above using IN
NB: You can use only Display types like: Multi value list, Multi selection box etc. Not drop downs which pass only single value.

Localisation of country names

As part of addresses I am storing in my SQL database country codes (e.g. US, DE,...). I then have another table (with two columns) in my database which translates the country codes to the English language names of the respective countries.
If I want to make the site multi-language, I could expand this translation table adding country names in other languages than English.
I was wondering if there is another method which does not involve modification of the database, e.g. using gettext to translate the English country names?
The typical way to handle this is to change the table structure to have three columns, instead of two:
Language
CounryCode
FullName
Whenever you query the database, you would provide the current language.
You then have to change your code to include the additional language key in any queries.
Depending on how you are going to keep track of the current language, you would also use a view or user defined function.
You don't want to use automated translation, since the name of a country like "China" could turn into the equivalent of "porcelain".

How to design a database table structure for storing and retrieving search statistics?

I'm developing a website with a custom search function and I want to collect statistics on what the users search for.
It is not a full text search of the website content, but rather a search for companies with search modes like:
by company name
by area code
by provided services
...
How to design the database for storing statistics about the searches?
What information is most relevant and how should I query for them?
Well, it's dependent on how the different search modes work, but generally I would say that a table with 3 columns would work:
SearchType SearchValue Count
Whenever someone does a search, say they search for "Company Name: Initech", first query to see if there are any rows in the table with SearchType = "Company Name" (or whatever enum/id value you've given this search type) and SearchValue = "Initech". If there is already a row for this, UPDATE the row by incrementing the Count column. If there is not already a row for this search, insert a new one with a Count of 1.
By doing this, you'll have a fair amount of flexibility for querying it later. You can figure out what the most popular searches for each type are:
... ORDER BY Count DESC WHERE SearchType = 'Some Search Type'
You can figure out the most popular search types:
... GROUP BY SearchType ORDER BY SUM(Count) DESC
Etc.
This is a pretty general question but here's what I would do:
Option 1
If you want to strictly separate all three search types, then create a table for each. For company name, you could simply store the CompanyID (assuming your website is maintaining a list of companies) and a search count. For area code, store the area code and a search count. If the area code doesn't exist, insert it. Provided services is most dependent on your setup. The most general way would be to store key words and a search count, again inserting if not already there.
Optionally, you could store search date information as well. As an example, you'd have a table with Provided Services Keyword and a unique ID. You'd have another table with an FK to that ID and a SearchDate. That way you could make sense of the data over time while minimizing storage.
Option 2
Treat all searches the same. One table with a Keyword column and a count column, incorporating SearchDate if needed.
You may want to check this:
http://www.microsoft.com/sqlserver/2005/en/us/express-starter-schemas.aspx