Using a subquery with a keyword 'IN' to create a dynamic list

Hello, everyone:

I began to dream of out of the box. I have large column of the codes that I don't want to hardcode it by hand, so I thought that a simple test of what follows would be the way to go:
Declare
v_code varchar2(20) := 'ZZZ';

Begin

IF v_code in (select GURIDEN_IDEN_CODE from Guriden) Then
DBMS_OUTPUT.PUT_LINE("This entry is good");
else DBMS_OUTPUT.PUT_LINE("This is not in the list");
End if;
End;
Well, I had a dirty little message that said I couldn't use the query sub in this way. So how can you create something similar?

Thank you

Preston@large

Published by: Preston@Large on March 1st, 2010 07:42

Maybe something like that?

DECLARE
        V_CODE          GURIDEN.GURIDEN_IDEN_CODE%TYPE := 'ZZZ';
        V_CODE_CNT      NUMBER;
BEGIN
        SELECT  COUNT(*) INTO V_CODE_CNT
        FROM    GURIDEN
        WHERE   GURIDEN_IDEN_CODE = V_CODE;

        IF V_CODE_CNT > 0 THEN
                DBMS_OUTPUT.PUT_LINE('This is a valid code');
        ELSE
                DBMS_OUTPUT.PUT_LINE('This is an invalid code');
        END IF;
END IF;

Tags: Database

