How to adapt function for direct using for IN/NOT IN clause

Hello
I have following function:
create or replace
function all_userids return UserTypeIDTAB authid definer
is
l_emp_tab UserTypeIDTAB := UserTypeIDTAB();
begin
for r in (select userid from usertab where userid <=10)
loop      
l_emp_tab.extend;
l_emp_tab(l_emp_tab.count) := r.userid;
end loop;
return l_emp_tab;
end;
where type UserTypeIDTAB was created by following:
create or replace type UserTypeIDTAB as table of number;
This function can be called in SQL:
select * from usertab where userid in (select * from table(all_userids))
But what I want to achieve is that it will be possible with shorter query like:
select * from usertab where userid in all_userids
or
select * from usertab where userid not in all_userids
In this case I have got following error:
00932. 00000 - "inconsistent datatypes: expected %s got %s"
Is it possible? What must be done for it? What does expect IN/NOT IN clause?
thanks

Metalpalo wrote:
What duplicate? And what would you achieve by "eliminating" this duplicate?The term duplicate by me is following subselect code:
(SELECT LISTITEMID FROM LISTTAB WHERE LISTID = ?)
This condition is to big when I set e.g. 100 filters. Therefore I want to replace it with something shorter.There is nothing shorter. In SQL language, you cannot define procedures or functions.
Putting that SQL statement as a view? That will be of no real benefit in making the statement shorter. There are two approaches. The first one is not very sensible as it does not provide any benefit:
create or replace view item_list as select item_id from list_tabTo "+pass parameters+" to the view (as you would to a function or a procedure), you need to use predicates. The CBO is clever enough to push these into the actual SQL that defines the view where possible. So using it:
select item_id from item_list where list_id = 1As you can see - nothing gained as the view SQL looks exactly like the underlying source SQL and the view provides no benefits.
The second method is to define views per list ID. For example:
create or replace view item_list_1 as select item_id from list_tab where list_id = 1
create or replace view item_list_2 as select item_id from list_tab where list_id = 2To use that:
where  parent_id in (select item_id from item_list_1) and child_id in (select item_id from item_list_2) The predicate now needs not be specified. But you need a view for each unique predicate that would have been used. Perhaps do-able when dealing with a small number of lists - but generally, this approach will not be useful and will require additional maintenance (creating views for new lists, dropping views for lists no longer valid, etc).
Thus using orignal SQL statement as it is, is IMO correct and should be used like that. And if you have a billion SQL statements that needs to apply that sub-select filter, then yes - you will need to code that SQL as a sub-select a billion times.
Nothing wrong with that. It is not duplication. And the fact that you cannot create "short cut" code in this case, is simply an issue of how the language is designed.
In Cobol we need to do this to increment a counter:
ADD 1 TO COUNTER.
In PL/SQL:
cnt := cnt + 1;
In C/C++:
i++;
In Delphi Pascal (generating optimal machine code):
Inc( cnt );
Etc.
It is wrong thinking that because another language allows you to do this by writing a fewer characters less, you now also need to pursue fewer less characters in the current language.
You need to adhere to the syntax, rules and fundamentals of the language you're using. And in SQL, it is perfectly fine to code that SQL statement, with a different predicate, multiple times. This is simply how the SQL language works.

