What is the sql statement for doing this?

Hi,
I am currently doing a simple search engine that allows a user to key in a filename and display all the files' name close to keyed filename(the first two letters are the same).What is the proper sql statement to select from Document according to DocumentType and the first two letters of the filename? Am i doing it the right way? I am currently use Access 2002, dunno if it will affects me.Thanks in advance
[What i did]
String filename="doc,txt"
SELECT DocumentType from Rule where UserType='1' and Action='Search';
DocumentType=1,5,9,13,17,21,25,29,33,37,41,45 // This is all the document Type the user can see.
Next i used StringTokenizer break the DocumentType.
DocumentType[0]=1;
DocumentType[0]=5;
SELECT * from Document where DocumentType and Name <<< I want to select from Document according to DocumentType and the first two letters of the filename

One more try - from what I can follow?
If I assume you have a table named for example "UserRules"
which has fields UserID,UserType,UserAction
and has records like this that controls the document types
a user is allowed to see
UserID UserType Action
TOM 1 Search
BILL 7 Search
ROY 2 Search
And if I assume you have a table named for example "AllowedUserDocumentTypes"
which has fields UserType,DocumentTypes
and has records like this that controls the document types
a user is allowed to see
UserType DocumentTypes
1 1,3,4,5,6,19
2 7,9,12,18
3 1,19,33,27
And you have the document table which has
fields are DocNo,Name,Title,Date,Filename,DocumentType
and it has records like this
DocNo Name Title Date Filename DocumentType
12345 BILL Cars CarTypes 18
12346 ROY Trucks TruckTypes 2
12347 TOM Toys ToyTypes 17
12345 JACK Car Colors CarColors 19
12345 TOM Car Shapes CarShapes 7
Then the select statement
Select DocumentTypes from AllowedUserDocumentTypes
join UserRules where UserRules.UserType = AllowedUserDocumentTypes.UserType
and UserRules.UserID = 'ROY' and UserRules.Action = 'Search';
will return 7,9,12,18
If the DocumentType field is numeric and the user entered "CarCrap" the
select statement would have to look like this
SELECT * from Document
where left(Filename,2) = 'Ca' and DocumentType in (7,9,12,18);
If the DocumentType field is say varchar
select statement would have to look like this
SELECT * from Document
where left(Filename,2) = 'Ca' and DocumentType in ('7','9','12','18');
You will have to build these select statements related to the user.
Note you should also allow for upper and lower case differences. I
would suggest you convert the user entry into uppercase and do a select
like below
SELECT * from Document
where Ucase(left(Filename,2)) = 'CA' and DocumentType in (7,9,12,18);
This is all written from memory, not tested and I have not done this
in several years.
I was showing approximately how to build the statements before.
rykk

