SQL Help: Add flag for several tables

Hello

I have an existing SQL as follows:

Select the storeId field,

(select case when count (1) > 0 0 otherwise then 1 end)

of tb_bbb

where tb_bbb.id = tb_base.baseId) AS conInd

of tb_base;

I would now add the table tb_ccc for the value of conInd. I try the following SQL:

Select the storeId field,

(select case when count (1) > 0 0 otherwise then 1 end)

Of

(select tb_bbb.id where tb_bbb.id = tb_base.baseId)

Union

Select tb_ccc.id where tb_ccc.id = tb_base.basdId) AS conInd

of tb_base;

However, it does not work. Any idea on this SQL?  Thanks for your help!

Hello

Here is another way, which may be more effective because it uses EXISTS (which can quit smoking as soon as it finds a match) instead of COUNT (who continues to go, so he can tell you if there are 999 or 1000 matches, even if you don't care to).

SELECT storeid

CASE

WHEN THERE IS)

SELECT 1

OF tb_bbb

WHERE bbb_id = m.baseid

) 1 THEN

WHEN THERE IS)

SELECT 1

OF tb_ccc

WHERE ccc_id = m.baseid

) 1 THEN

0 OTHERWISE

END AS conlnd

OF tb_base m

;

Tags: Database

Similar Questions

  • Container for several tables of different length

    Hey,.

    I'm doing an algorithm for labelling component connected in LabVIEW.  I came across the problem that I need some sort of data structure that I can't create.  I hope that I've missed something and someone can report this to me.

    What I'm looking for is a container that can contain lists of lists of 2 values.  Basically, I have several labels.  Each label will have a list of coordinates in.  The closest I came to this creation is a 2D cluster table.  Then, the cluster contains the coordinates X and Y.  The problem is that each list is not the same size, and for a table of 2D in labVIEW, all rows/columns must have the same length.

    In summary, I'm looking for a way to store multiple lists of coordinates.  The lists will all be of different lengths, and I don't know how many lists there will be.

    Is it possible to do this?

    If not, does anyone know an easier way than that looking for a 2D for concentrations table all?  At the back of my mind, I want to say that there may be a Vision VI of OR who can do this, but I can't find a.

    Thanks for your help,

    Dominic Walker

    A way to manage several arrays of different lengths (but all the same type of data) is to put the berries in a queue.  Each element in the queue must be a table, but they can be of different lengths.  To get to all the tables, you use the preview queue feature.  It returns an array of clusters with each table queue in a separate group (if I remember correctly).   Perhaps an array of clusters of berries would work for you.  I just checked that this allows arrays of different lengths.  You can also place a control of the chain with the label of the cluster if it is appropriate.

    Lynn

  • granting of privileges to the schema for several tables at the same time... any script?

    Hello gurus,

    I have about 25 tables in the ABC scheme

    I want to give all privialges to the XYZ schema for all tables of 25 which is in the pattern ABC... So is there is SQL statement or a script, I can run to grant privileges to all tables.

    Something similar to these...

      SELECT 'create synonym ' || table_name || ' for ' || table_name
      FROM user_tables  {code}
     
    So i get all the table names ....then i can run as a script.... U r help is greatly appriciated gurus!!!
    
    
    Thank you!!!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

    Administrator:

    set head off
    set pages 0
    set feed off
    spool myscript.sql
    Select 'grant select, insert, update, delete on abc.'||table_name||' to xyz;'
      from dba_tables
     where owner = 'ABC';
    
    Select 'create synonym xyz.'||table_name||' for abc.'||table_name||';'
      from dba_tables
     where owner = 'ABC';
    
    spool off;
    

    Obviously this does not all new table that will be created in the future on ABC schema...

    Max
    [My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/]

  • Implementation of dumps for several table

    Hello
    Is it possible to configure the < dumps-plan > element or implement dumps to get data from multiple
    table. Currently the sample xml and dumps in the tutorial is configured to a single table.

    Thank you
    -Trapani

    Hi Thiru,

    As Rob mentioned, you can implement dumps to do just about anything you want: do a join between tables, run several queries for data from multiple tables or even access non-base data system, such as an existing system or a web service to retrieve the data. Consistency really cares how you implement your cache store and where you get the data, as long as you return a single object to the load method, which must be inserted in the cache the cache store is set up for (or in the case of loadAll, many objects in a map).

    However, what I didn't understand not your question is if you want to load the data of several related tables to create a single object (an aggregate in DDD terminology), or if you want to create different entity objects based on the data in each table and put them all in the cache. Normally, you should have a cache by entity type, while the latter is discouraged until you know exactly why you do and are recommended to create a separate for each entity type cache and use different cache stores for them. Otherwise, you will encounter issues if you try to index your cache or run queries on it, because these characteristics depend on the schema of compatible entry.

    However, if you load an aggregate, you can decide to store the entire aggregate object in a single cache, in which case you will probably eventually query several tables related to construct an instance of an aggregate, or you may decide to store root cluster in its own cache, and separate the low related entities in caches, once again a cache by entity type. The choice should really depend on the size of small entities within an aggregate and access model data, so it is difficult to provide general guidance. However, if you do not end up storing weak entities in separate caches, it is usually advantageous to use the key association to ensure that they are located in the same partition as their aggregate root.

    Kind regards
    ALEKS

  • Trees does not not in 4.0 for several tables

    I built the query:

    Select case when connect_by_isleaf = 1 then 0
    When level = 1 then 1
    of another-1
    end the status,
    level,
    name as title,
    NULL as an icon,
    ID as the value,
    NULL as ToolTip

    de)
    To_char (nihub_qa_group_id) SELECT ID,
    NULL as parent,
    GroupName as name,
    NULL link,
    NULL a1,
    NULL A2
    OF nihub_qa_groups
    UNION ALL
    SELECT to_char (nihub_qa_group_id): ': ' | TO_CHAR (nihub_qa_tables_id) as id,
    TO_CHAR (nihub_qa_group_id) as a parent,
    table_NAME as name,
    NULL link,
    NULL a1,
    NULL A2
    OF nihub_qa_table_tree_v
    )
    Start with the parent is set to null
    connect by prior id = parent
    siblings arrested by name

    but the tree will not display. I get the error: Warning: tree root ID '10000' could not be found. and when I debug I get errors: ORA-06550: line 34, column 34: PL/SQL: ORA-00904: "ID": invalid identifier ORA-06550: line 3, column 13: PL/SQL: SQL statement ignored ORA-06550: line 37, column 64: PLS 00364: 'I' use the loop index variable is invalid ORA-06550: line 37, column 15: PL/SQL: statement ignored.

    My paintings is quite simple:

    nihub_qa_group:

    CREATE TABLE nihub_qa_groups
    (
    nihub_qa_group_id NUMBER NOT NULL,
    GroupName VARCHAR2 (255) NOT NULL CHECK (single)
    )
    ;



    ALTER TABLE nihub_qa_groups
    Add a CONSTRAINT "Group PK" PRIMARY KEY (nihub_qa_group_id);

    nihub_qa_tables:

    CREATE TABLE nihub_qa_tables
    (
    nihub_qa_tables_id NUMBER NOT NULL,
    table_name VARCHAR2 (250 BYTES),
    last_date_loaded DATE,
    last_row_count NUMBER,
    avg_records_loaded NUMBER,
    check_avg CHAR (1 BYTE),
    check_orphan CHAR (1 BYTE),
    check_domains CHAR (1 BYTE),
    check_date CHAR (1 BYTE),
    threshold_plus NUMBER,
    threshold_minus NUMBER,
    date_column VARCHAR2 (255 BYTES)
    )
    ;



    ALTER TABLE nihub_qa_tables
    ADD CONSTRAINT "nihub_qa_tables PK" PRIMARY KEY (nihub_qa_tables_id);



    and nihub_qa_table_tree_v is a point of view:

    VIEW to CREATE or REPLACE nihub_qa_table_tree_v (nihub_qa_group_id,
    nihub_qa_tables_id,
    table_name)
    IN SELECT
    nihub_group_table.nihub_qa_group_id,
    nihub_group_table.nihub_qa_tables_id,
    nihub_qa_tables.table_name
    Of
    nihub_group_table nihub_group_table,
    nihub_qa_tables nihub_qa_tables
    WHERE
    nihub_group_table.nihub_qa_tables_id = nihub_qa_tables.nihub_qa_tables_id;


    nihub_group_table is a correlator group_id and tables_id to support the relationship m:m. when I run the query in Toad or sql command in the APEX, I get:

    1 1 UNICA - 10000. -
    2 0 NIHUB_NETINSIGHT_VEIW_PARAMS - 10000:20000 -.
    2 0 NIHUB_NETINSIGHT_VIEWS - 10000:10000 -.
    2 0 NIHUB_NETINSIGHT_VISITS - 10000:30000 -.
    2 0 NIHUB_NETINSIGHT_VISIT_PARAMS - 10000:40000 -.
    1 GROUP 1 TEST - 20000 -.
    2 0 NIHUB_NETINSIGHT_VIEWS - 20000:10000 -.


    that is what I expect. Here, any help would be appreciated.

    Thanks in advance

    PAM

    Here is a document to create a tree in APEX 4 via a wizard: http://apex.oracle.com/i/doc/tree_query_create.htm#BABJAGJJ

    Thank you

    Tony Miller
    Webster, TX

    While it is true that technology is waiting for no man; stupidity always stops to accommodate new passengers.

    If you answer this question, please mark the thread as closed and give points where won...

  • Synonyms for several tables

    Hello

    I have a trigger which in a specific State, change 14 synonyms of 14 different paintings.

    The official documentation is not possible to create the synonym of more then one table at the same time.

    You know some tricks to simplify this operation?

    Thank you

    Ste

    Ste74 wrote:

    DB architecture, I have three 'groups' of tables (with 7 tables) with the same structure but different in data.

    Simply create an additional column of ACTION_GROUP and 7 tables with the same structure as those that already exist. List the tables of newly created partition by column ACTION_GROUP create 3 partitions with the values 1, 2 and 3. Add the ACTION_GROUP column to each of the 21 existing tables and tables 1 to the tables of Group 1, group 2 and group 3 3 table 2. Now, you can fill each partition table newly created through the exchange of the partition corresponding get and group the data in table rid your 21 original tables. Now you have 7 tables and all you need is WHERE ACTION_GROUP = added to your queries. Actually, same approach might work even without partitioning - you simply need to use insert instead of exchange of the partition.

    SY.

  • EO for several tables

    Hi all

    In the new page that I created, I have more than 8 tables I should use to display the data in the page. Also when I try to save the page, the data is saved using the API seeded. In this situation,

    (1) how to use the objects of entity for 8 different tables? Can I create associations between all these different tables?
    (2) that I need to record data using the API, I extend the OAPlsqlEntityImpl class in the EO. So, in this case, all postings must be done using getters and Setters at the level of the VO or EO?

    Please advice.

    Thank you all

    KK

    Hello

    1) Set the Foreign key using setAttribute Methods ? 
    

    When you create a VO based on multiple EO, there should be a link between these Office of assessment as primary key & Foregin key 8. And when you share a commitment that the value of your beans will be saved to the database. But the foreigner, you will need to set independently using setAttribute method because it will not be saved by his own.

    2) If i'm doing the validations at EO level, those setters and getters will be called before the Create(), Update() and Delete()
    methods in the EOImpl class. Is that true?
    

    Yes, you are right, it is called to create and update operation, but not to delete.

    Kind regards
    GYAN

  • CREATE VIEW for several tables

    Hello

    I have a lot of tables, each of them containing a serial number field, each number is unique all the tables.

    I need a notice like this:
    SERIAL_NUMBER  |  TABLE_NAME
    ----------------------------
    1              |T1
    2              |T2
    3              |T3
    4              |T1
    5              |T1
    6              |T4
    What is the best way (SQL) to create this view?

    Thanks in advance!

    Maybe something like this:

    create or replace view my_view as
    select serial_number, 'T1' table_name from t1 union all
    select serial_number, 'T2' table_name from t2 union all
    select serial_number, 'T3' table_name from t3;
    
  • Need help and suggestions for partitioned tables

    Hello

    We have a table and it is partitioned and partitioned with datetime column, IE... partition by range.

    I tried to run the query in the form below and it runs 1 HR and did not get the result and I kill the query.

    Select min (datetime) max (datetime) < big_table > maxdate, mindate; -2203M data in this table

    index also in place on these columns as a composite index (code, datetime, status, po_num)

    < big_table > - having columns like code, datetime, status, po_num, creation_date

    Here is the plan of the explain command:

    Hash value of plan: 228211001

    ------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    ------------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                   |     1.     8.  4009K (2) | 04:41:57 |       |       |

    |   1.  GLOBAL TRI |                   |     1.     8.            |          |       |       |

    |   2.   RANGE OF PARTITION ALL THE |                   |  2163M |    16G |  4009K (2) | 04:41:57 |     1. 1048575.

    |   3.    FULL RESTRICTED INDEX SCAN FAST | POSTATUSINDEX |  2163M |    16G |  4009K (2) | 04:41:57 |     1. 1048575.

    ------------------------------------------------------------------------------------------------------------

    Please give me any suggestions how to get the query faster.

    THX in advance

    You need to know which column mainly used in queries?

    If most of the request uses ID column, then partition of hash on ID will be beneficial.

  • A PL/SQL to add the archived redo log for logminer files - please help debug

    Hello

    I have a PL/SQL to add recovery logs a day archived files to logminer utility in order to catch all LMD, which happened for a paticular at a particular time scheme

    as below,

    -logmnr.sql

    Set serveroutput on

    declare

    v_redo_dictionary_file VARCHAR2 (100);
    v_archived_log_file VARCHAR2 (100);

    -catch all them archived redo logs today, put in a cursor

    CURSOR logfile_cur IS
    SELECT name from v$ archived_log WHERE the to_char (COMPLETION_TIME, 'dd_MM_yyyy') > '18_01_2010' and not in sequence # (select sequence # v$ archived_log WHERE DICTIONARY_BEGIN = 'YES' AND dictionary_end = 'YES');


    Start

    -Create the DICTIONARY file on the files of the SOURCE database redo

    sys. DBMS_LOGMNR_D.build (OPTIONS = > sys.) DBMS_LOGMNR_D.store_in_redo_logs);


    Select name from v_redo_dictionary_file from v$ archived_log where DICTIONARY_BEGIN = 'YES' AND dictionary_end = 'YES', and sequence # = (select MAX(sequence#) from v$ archived_log WHERE DICTIONARY_BEGIN = 'YES' AND dictionary_end = 'YES');

    -Add newspapers of dictionary files
    sys.dbms_logmnr.add_logfile (nom_fichier_journal = > v_redo_dictionary_file,)
    Options = > sys.dbms_logmnr.new);

    -Add the log files

    Open logfile_cur;

    LOOP

    SEEK logfile_cur INTO v_archived_log_file;
    EXIT WHEN logfile_cur % NOTFOUND;
    sys.dbms_logmnr.add_logfile (nom_fichier_journal = > v_archived_log_file);


    END LOOP;

    CLOSE Logfile_cur;

    -Start LogMiner, also enable the ddl

    sys.dbms_logmnr.START_LOGMNR (options = > dbms_logmnr.dict_from_redo_logs + dbms_logmnr.ddl_dict_tracking);

    EXCEPTION
    WHILE OTHERS
    THEN
    DBMS_OUTPUT. PUT_LINE (SQLERRM);

    END;
    /


    ###############
    SQL > @logmnr.sql
    ORA-01291: missing logfile

    PL/SQL procedure successfully completed.

    What I did wrong?

    Thank you very much
    Roy

    [Double wire | http://forums.oracle.com/forums/message.jspa?messageID=4035521#4035521]

  • Add several tables on a Page

    Hello

    I am building an application that handles (APEX 4.0) material inventory. I have an entry page that adds data to two or more tables at once. The page has two forms on it pointing to two separate tables. However when I try to run the page, it fails and returns an error:

    ORA-06550: line 1, column 437: PL/SQL: ORA-00904: "ORH_LAST_UPDATE_DATE": invalid identifier ORA-06550: line 1, column 7: PL/SQL: statement ignored
    Error failed to process row in the IDD_ID_DATA table.

    As far as I can see in the application, this column is not in question (I don't even do anything for her and she is nullable). I looked at the application itself as well as some research online but can't find anything useful...


    So my question is this: is it possible to add several tables to a page? If yes how?

    I'm new to APEX so any help would be greatly appreciated!

    UPDATE:

    I received an email from support of APEX team:

    «The answer is simple, it's you will need manually code processes query (and DML) If you want to maintain multiple tables on a page (there is a limit of a table when you use the integrated process).»
    For this I suggest that you remove the process generated by the wizards and create processes of PL/SQL with insert, update, delete statements as needed. "This encoding is not difficult but takes much longer when you can use the integrated process.

    I've been playing with code PL/SQL and the final result is the following:

    Start
    INSERT INTO table1
    VALUES)
    : P2_Item_Field1,.
    (: P2_Item_Field2);
              
    INSERT INTO table2
    VALUES)
    : P2_Item_Field1,.
    (: P2_Item_Field2);
    end;

    I used this code in a PL/SQL custom in the treatment process > section to the Page processing and it seems to work fine now. The only downside to this method is that if the name of a Page element is changed the code will also have to be changed. Except that I had no problem.

  • How to fill out (display) values for several blocks in which there is no relationship between the blocks (tables).

    Hello.

    Is it possible to fill in the values (execute_query) several blocks where there is absolutely no relationship between the tables in the same form?

    There is no relationship between the tables. All are separate tables with different columns. None of the names of columns match

    & also the values of the columns do not match. I created blocks for all tables. When I click on run, only the first block of values (first picture) is filled.

    other values of block did not get filled. Is it possible to fill in the values for all of the blocks where there is not relationship, or when there is no master block?

    Is there something I can do for this? It is mandatory for me to put all the blocks in a single form.

    Help me, please. Please do not respond.

    Thank you.

    Create a key-EXEQRY-trigger on the block where 'throw you' the quers. In it, put something like

    GO_BLOCK ('BLOCK1');

    EXECUTE_QUERY;

    GO_BLOCK ('BLOCK2');

    EXECUTE_QUERY;

    ...

  • Table of contents for several sheet file...?

    It is possible to:

    1. Create a Table of contents listing all sheets in a file?
    2. Have these hyperlink worksheet titles to the sheets themselves?

    I build what will eventually be a fairly large file (read: 75 + leaves). Rather than scrolling all the leaves one by one by one manually to locate the correct table, it would be useful to have a table of contents or an Index that lists the in order... Ideally, allowing the connection of hypertext link to the leaves they reference. (I swear that this was part of a way-back-when number...)

    Instead, is it possible to auto-trier worksheets in alphabetical order? He would not give me the project view as a table of contents or an Index of 35,000 feet, but at least it would be a little easier to find what it takes.

    Looking forward to sharing the wisdom...

    HI stephanie,.

    The numbers 2 (' 09) and 3 support not the hyperlinks to locations within the current document. Both take in charge of hyperlinks that open a Web page in your default browser or which will open and send a new e-mail message.

    Command-F can be your friend here.

    Place an array of single cell on each sheet (or use a cell on the existing table). Enter a short text string that identifies the table or sheet. Each string must be unique in the document.

    To access the card containing one of the following strings:

    Press Control + F to open the Find dialog.

    Enough chain to identify the worksheet type.

    Number will draw this roadmap forward as soon as it can determine which table contains the cell containing this string.

    Tested with four sheets containing:

    able, baker, charlie and delta

    With this limit together (and any other tables in the document - quite an artificial situation!), type c or d was enough to bring me to sheet 3 or 4, sheets 1 and 2 required two letters (ab or ba) to identify the good sheet and bring it forward.

    With a document containing several tables (and more leaves), create (and remembering) a separate channel for each becomes more complicated.

    You can place a second copy of each in a table of Index or table of contents on a separate sheet. From the index table,

    Copy the entry for the table/worksheet you want to go.

    Open the dialog to find (command-V)

    Paste the entry in the search box. (What it will find and highlight the entry that you have copied to the index table)

    Click on the > button on the dialog to find the occurrence FOLLOWING this string (on your target table.

    Kind regards

    Barry

  • I downloaded webmail add Blocker for firefox and now youtube does not display images... Help

    I have downlaoded webmail add Blocker for Firefox, so I can get rid of the side ad right in hotmail (Outlook) which works very well, but now many of the videos on youtube shows not a picture although I can hear the sound.

    Is my prolem I downloaded add blocker everything worked fine beforehand. If so, how can I get rid of the problem? Uninstall add blocker? How do I do that?

    Please help me. I'm old and not much less computers. My stress level go up when it does not work properly.

    Make sure that your ads block non-blocking images.

    GoTo > tools > Options > content

    • Check > 'load images automatically '.
  • Since the update Firefox 6.0, some websites do not load correctly. I suspect it has to do with the Java being disabled because of the compatability modules. When I try to go to Tools/Add-ons, I get the message "Loading" for several minutes without chang

    Update Firefox 6.0 is useless to me because many websites I visit are not displayed properly, I guess because the Java modules are disabled because of incompatibility. They appear correctly in Internet Explorer.

    In addition, the add-on from Trend Micro is not compatible, which leaves me with a positive feeling.

    When I try to check to see if these modules can be updated, the menu item Tools/Addons just goes to a page with "loading" and stays there for several minutes without change until I close it.

    I would like to know the procedure to regularize this version of Firefox to my previous version that worked.

    Firefox 5.0/5.0.1/4.0/4.0.1 and earlier 3.6.20 all contain questions of security and stability that will not be corrected. You put your system at risk by using any version of Firefox that 6.0 or 3.6.20. Any person who displays a link to other versions is to be irresponsible, in my opinion.

    Java

    If the incompatible extensions in Add-ons > Extensions are Java Console, you have no need them unless your doing Java development. Most of the users have not yet installed, but Java will install Java Console with each update. You can delete them manually:

    The only thing that affects the functioning of the sites/Java applets on the web is the plugin (Add-ons - > Plugins) "Java (TM) Platform SE (version)". Do not forget that it is enabled and that you have not all extensions which affect/block "scripts".

    Trend Micro

    You must contact Trend Micro or go to the forums on their website to inquire about their plans to update the add-ons/toolbars they install in Firefox.

    Problem with the display of the Add-ons Manager

    The Add-ons Manager gets in a loop of loading due to the recent update of Firefox 6 and servers being overloaded because users and update process are looking for updates to the add-on. If you stay away from the "Get Add-ons" selection on the left of the screen of the add-on Manager, you should have no problem with that. This situation is expected to resolve when the overload of Firefox 6 update is complete. I do not always use this "Get Add-ons" option, instead, I go to the website of modules and the search for what I want from there: https://addons.mozilla.org/en-US/firefox/search/?q=clone & cat = all & x = 0 & y = 0

Maybe you are looking for

  • How to choose photo album for screen saver?

    Upgrade to El Capitan, and among the many things that have changed or disappeared is to select what iPhoto (Yes, I know now his Photo) album to use for the screen saver. Previously, I could choose the album that I wanted to, but now it seems that the

  • WIFI does not work after installing WIN7 to HP Pavilion DV1000

    I hope you can help! After the complete collapse of the old WinXp I installed Win7 - mostly away from the ti works. However, WIFI does not work. (P/N is PY869PA #ABG, he also says dv1303ap on the label) Is there a driver for the available WLAN? Witou

  • AVG Free Edition or Security Scanner for MS 1.0.30001.0, who should I believe?

    AVG is infection by the Virus (Generic30.amon) reports on an executable installed in 2006.MS 1.0.30001.0 security scanner found no viruses or Malware.  Who should I believe? Naïve question of the day: a virus infect an exe without changing the date o

  • Subject of the vlan voice SRW224G4P

    Hello I have configured the SRW as vlan, use vlan for voice 212, 348 for data and communicate with cisco IP Phone. database of VLANVLAN, 210-216 345-348outputID of the vlan voice 212 ! !interface fastethernet1activate the storm controlStorm-control b

  • Video output cut but keeping audio in some places along the way

    Hi there, my office's plan to buy Premiere Elements but need to be able to do a specific thing... Can someone please confirm: are you able to have a video running and then hang it so some parts do play the video and audio?  In a sense, we want the au