Similar Messages

  • I want to be the only one who can access my profile, so how to create passwords for profiles (NOT for websites) ?

    I want to be the only one who can access my profile, so how to create passwords for profiles (NOT for websites) ?
    thanks

    Maybe use the portable Firefox version on a USB stick if you want to prevent access to your profile.<br />
    Solutions that use an extension can easily be bypassed by starting in [[Safe mode]].<br />
    Otherwise you need to locate the Firefox profile folder on an encrypted drive.
    See http://portableapps.com/apps/internet/browsers/portable_firefox

  • How to unblock function for updating IOS software.

    we did say not to upgrade some time ago, now we want to upgrade ios, how to find and unblock function for upgrading ios to newer software?

    I did everything that you guys asked me to do. Until now my iphone is useless. A friend of mine asked me to update his iphone 4 running ios 5.1.1 to ios 7.1.2 and I was able to update it without experiencing any error then I tried it again on my iphone but the same error appeared. The same (error code 3194).
    This got me thinking that APPLE must have blocked my iphone from updating to later version of IOS. can someone please help me figure out and understand why this is happening to my iphone if other iphone like my friend's can update ios so easy?

  • How to force Functional Module to use Batch-Process ?

    Hello all,
    I am calling a FM via synchronous RFC. No matter what I try the functional module is started
    in a dialog process in the remote system. This is inconvinient because sometimes the process takes too long and a timeout occurs. I also tried transactional RFC and asynchronos RFC but no  difference here.
    The FM will always be executed in a dialog process.
    How can I tell the functional module to use a batch process ?
    Thank you for your answers,
    Axel

    hi,
    use
      CALL FUNCTION 'HR_START_BATCHJOB_IN_OTHER_SYS'
        EXPORTING
          repid                = 'sy-repid'              "           "Program name
          variant              = 'VAR'
        JOBNAME =
        CALL_BACK_DEST =
        CALL_BACK_ID =
      IMPORTING
        JOBCOUNT =
        INDX_ID =
        TABLES
          valutab              = it_sel.
    you can set your program in batch mode using the above function module
    Yogesh N

  • How to open jxl workbook directly using JSP...??

    Dear Friends,
    I have created an object for "jxl.write.WritableWorkbook" in my action class, suppose let's say "objWB"
    now I can write this object to a file using objWB.write(), If I write to a file I am able to open it using FileInputStream
    but I don't have permissions on my client machine
    so is there any way, where I can open it directly using JSP.
    Thanks in advance..
    GP
    Don't think be happy

    Don't think, be happy eh? How can you be happy if you have no capacity to register it?
    In any case, to "open" a document in any web environment, you write the binary data to the response with the correct content-type set. If for example you set the content-type to "application/ms-excel" and on the client computer a program is registered to handle that content type, the document might be opened directly in that application. If there is no application registered to handle the content-type, a download of the file is usually offered.
    Do a google search for popular content-type values. I'm sure you can also find examples on how to output a binary file to the response. You are already almost there, in stead of writing the data to the fileoutputstream, write it to the outputstream of the response object in stead.

  • How do I search for sticky notes in a PDF doc?

    Several people (at work) have commented on a 440-page document that I created, using sticky notes to write their comments in. When I first open the document, the sticky notes are all closed. The icon for a closed sticky note is pretty small and not brightly colored, so they're easy to miss when scrolling through hundreds of image-heavy pages. I am hoping that it's possible to search for each occurrence of a sticky note.
    If there is no way to search for the notes, is there a command I can use to open all the notes in the file (in one action) so that they are larger and easier to spot?
    Platform: Windows 8 PC
    Version: Acrobat 8
    If this is not a feature available in Acrobat 8, is it possible to do this in later versions?
    Apologies if this is not the right community for this question, but none of the ones listed seemed like the obvious choice, and there is no "miscellaneous" or "general" category. If there is a better community for the question, please let me know.
    Thanks,
    Joyce.

    Out the gate you've a problem.
    The Acrobat 8 product family passed into "End of Support" many years ago (well before the release of Windows 8).
    "End of Support" means -- well, just that eh.
    The Acrobat 8 product family is not compatible with Windows 8.1, 8 or 7.
    The Acrobat XI product family is compatible with Windows 8 / 8.1.
    Regarding Comment and Mark Up Annotations:
    With Acrobat 8 Pro use the "Comments List".
    Same wit Acrobat 9 Pro, X Pro and XI Pro.
    May be available with the various versions' "Standard" release.
    The contents of a Comments List can be exported to a PDF report.
    The filter an be used to display specific characteristics / attributes which then become the reports content when you output a report.
    Having "8" the Help PDF file got loaded with the install of "8".
    Use it to review the information provided on the Comments List.
    Be well...

  • Trackpad zoom in function for mac not working

    I downloaded the beautiful Firefox last week. Everything works superb BUT the Zoom in function for the trackpad, which is a very important function for a guy that reads everything straight from the computer. I opened the Safari just to check but it works well there...
    I restarted my mac (MacBook Pro, 2 years old) but still not working. Help please!!

    Your zoom controls.
    <Control> '''+''' (plus) enlarge
    <Control> '''-''' (minus) reduce
    <Control> '''0''' (zero) restore
    You can rename (or delete) the '''content-prefs.sqlite''' file in the Firefox
    profile folder to reset the page zoom for all websites.
    Type '''about:support''' in the address bar and press enter.
    Under the page logo on the left side you will see '''Application Basics.'''
    Under this find '''Profile Folder.''' To it’s right press the button
    '''Show Folder.''' This will open your file browser to the current
    Firefox profile. Now '''Close Firefox.'''
    Locate the file. Then rename or delete it. Restart Firefox.

  • How to look out for oss notes

    how to look out for oss notes

    OSS Note
    http://www.sappoint.com/basis/.pdf
    http://www.sap-img.com/basis/oss-notes.htm
    http://www.sap-img.com/basis/manually-applying-the-oss-note.htm
    REgards,
    Santosh

  • How to open word document directly using ole2 and ole containers

    Hello
    i am using ole conatiners....in forms 6i. i want o open word document directly when i click a button....
    i have tried host....ole but word opens .....i want the document to open at once.....
    what should i use /set
    plz tell by host command and ole2 as well
    its urgent.....
    thanks

    Try this code, Hope this will work.
    declare
    item_name varchar2(80) := 'letter';
    item_id item;
    verb_index_str VARCHAR(20);
    verb_index PLS_INTEGER;
    verb_cnt_str VARCHAR(20);
    verb_cnt NUMBER;
    verb_name VARCHAR(20);
    loop_cntr NUMBER;
    begin
    item_id := Find_Item(item_name);
    IF Id_Null(item_id)THEN
              message('No such item: '||item_name);
    ELSE
    verb_cnt_str := Forms_OLE.Get_Verb_Count(item_id);
    verb_cnt := TO_NUMBER(verb_cnt_str);
    FOR loop_cntr in 1..verb_cnt LOOP
    verb_name := Forms_OLE.Get_Verb_Name(item_id,loop_cntr);
    -- message(verb_name);
    -- message(loop_cntr|| ' '||verb_name);
    IF verb_name = 'Open' or Verb_name = '?E?'THEN
    EXEC_VERB(item_id,verb_name);
    END IF;
         end loop;
    end if;
    EXCEPTION
    WHEN OTHERS THEN
    MESSAGE('Error: '||TO_CHAR(SQLCODE)||' '||SQLERRM);
    RAISE FORM_TRIGGER_FAILURE;
    end;

  • How to find function is in use

    Dear All
    Please let me know. is there any facility in oracle 10g to find out whether my function or procedure
    are in use by any user?
    If anybody is having idea then please tell me or tell me any database dictionary table where i can get this info.
    Thnks

    vishal dba wrote:
    Dear All
    Please let me know. is there any facility in oracle 10g to find out whether my function or procedure
    are in use by any user?
    If anybody is having idea then please tell me or tell me any database dictionary table where i can get this info.
    ThnksGo to tahiti.oracle.com. Drill down to your product and version. There you will find the complete doc library.
    The Reference Manual documents all of the data dictionary views. Look through there for anything that looks like a likely candidate, then read up on it.
    Give a man a fish and he eats for a day. Teach a man to fish and he eats for a lifetime.

  • How to create requirement for BOM, not for its components?

    Dear gurus,
    I have never worked in PS module before. Now I have the following task:
    There is Project, Network and WBS. I inserted material for operation in WBS and exploded the material.
    Now the system must create requirement for this material but NOT for components of BOM. How can I configure the system?
    P.S. We don't use MRP and we can't change Material Master Data.
    Edited by: Azat Fayzullin on Dec 8, 2009 12:44 PM

    Have you read SAP help on PS
    also check this forum for similar posts
    If you have never worked on PS module I am not sure if you will be able to configure the system
    please attend some courses in PS from your local SAP academy course names are PLM200, PLM210, PLM220, PLM230, PLM240
    for your specific requirements I would recommend PLM200 and PLM220

  • New sent back functionality for manager not working fine.

    Hello,
    We have an ESS/MSS implementation in place with portal.
    Now the scenario is :
    Employee raise a travel request.
    Request goes to worklist of manager.
    Manager selects to "Sent it back" to employee for correction.
    Employee is able to see the request for correction in his worklist.
    Now the problem is:
    when manager selects to "Sent it back" to employee for correction.
    The request also comes to his worklist as well AND it goes to employee worklist as well.
    The request must not come back to manager !
    Any comments please !

    What is the WF Template number you are using? Is it a Standard one or a Custom one ?
    For the User Decision Step, See what is the Agent Assignment ?
    Check the Workflow log to see if there are mulitple entries in the Container Element !!!
    Regards,
    PR.

  • How do i store for playing NOT STOLEN music files on ipad, from any computer in the world, at any time?

    I concluded that with buying an Apple ipad2, I made ​​the worst investment. Unfortunately, I realized that the philosophy that you build the software for these devices is to extort money from clients without providing them the right to choice. Specifically, at this point I am feeling frustrated that I can not copy .mp3 files to iPad from my home computer, as any device can do. These files do not contain stolen music and, yes, is a certain reason to be unhappy client! I am very sorry that I don't bought a Samsung Android device and I will share my experience all those who need it.

    I can not copy .mp3 files to iPad from my home computer
    Er, yes you can - I have thousands of MP3 on mine. It appears you have not have bothered to read the User Guide before coming here to make yourself look rather foolish with your blatently incorrect beliefs.
    Here's a link for you: http://support.apple.com/manuals/#ipad

  • How can I: Search for files "not in catalog"

    Is there a way to search for files/photos on my hard drive that are *NOT* already in my catalog?
    (a) I can do a mass search to find all photos on my hard drive.
    (b) And there is a reconnect feature - for all entries in catalog with a missing/invalid link, look for the file that matches best.
    But I'd like to have Elements find photos that I have not added to the catalog.
    That is, do (a), but check each one to see if it is already added.
    Is there a way to do that?
    Thanks,
      -ceej

    What you want to achieve by finding those files?
    In folder view you can see the folder which have no media files in Organizer.
    If you import all the files form all the drives on your system, by deafult you will see files just imported into catalog. That means, just after import ou will have the files which were not in your catalog :-)
    I know my  answer could be confusing for you, but it will make sense if you know what happens after import in Organizer...

  • HT1657 How to get credit for movie not playing?

    Even after the complete download of a movie, play would not start and after 24hrs it was deleted- how can I get a credit?

    If you've been charged but haven't received the items then try the 'report a problem' link to contact iTunes Support : http://reportaproblem.apple.com
    If the 'report a problem' link doesn't work then you can try contacting iTunes Support via this page : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