Similar Messages

  • How could I find the SQL statement who get this message ?

    ORA-01555 caused by SQL statement below (Query Duration=11191 sec, SCN: 0x0854.723b9c32)
    ... How could I find the SQL statement who got this message ?
    Thanks, Paul

    ORA-01555 means that the UNDO/ROLLBACK space is not large enough.
    This occurs because the SELECT statement is attempting to read the UNDO, but the UNDO has been released (transactions have committed or rolled back) and reused.
    The following are SOME of the reasons I have seen this to occur:
    1) Updates in a loop, with commits happening in the same loop
    - this will mark the UNDO available quickly and quickly reuse it. Then when the SELECT wants to rebuild a block, the UNDO used to rebuild the block has been reused (solution, make the UNDO bigger)
    2) A SELECT cursor used to control a loop in which updates are performed, and a 'done' flag is marked against the current cursor record, and commits are performed at the end of each loop, prior to fetching the next record
    - same problem as above, but it hits the current process. Same solution
    3) A 'month end' activity spike occurs, and all sorts of transactions create updates. There is a report that reports the activity - amusingly it needs to start at the beginning of all the work and updates periodically by doing a huge SELECT up front. This is then used to drive a loop which attempts to get information from the various transactions that have been updated and committed. After a while, the SELECT gets an ORA-01555
    - same problem as above and same solution. Get a bigger UNDO segment.
    You say this only happens once a month. That should give a hint.
    I wouldn't bother with which SELECT statement, as much as which APPLICATIONs are being run when it happens.
    One way around this - use 10g and set the guaranteed retention period. All sorts of other things will break, by no more 1555. <g>

  • I want to move my photos from iPhoto to Time Capsule to make space on my computer.  What's the best means of doing this?

    I want to move my photos from iPhoto to Time Capsule to make space on my computer.  What's the best means of doing this?

    Please do not do this.
    The Time Capsule was designed for your backups.....not as an everyday hard drive. Access to the Time Capsule is slow.
    If there is any loss of connection between iPhoto and the iPhoto library when you are reading or writing, the entire iPhoto library is easily corrupted.
    The chances of corruption are even more likely if you are using wireless on the computer.
    And....even if you decide to risk this....if you move your "original" iPhoto library to the Time Capsule.....how will you make backups of the library?
    The only copy of the library will be on the Time Capsule....you have no backups.....when, not if, the Time Capsule has a problem.
    Simply stated, I would never do this with any important data that you cannot afford to lose. Please post in the iPhoto support area if you need to confirm this.
    iPhoto
    If you do want an idea of how to move your iPhoto library correctly, post back and we can help.

  • What are the business drivers for doing SAP BW Modeling

    What are the business drivers for doing SAP BW Modeling
    a.     Simplicity
    b.     Flexibility
    c.     Performance
    d.     Cost
    e.     Administrative Overhead

    Hi  Kumar,
    I will give just hints rest you have to think and act not about Interview quotations but SAP MM career.
    There are  couple of  guys and all of them has got job, first as a SAP testing, as SAP freshers in HCL/HP India etc.
    Later on  they have learnt all the business process in project and all the E2E cycles in  MM/SD/FICO etc.
    Now they are working on support projects and roll out projects.
    I think there are ways and we need to understand how to explore all the job possibilities.
    Please have good knowledge and definitely you will succeed. Short cuts are not always the way to success.
    Hope all my fresher friends will find some clue here....
    Regards,
    D Singh

  • What's the best way for reading this binary file?

    I've written a program that acquires data from a DAQmx card and writes it on a binary file (attached file and picture). The data that I'm acquiring comes from 8 channels, at 2.5MS/s for, at least, 5 seconds. What's the best way of reading this binary file, knowing that:
    -I'll need it also on graphics (only after acquiring)
    -I also need to see these values and use them later in Matlab.
    I've tried the "Array to Spreadsheet String", but LabView goes out of memory (even if I don't use all of the 8 channels, but only 1).
    LabView 8.6
    Solved!
    Go to Solution.
    Attachments:
    AcquireWrite02.vi ‏15 KB
    myvi.jpg ‏55 KB

    But my real problem, at least now, is how can I divide the information to get not only one graphic but eight?
    I can read the file, but I get this (with only two channels):
    So what I tried was, using a for loop, saving 250 elements in different arrays and then writing it to the .txt file. But it doesn't come right... I used 250 because that's what I got from the graphic: at each 250 points it plots the other channel.
    Am I missing something here? How should I treat the information coming from the binary file, if not the way I'm doing?
    (attached are the .vi files I'm using to save in the .txt format)
    (EDITED. I just saw that I was dividing my graph's data in 4 just before plotting it... so It isn't 250 but 1000 elements for each channel... Still, the problem has not been solved)
    Message Edited by Danigno on 11-17-2008 08:47 AM
    Attachments:
    mygraph.jpg ‏280 KB
    Read Binary File and Save as txt - 2 channels - with SetFilePosition.vi ‏14 KB
    Read Binary File and Save as txt - with SetFilePosition_b_save2files_with_array.vi ‏14 KB

  • What is the sql command for SELECT with OR condition

    Hi
    What is the correct sql command for doing select with or condition??
    SELECT * from TempData
    WHERE port = '123'
    OR serialnumber = '555'
    So if there is a port = 123 or if there is a serialnumber = 555, I will get a successful select.
    Thanks for helping a newbie!!

    Hi
    What is the correct sql command for doing select with
    or condition??
    SELECT * from TempData
    WHERE port = '123'
    OR serialnumber = '555'
    So if there is a port = 123 or if there is a
    serialnumber = 555, I will get a successful select.
    Thanks for helping a newbie!!Make sure you bracket your OR conditions
    eg
    SELECT * from TempData
    WHERE column = 'VALUE'
    and port = '123'
    OR serialnumber = '555'
    is read as
    SELECT * from TempData
    WHERE (column = 'VALUE'
    and port = '123' )
    OR serialnumber = '555'
    which is not the same as
    SELECT * from TempData
    WHERE column = 'VALUE'
    and ( port = '123'
    OR serialnumber = '555' )

  • I have 91 file that are pdfs i need to make searchable what is the best way of doing this

    help
    i have 91 file that are pdfs i need to make searchable what is the best way of doing this

    Hi ismaelr61128862,
    I would recommend you to try Advanced search option of Acrobat software, Go to Edit and then Advanced search.
    Hope that helps. In case you have any further questions please provide sufficient amount of details so that i can assist you more accurately.
    Regards,
    Rahul

  • What is the sql query for the real time reports Resource Stats?

    Does anyone know what the query is that the real time report tool uses for the Resource Stats page?  Trying to develop a custom report that displays similar information that is updated regularly.

    Hi,
    009 wrote:
    Hi Frank,
    Just wanted your opinion on the above given SQLI'm not sure I understand it.
    I added some more formatting to help me read it:
    SELECT      A
    ,     CASE WHEN LAG(A,1) OVER (ORDER BY A) IS NULL
              OR A=LAG(A,1) OVER (ORDER BY A)
              THEN LAG(B,1) OVER (ORDER BY A)
         END B_LAG
    ,     B
    FROM     (
         SELECT A, B
         FROM
              SELECT '1'A,'Apple' B FROM DUAL UNION ALL
              SELECT '1'A,'cat'B FROM DUAL UNION ALL
              SELECT '2'A,'bat'B FROM DUAL UNION ALL
              SELECT '3'A,'rat'B FROM DUAL UNION ALL
              SELECT '2'A,'yellow'B FROM DUAL UNION ALL
              SELECT '1'A,'pin'B FROM DUAL
         CONNECT BY PRIOR A=B
         ORDER BY A
    );What is the purpose of the CONNECT BY in what you have so far?
    Is the idea that you will add another CONNECT BY query, using
    CONNECT BY  b_lag  = PRIOR b?
    Do you think that will be better than using ROW_NUMBER?
    Will it work if (a, b) is not unique?

  • What is the SQL Standard for passing back a 0 in an Amount Field

    So I have an Amount Column in my database. What is the best way and the SQL Standard to pass back a 0 if it is a <NULL>? With a COALESCE statement?
    Thanks for your review and am hopeful for a reply.

    This is UNBELIEVEABLE! I got rid of my TextBox13 all together...Deleted it to start from scratch. And it is still erroring on TextBox13!!! I even checked the Properties List and there is no TextBox13. What in God's name is going on here?!?!?
    Am I missing something???
    Hi ITBobbyP,
    As to this issue, I find that this is a known issue which you can see on the link below:
    http://connect.microsoft.com/SQLServer/feedback/details/649210/bids-sql-2008-r2-warnings-not-clearing
    According to the Feedback, we can workaround this known issue by Re-open the project. And if Warning was in fact resolved, it will no longer show on the Business Intelligence Development Studio (BIDS) "Error List".
    As to your former issue, please refer to the expression post by
    Jingyang Li.
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • What is the best approach for doing view logic?

    Hi, I have a jsp page that receives an array of strings and a set of strings from a servlet. The set contain elements of the array. The page must print all the array values and which values are contained in the set. My first implementation just construct a checkbox for each array value using jstl c:forEach. To determine if they are checked or not I use some scriptlet. Without using scriptlet, the servlet would need to help by providing a new type of data. Also, if I needed to sort in ascending order the checkboxes, then I would need to use scriptlet, or the servlet would need to do the ordering before passing the array. Using the servlet to prepare the data, if the view now need to change ordering to descending, then I should change the servlet.
    My doubt is, when doing view logic, what is better, to spread it into view and servlet, or to leave it in view only? I know the recommendation is to not use scriptlet in views, but jstl alone sometimes doesnt provide the needed support for constructing views

    Write your own custom tags to handle to cases where JSTL alone is not sufficient. Also, you may use expression language (EL) and have custom EL functions. Avoid writing scriptlet in JSP and instead of writing view processing logic in servlets use custom tag handler or EL functions to handle UI display logic.
    Thanks,
    Mrityunjoy

  • Error in the sql statement for SQL Server

    Hy:)
    i am using this sql statement to get all fields, which have been changed since yesterday
    SELECT ITEMCODE FROM SBODemo_UK.DBO.OITM  WHERE CREATEDATE IS >= DATEADD(day, -1, GetDate())
    But its not working.. you have any suggestions?
    cheers,
    Maggie

    Hello Margarete,
    I think ur query works if u simply remove 'IS' from it
    SELECT ITEMCODE FROM SBODemo_India.DBO.OITM
    WHERE CREATEDATE >= DATEADD(day, -1, GetDate())
    Manu

  • How to always hide the SQL statements for users when they run User Queries?

    Hi,
    from the IT dept. position, I don't want users to see and be so curious about the SQL commands.
    How can I always hide the textbox of  Display Query Structure?
    thanks.

    Hi,
    Unfortunately system design has short of this function. If users are allowed to run those queries, you can not hide the query structure.
    You may post a DRQ here: /community [original link is broken]
    Thanks,
    Gordon

  • What is the sql query for this

    table Employee
    EmpId
    Name
    MonthlySalary
    DateofJoining
    Suggest  a sql server query to find out the employee details whose having salary greater than their yers of experiance 
    nravhad

    Hi ,
      As this seems to be a kind of lab exercise question for learning purpose , i am giving you the pseudo code which will help to solve this problem and learn.
      select <the requeired columns> from employee table.
      where Find the no of years between dateofjoining and current date using DATEDIFF function< monthly salary
      if this is not a lab exercise problem for learning purpose , please forgive my ignorance.
    Best Regards Sorna

  • What's the best technique for making this page work?

    Here's a link to a jpg showing a design for a portfolio site that I'm building:
    http://i287.photobucket.com/albums/ll130/Mickmastergeneral/test_modeling_texturing.jpg
    The image of the ATV will be a Qucktime file; the visitor will be able to scrub the slider to see a pre-rendered rotation of the model. The visitor will then be able to view a different model by clicking on one of the thumbnails at the bottom of the page. So far so good.
    But the visitor will also need the ability to display the model's texture map in a new window (by clicking on one of the the texture map icons on the right), as well as choose wireframe or shaded mode (by clicking on the appropriate text button; this would load a quicktime movie of either a wireframe or textured model turnaround).
    So, the trick is getting all the appropriate stuff to load when the user clicks on a lower screen thumnail: The Quicktime movie, the appropriate texture map icons for that model (which in turn need to link to pages containing the correct image), and "Shaded" & "Wireframe" text buttons (that link to the appropriate Quicktime movie.)
    I haven't done any web design in years, so I'm using an ancient version of DW (Dreamweaver Ultradev 4), and I'm definitely not up on the latest techniques. I know how to work with frames, but I've heard that it's a good idea to stay away from them. Would layers work for this? I've worked with Behaviours and I know how to do image swaps and hide/show layers, but I don't know how (or if) I can use that trick to make the appropriate texture and wireframe/shaded links appear. Any ideas how I should proceed?

    So, do you think it would make sense for me to just bite the bullet and learn Flash?
    No - I don't think Flash is a good tool for a general purpose website other than for special cosmetic effects.  But I do think it is the thing to use if you want those, and not QT.
    - I already have a ton of those model animations rendered out as h.264 Quicktime files. They look pretty good and are a reasonable file size. If I bring them into a Flash file, does that convert them into Flash? Will that affect image quality or inflate their file size?
    They should convert quite acceptably.

  • What is the best approach for executing this code only once?

    Hi,
    What would be the best way to this using JSF/Java web architecture? I have a login page, login.jsf, that submits login credentials to another servlet and if successful, is redirected to a login success page, which I have called "main.jsf", my application's main page. What I want to do, however, is when the login success mechanism redirects to my application, I want to run a bit of Java code (which requires access to the session object) that executes only once, and then redirects to my application's main page.
    In other words, I could put this Java code on my application's main page, but then it would execute every time a user visited it.
    Any advice on the most efficient way to do this?
    Thanks, - Dave

    laredotornado wrote:
    Thanks for your reply but I have a question. If the filter is executed on every page, then, assuming the user is logged in, the code would be executed every time. How can I create this such that my code snippet is executed only once, preferably after the user is re-directed to the login success page?It is more secure. On login just put the User object as attribute of HttpSession and check in the filter if it is there.

