Is it possible to create a parameter query in openoffice base? - openoffice-base

In access it is very easy to use it:
BETWEEN [minimum] AND [maximum]
But what is the syntax in openoffice base?

There are two ways to do this. First is to have the query ask for user input. Colons are used to indicate user-input parameters, like this:
BETWEEN :MINIMUM AND :MAXIMUM
Second is to use a one-row filter table. Tie the user's form to this one row by making the form source something like SELECT * FROM "Filter" WHERE "FilterID" = 1. Then the user will enter the dates into the filter table, and the query will have a join to the filter table to determine the dates.

Related

How to match a substring exactly in a string in SQL server?

I have a column workId in my table which has values like :
W1/2009/12345, G2/2018/2345
Now a user want to get this particular id G2/2018/2345. I am using like operator in my query as below:
select * from u_table as s where s.workId like '%2345%' .
It is giving me both above mentioned workids. I tried following query:
select * from u_table as s where s.workId like '%2345%' and s.workId not like '_2345'
This query also giving me same result.
If anyone please provide me with the correct query. Thanks!
Why not use the existing delimiters to match with your criteria?
select *
from u_table
where concat('/', workId, '/') like concat('%/', '2345', '/%');
Ideally of course your 3 separate values would be 3 separate columns; delimiting multiple values in a single column goes against first-normal form and prevents the optimizer from performing an efficient index seek, forcing a scan of all rows every time, hurting performance and concurrency.

Modified User Input value in Snowflake

I have a requirement to read the string passed by the user and later modify the string to get a required format and pass it as a where condition to the view.
Example
the user inputs a list of material numbers separated by commas '12345,78990,456789'. this string has to be modified to
MATCH("BOM_PATH",'12345') OR MATCH("BOM_PATH",'78990') OR MATCH("BOM_PATH",'456789')
So basically I need to separate all materials from the input string and search for those individual materials in a field called BOM_PATH which holds the value like '12345:098765:784526'
I tried using Snowflake SQL UDTF but it doesn't support variables or multiple SQL statements and Snowflake view doesn't support parameters.
So please suggest me a way on how to implement this in Snowflake.
You can do it by using ARRAY_CONTAINS() function with the input converted to the array by STRTOK_TO_ARRAY().
create or replace table bom_table(BOM_PATH varchar);
insert into bom_table (BOM_PATH)
values
('12345'),
('55555'),
('77778'),
('78990');
select * from bom_table
where
ARRAY_CONTAINS(BOM_PATH::variant,STRTOK_TO_ARRAY('12345,78990,456789',','));
Alternatively, if your BAM_PACH is a delimited list too - use ARRAY_INTERSECTION() and ARRAYS_OVERLAP()
insert into bom_table (BOM_PATH)
values
('12345:098765:784526'),
('12346:098766:784527'),
('12345:098765:777777'),
('12399:098765:777773');
select ARRAY_INTERSECTION(STRTOK_TO_ARRAY(BOM_PATH,':'),STRTOK_TO_ARRAY('12345,78990,456789',',')) from bom_table
where ARRAYS_OVERLAP(STRTOK_TO_ARRAY(BOM_PATH,':'),STRTOK_TO_ARRAY('12345,78990,456789',','));

How to display all records in query when using a criteria

I have created a query and i have a field called Department. I have added a criteria to that field that allows user interface, when you run the query it asks for you to enter the department name you want to display. If I choose to display all departments records what can I put in to display all departments? I remember something about entering * to display all records but this does not want to work
* only works with text fields and even then only when used with LIKE not =.
This is what I would use as filter:
[Department]=IIF([MyParameter]='',[Department],[MyParameter])
This should evaluate to always true when the Parameter is left empty.

MsAccess - How to make an ID field fill in other fields in the form?