Maybe you are looking for

  • Linksys E2000 Suddenly Choppy When Playing HD Videos

    So quick back story. I stream a lot of 720p HD video over my network (both local storage and Internet streaming). I bought the E2000 about 5-6 months ago after my last router stopped working, and it has been working flawlessly up until now. So a few

  • How many times can you download a purchased tune from iTunes?

    I am in the process of cleaning up my itunes. I am deleting duplicates. I find that I have duplicates of purchased tunes. Don't know how this even happens but now that I've put 700 duplicates in the wastebasket, I find a lot of purchased tunes gone f

  • Table Partitioning in Oracle 8i

    Can tables be partitioned in Oracle 8i Standard Edition, or do I have to have the Enterprise Edition? I'm trying to deal with backup of a large database, and want to consider performinig partial backups to save time/resources. Thanks.

  • Quiz slides not to be counted in quiz summary at end - Captivate 4

    I have created a course which has quiz slides at the beginning of the cours which I have marked to not be graded.  These slides are knowledge checks and should not be graded nor be counted.  Then I have quiz slides at the end of the course that I do

  • Issue in ATG Production

    Hi All, While running ATG Production I am getting following Error. **** Error Mon Feb 25 10:39:10 IST 2013 1361768950870 /atg/dynamo/service/Scheduler Error while handling scheduled job null java.lang.NullPointerException **** Error Mon Feb 25 10:39: