OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Parameter Query - Sinlge parameter multiple values

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
steve-waters
Newbie
Newbie


Joined: 06 Jan 2008
Posts: 2

PostPosted: Sun Jan 06, 2008 6:24 pm    Post subject: Parameter Query - Sinlge parameter multiple values Reply with quote

Hi,

I am just trying to put together a simple app that will run a report based on a parameter query that can take a list of values.

e.g. select loans
where loannumber in [123,1231,124,432,34,235,235,25]

(above is not the sql being used ust to give you idea)

I have been able to make a query that has a parameter for loan number and accepts a single value, but i have not been able to work out how to input many values and then return the results.

Thanks,
Steve
Back to top
View user's profile Send private message
Sliderule
Super User
Super User


Joined: 29 May 2004
Posts: 2474
Location: 3rd Rock From The Sun

PostPosted: Sun Jan 06, 2008 7:21 pm    Post subject: Reply with quote

Steve:

The answer . . . assuming you are using the Query GUI ( Graphical User Interface ) is rather simple . . . BUT . . . it does NOT include using an IN clause.

In the example below . . . I defined a Query . . . and the user is prompted to enter a maximum of six ( arbitrary number for example purposes only ) entries. You can expand this to whatever meets your needs. Each prompt is 'defined' by using the OR capability.

Since, the ORDER that the prompts are displayed is 'alphabetical' . . . and . . . it canNOT begin with a number and must be one word . . . I elected to start each with a :Q followed by an underscore followed by a number ( 01 to 06 ) followed by an underscore followed by a description, change this to meet your needs.

The user may 'fill-in' the prompt(s) for as many as desired . . . and . . . press the Next button to enter the next Parameter. When as many as desired are entered . . . pressing the OK button is needed. I hope the graphic below will clear things up for this simple example.



Please note, if you were to produce this same query with SQL . . . it would look like:
Code:
SELECT
      "group_time",
      "descript",
      "descript2"
FROM "grptime" AS "grptime"
WHERE ( ( "group_time" = :Q_01_First_Entry )
      OR ( "group_time" = :Q_02_Second_Entry )
      OR ( "group_time" = :Q_03_Third_Entry )
      OR ( "group_time" = :Q_04_Fourth_Entry )
      OR ( "group_time" = :Q_05_Fifth_Entry )
      OR ( "group_time" = :Q_06_Sixth_Entry ) )
ORDER BY "descript2" ASC

I hope this helps, please be sure to let me / us know.

Sliderule

Thanks to add [Solved] in your first post title (edit button) if your issue has been fixed / resolved.
Back to top
View user's profile Send private message
steve-waters
Newbie
Newbie


Joined: 06 Jan 2008
Posts: 2

PostPosted: Mon Jan 07, 2008 2:46 pm    Post subject: Reply with quote

Thanks for the reply. Close but no cigar Smile

The solution is close to what I was seeking and a good tip to have in my armoury however it is not what I need to happen for this report/query.

The query is to be setup so user can enter a varying number of items, 1 -> n. Which is why I was hoping to be able to pass a list to the query rather than have individually named items.

Thanks,
Steve
Back to top
View user's profile Send private message
Sliderule
Super User
Super User


Joined: 29 May 2004
Posts: 2474
Location: 3rd Rock From The Sun

PostPosted: Mon Jan 07, 2008 4:04 pm    Post subject: Reply with quote

Steve:

You said:
Steve wrote:
The query is to be setup so user can enter a varying number of items, 1 -> n. Which is why I was hoping to be able to pass a list to the query rather than have individually named items.

¿ ¿ ¿ Have you attempted this technique, for example, and, only entered three values, rather then six . . . it works exactly as you want ? ? ? And, the user entered a value, can press the Next button, OR, the Enter Key to be able to enter the next value. The only difference is . . . the user never has to press a comma key. You can define . . . a large number of Parameters . . . I tried it with 33 . . . no problem.

The user may enter as many, or as few, as needed.

I hope this helps, please be sure to let me / us know.

Slideurle

Thanks to add [Solved] in your first post title (edit button) if your issue has been fixed / resolved.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group