Similar Questions

  • I used to work with Interbase and Firebird and used databases the keyword "domain". I am now switchig to Oracle as a primary database and would like to find an alternative appropriate "domain" in Oracle, as it appears he does ' t taken in charge the stand

    I used to work with Interbase and Firebird and used databases the keyword "domain".

    I am now switchig to Oracle as a primary database and would like to find a suitable

    Variant of 'area' in Oracle such that it appears he does ' t support the standard SQL syntax.

    for example:

    Create the int2 smallint field;

    create domain id2 int2 default 0 not NULL; / * for the primary key * /.

    create domain rel2 int2 default 0 not NULL; / * foreign key * /.

    I tried a couple of approaches to achieve this "area" is:

    1. create synonym - cannot be used with the basic types;

    2. create the type - type of work, but the implementation is rather clumsy

    and can be costly in terms of performance.

    Is there something else to Oracle that can emulate the feature "domain"?

    Thanks in advence, I got really approciate any help on this.

    Alex.

    Your best approximation is CREATE TYPE, but their is nothing of what is a 100% adjustment.

    For example, if you create a domain with a check constraint you need to implement than separately on each table.

  • Question: smart album with no keywords

    Hello

    I keep my pictures organized by keywords.

    When organizing my library in iPhoto, I used a smart album named any keyword with condition 'keyword is not.

    Is there a way to do this in Photos?

    It seems there is no option to 'none '.

    Thank you

    There is no documented option to create an album smart wih "keyword is not".

    You can use a work cycle: rename all of your keywords to start with a fixed prefix "k::" or similar.  And search for photos with "text does not include" k:: "to find the photos without keywords."

  • Corresponding to the string of text with a keyword and check whether it exists or not

    We have this DESCRIPTION column, and the data inside it are:

    Mr. Redmond Bred is to have a red balloon. His tie is also red.

    Now, when you use it AS operator with the keyword 'red', he finds a match in these 3 words: Redmond, Bred and red.

    But in my case, the match should happen with the word "red" only. Is this possible?

    Yes, it is possible, for example by using regular expressions.

    Also please note that your first assumption is wrong. The like operator won't find Redmond.

    Example of

    select *
    from dual
    where regexp_like('Redmond''s Bred is having a red balloon. His tie is also red.','(^|\s)red(\s|$)');
    

    Post edited by: SvenW. : added example

  • Subquery 'WITH SAWITH0 AS' OBIEE 11 g factoring clause contained in the generated sql code

    I have observed that OBIEE 11 g generates in physics request log query using the (subquery factoring) WITH clause to the generated sql code elegantly readable. It's great! Thanks for the developers. However I have a few questions about it.

    __Background__
    Oracle database ' default behavior is that if you have only a subquery in the section, it runs as a perspective in line and he not materialized before the main sql is running. If you have more than one default database engine materializes all the in the order of definition. In some cases, it can completely blow up the SGA and make a query without end. To divert this behavior, you can apply two tips that work both in inline views in subqueries as well: / * + MATERIALIZE * / and / * + INLINE * /, however Analytics 11 g does not seem to have capabilities of Board at the table level logical, only at the level of the physical table.

    If we go with the current default settings, the developers do not know this feature can fall on serious performance problems for the sake of a few sweets of syntax to the generated sql level, I'm afraid.

    __Questions__

    * It is possible to turn the Analytics Server to not use WITH but views inline instead?
    * Is it possible to sneak in a few boards that would the / * + INLINE * / allusion to the proper place in the subqueries generated if necessary
    * Is the Oracle database has any initialization parameter that can influence the behavior of this subquery factoring and divert by default?

    The WITH statement is not added to make the query more elegant, it is added for performance reasons. If your queries slow to run, then you can have a design problem. In a typical DWH DB SGA should be increased seriously given that ran queries are much larger and complex than on an OLTP DB. In all cases, you can disable the WITH statement in the administration tool by double clicking on your database on the physical layer from object in the features tab. The function is called WITH_CLAUSE_SUPPORTED.

  • How to join two tables of different schemas of Oracle by using a subquery

    I'm trying to join two different schemas of Oracle tables using a subquery. I can extract data from each of the tables without problem. However, when I combine select statements it by using a subquery I get Oracle error *'ORA-00936: lack of expression ' *. Given that each SELECT statement runs on its own without error I don't understand what's missing. I'm trying to get the result set is matching the LINE_ID of PDTABLE_12_1 in the schema with the table PDTABLE_201 MAT_DESCRIPTION DD_12809 in the RA_12809 schema.

    The query is as follows:

    SQL = "SELECT [DD_12809]. [PDTABLE_12_1]. LINE_ID OF [DD_12809]. [PDTABLE_12_1] JOIN "_".
    + "(SELECT [RA_12809]. [PDTABLE_201]. MAT_DESCRIPTION "_".
    "FROM [RA_12809]. [PDTABLE_201]) AS FAB "_".
    + 'ON [DD_12809]. [PDTABLE_12_1]. PIPING_MATER_CLASS = FAB. PIPING_MATER_CLASS ".

    The format of the request is copied from a manual of programming SQL.

    I also tried running the query uses a right JOIN on the two tables, but got the same results. Any ideas would be useful. Thank you!

    Published by: user11338343 on October 19, 2009 06:55

    The format for the join of two tables in Oracle feels like any other database:

    SELECT a.col1, a.col2, ..., b.col1, b.col2, ...
    FROM   schema1.table1 a,
           JOIN schema2.table2 b ON a.col = b.col and ...
    WHERE  a.other_col = 'FRED'
    AND    ....;
    

    Do not place bracketed identifiers in Oracle. The account that connects to the database must have select privileges on the two tables.

  • Can I upgrade to iOS 10 using a Mac with OS (10.8.5) Mountain Lion?

    Can someone tell me if I can sync to my iPhone 6 with iTunes using a Mac with the (10.8.5) Mountain Lion?

    This is what Apple is the list for the iPhone 7 that runs iOS 10.

    http://www.Apple.com/iPhone-7/specs/

    • Sync with iTunes on a Mac or a PC requires:

    My daughter is running Lion on his MacBook Pro and was synchronize its iOS iOS 9.3.5 devices. The requirements for iOS 9 call for Cougar 10.8.5. It will never update via iTunes - always on WiFi - and I think that's how she got away with it. I don't know if it will work this time with iOS 10.

  • Try to add a page to a pages document. It worked until now but just finished page 13 with text and photos and cannot add another page, using macbook pro with El Capitan and the most recent version of the Pages.

    Try to add a page to a pages document. It worked until now but just finished page 13 with text and photos and cannot add another page, using macbook pro with El Capitan and the most recent version of the Pages.

    You have placed your beam to insert at the end of your text on page 13 and then apply Insert menu: Page Break? In the v5.6.2, Pages I just add a new page to a section of four pages to this approach.

  • I use an iMac with a wrong as a monitor graphics card?

    The graphics card on my iMac went wrong.  The logic board is OK and works otherwise OK.  Can I use the iMac with the graphics card bad as a second monitor in target disk Mode or use it as a monitor for a mac mini? The bad iMac is a model 2011 (of course!) with HDMI ports and Thunderbolt.

    I think you mean that the Display Mode target and any connection to the screen will have to pass by the graphics card. Whereas if you replace the bad graphics card, don't.

  • Using Migration Assistant with no display

    I got my MacBook mid-2010 (2.4 GHz, 4 GB RAM, OS X El Capitan) for 2 years.

    It splits into two somewhere within 2 years.

    The MacBook was still usable, but it had to be on a desk. The screen was completely separate from the base. It still worked.

    I woke up a few days ago to find that someone had cut the display cable holding the MacBook set and turn on the screen.

    I bought an early-2011 13 "MacBook Pro to replace the dead MacBook. (Yes, I buy old Mac because the news is so expensive).

    Old Mac has been saved semi regularly, so I have an old backup to use for the new Mac. The problem is that just before the death of the former Mac, I downloaded a bunch of stuff that has not been saved. I really want the files that have not been backed up on my new MBP.

    Can I use Migration Wizard with an Ethernet cable and transfer of data from one, or Migration Assistant must be running on old Mac as well?

    I tried to connect (I'm sure that the computer is still running, it doesn't simply have a display) on the old Mac, plug the backup drive and I hope to do a backup hourly, but Time Machine did not only.

    Any suggestions would be GREATLY appreciated.

    If you use Ethernet or a wireless network to transfer data, Yes. If you can not download the files and file-sharing has not been activated on the old Mac, you must either get fixed display or put its internal drive in a closed Chamber.

    (143074)

  • How to use spell checking with magic mouse

    How to use spell checking with magic mouse

    Hello

    The mouse is not intended to be used with the spell checker.

    The mouse settings available in system preferences > mouse

    Spelling and grammar can be checked in the Edit menu in most applications.

    In addition, shortcuts keyboard.

    Command:

    And the command;

  • Can I still use Internet Explorer with Mozilla Firefox

    Can I keep the two search engines installed and use them without causing any problems to my computer

    Change by a moderator. I changed the title of
    can I still use exporer with mozilla for
    Can I still use orerlExp Internet with Mozilla Firefox

    They are not search engines. They are called browsers, and Yes you can use Mozilla Firefox and Internet Explorer on the same computer at the same time. You can also add Google Chrome and a few others without causing problems for your computer.

    Most people are after the use of these alternative browsers, that they no longer wish to continue using Internet Explorer.

  • How to make a bootable USB using the disc with El Capitan utilities?

    Anyone know how to make a bootable USB key using the disc with El Capitan utilities?

    Try this its worked perfectly.

    http://www.Macworld.com/article/2981585/operating-systems/how-to-make-a-bootable - os-x-10-11-el-capitan-installer-drive.h...

  • I use 4 windows with multiple tabs, but I 'don't know why one of them (window) always close when I restar computer

    I use 4 windows with multiple tabs, but I 'don't know why one of them (window) always close when I restar computer

    Hello, by default the firefox session restore feature only allows you to save last 3 windows open. to change this, type on: config in the address bar of firefox (confirmed the message information where it appears) and search for the preference named browser.sessionstore.max_windows_undo. Double-click it and change its value to 4 (or more).

    http://KB.mozillazine.org/browser.sessionstore.max_windows_undo

  • Rotation of the photos in iPhoto I could simply use the trackpad with 2 fingers turning motion.  In pictures, it seems that I have to use the Edit menu, etc etc?

    In iPhoto, I could simply use the trackpad with 2 fingers rotating motion to change photos quickly to stand.  In the Photos but it seems I have to use the Edit menu, etc. etc.?

    command + r or command + option + r, depending on the direction you want.

    Also, right-click on the image to the same command, hold the option for the choice

Maybe you are looking for