Maybe you are looking for

  • Apartment number not listed in Verizon Database

    Hi, my apartment number is not listed in Verizon's database. Somehow, Verizon can provide Internet services to everyone else in my apartment building except mine because mine is not listed. My address is {edited for privacy}. Can you please help? - J

  • Problems with Java 1.4.2 component on Linux RHEL

    Hello, My Linux RHEL was hacked and my HDD was backed-up. Now, I need to reconfigure my RHEL environment to get software up and running again. I am required to install j2sdk1.4.2_05 as a prerequisite for Oracle Forms/Reports Services 10g on my Linux

  • HD Video Recording app missing?

    HD Video Recording app missing? I restored my iPhone 4S with my latest backup from previous model, but HD camera seems to be lost. What should I do? Thx for any help.

  • Is it possible to change the color of my apple logo light

    I have a macbook air and the apple lights up white, but I'm using F.Lux to help with backlight color temperature and the apple doesn't seem to change color even though the screen does. I thought the apple was controlled by the backlight?

  • SAP Backup Service  SAP 8.8 and Windows 2008 R2 64 Bit

    Dear All ( Mr Gordon) I am facing problem with the Backup Service on windows 2008 R2 64 Bit. 1)The Service starts - There is no Issue 2)THere is no Backup - Even though i schedule it perform the backup 3)EvenLog has a lot of messages -   Messages say