Problem:
I'm trying to make it so when a numerical field is filled in with a certain ID it fills in the other fields accordingly to what the first field was filled with. So if a person were to type in their ID it would populate it with their name accordingly.
Example:
But upon ID/numerical change I want it to do something like this:
Prior knowledge that may or may not help:
-I know this is possible with combo boxes but having a combo box with 2k-8k entries seems absurd
-I don't really think subform is optimal for this situation
-I think you can do this with "=DLookup" but I don't exactly understand how to pull it off
Please and thanks for any help. All is appreciated greatly!
Some built-in Access mechanisms:
Search field in the Navigation bar of the form.
Find feature (Ctrl-F).
Alternatively, with VBA you can use your own UI design and have more control:
Obtain the desired ID from the UI in whatever way you like - a textbox, a button and a popup, etc. Don't use a textbox that is bound to the actual ID field (ID fields should be read-only and you shouldn't use an edit field for a search field - keep them separate).
In VBA, obtain the ID that user searched for and then jump to that record using code like this:
Me.RecordsetClone.FindFirst "StudentID = " & studentID
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
You don't need VBA for this. Simply add the Student ID textbox value as a parameter the form's query and let it filter the results according the ID provided.
The query should be something like this:
PARAMETERS [Forms]![YourMainForm]![YourIdTextBoxName] Long;
SELECT *
FROM YourTableName
WHERE ((([Student ID])=[Forms]![YourMainForm]![YourIdTextBoxName]));
When you add a new ID, requery the form to see the results.
Me.Requery

nested if statment with so many text conditions ERROR

this is my data table
I'm writing this formula in openoffice not excel, that's why you will see ";" instead of ","
my questions is that I'm trying to put the currency of each country's capital name, and I did it but the thing is that I'm unable to make more than 42 conditions!!!!!
Is there another way or another formula can I use???
Here is the formula I did, and it's working
=IF(D3="AMSTERDAM";"EUR";IF(D3="FRANKFURT";"EUR";IF(D3="OSLO";"NOK";IF(D3="COPENHAGEN";"MULTI";IF(D3="ALICANTE";"EUR";IF(D3="BARCELONA";"EUR";IF(D3="BERLIN TXL";"EUR";IF(D3="VILNIUS";"EUR";IF(D3="BRUSSELS";"EUR";IF(D3="CATANIA";"EUR";IF(D3="DUSSELDORF";"EUR";IF(D3="FARO";"EUR";IF(D3="GRAN CANARIA";"EUR";IF(D3="HELSINKI";"EUR";IF(D3="MALAGA";"EUR";IF(D3="MUNICH";"EUR";IF(D3="PARIS CDG";"EUR";IF(D3="RIGA";"EUR";IF(D3="SANTA CRUZ PALMA";"EUR";IF(D3="SEVILLA";"EUR";IF(D3="TENERIFE";"EUR";IF(D3="BUDAPEST";"HUF";IF(D3="ANTALYA";"TRY";IF(D3="GAZIPASA";"TRY";IF(D3="ISTANBUL";"TRY";IF(D3="BERGEN";"NOK";IF(D3="STAVANGER";"NOK";IF(D3="STAVANGER VIA ESBJERG";"NOK";IF(D3="LONDON CITY";"GBP";IF(D3="LONDON LHR";"GBP";IF(D3="LONDON STN";"GBP";IF(D3="MANCHESTER";"GBP";IF(D3="FUERTEVENTURA";"ISK";IF(D3="LANZAROTE";"ISK";IF(D3="PORTO SANTO";"ISK";IF(D3="GLASGOW";"SCP";IF(D3="GDANSK";"PLN";IF(D3="CLUJ­NAPOCA";"RON";IF(D3="STOCKHOLM";"SEK";IF(D3="PRAGUE";"CZK";""))))))))))))))))))))))))))))))))))))))))
I'd suggest you use a table in another section of your spreadsheet then use VLOOKUP to match the currency to your country.
=VLOOKUP(D3;Currency_Table;2;FALSE}
Which is lookup D3 in the table named Currency_Table and return the exact match (from FALSE) in the second column which will give you your currency.
Or if you want the formula to exist without dependency upon another table you could use something like:
=VLOOKUP(D3;{"AMSTERDAM"\,"EUR";"FRANKFURT"\,"EUR";"OSLO"\,"NOK"; etc...};2;FALSE}
NB: I've added an escape \ before the comma because I'm assuming you are from a language area that uses , as a decimal by your language settings I'm assuming you'll need that in your array for that to work.

Resources