Detroit SQL of the query in writing: analysis of the GAPS in order of Row_Wid in a Table

I am writing a query that scans a product Dimension Row_Wid, notes the gaps in the sequence and generates the missing Row_Wids. It loads these 'missing Feds"in a sequence of wid created table to reuse by Informatica transformation of research without bond during the subsequent data loads. Yes, I expect many people asking why I do this. The simple reason is that Informatica has a limit of 2 147 sequence generator 483 647'. I arrived at this upper limit, but my table contains only 2.2 million lines of actual data. I'm trying to reuse these Row_Wids now 'not used '.

I have a job with success the query to find the first ditch and fill some of that gap. Now my next problem is to figure out how to get my request to move away from the next. I can't use the PL/SQL in the query. My client does not allow its use.

I'll paste the code I have now. I need to evolve to the next gap. Suggestions? Help? Ideas?



The Version of database: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

The table I'm inserting: CREATE GLOBAL TEMPORARY TABLE "OLAP". "" ROWWIDVAL "("ROWWID"NUMBER (10.0), NUMBER (10,0)"EXTRAVAL") ON COMMIT PRESERVE ROWS;
A note: the Temp Table to test this point, I've created is "RowWidVal" and it has two columns.

-Updated Code collaboration-
Insert Into RowWidVal(
SELECT
     CASE
          WHEN NumGen <= GapSize+2 THEN (P2.MinGapStart-1)+NG.NumGen
     END RowWid, 0
FROM
     (SELECT MIN(T4.GapStart) MinGapStart, MIN(T4.GapStop) MinGapStop, (MIN(T4.GapStop) - MIN(T4.GapStart)) GapSize
          FROM
               (SELECT T2.row_wid + 1 GapStart,
                    (SELECT MIN(T1.row_wid) - 1 FROM w_product_d_test T1 WHERE T1.row_wid > T2.row_wid) GapStop
                    FROM w_product_d_test T2
                    LEFT OUTER JOIN w_product_d_test T3 ON T2.row_wid = T3.row_wid - 1
               WHERE T3.row_wid IS NULL
               ) T4
     WHERE T4.GapStop IS NOT NULL
  ) P2,
     (SELECT LEVEL NumGen
      FROM dual
      CONNECT BY LEVEL <= (SELECT ((Min(GapStop) - Min(T4.GapStart)) +1) GapSize
                               FROM
                                   (SELECT T2.row_wid + 1 GapStart,
                                        (SELECT MIN(T1.row_wid) - 1 FROM w_product_d_test T1 WHERE T1.row_wid > T2.row_wid) GapStop
                                        FROM w_product_d_test T2
                                        LEFT OUTER JOIN w_product_d_test T3 ON T2.row_wid = T3.row_wid - 1
                                        WHERE T3.row_wid IS NULL
                                   ) T4
                                    WHERE T4.GapStop IS NOT NULL)
     ) NG
WHERE P2.MinGapStart < P2.MinGapStart+(GapSize+2));
Published by: user1002601 on 16 January 2013 08:33

Published by: user1002601 on 16 January 2013 08:39

How about this?

Sample data:

SQL> create table w_product_d_test (row_wid number);

Table created

SQL>
SQL> insert into w_product_d_test (row_wid)
  2  select column_value
  3  from table(sys.odcinumberlist(1,2,3,4,5,11,12,13,31,32,33,34));

12 rows inserted

SQL> select * from w_product_d_test;

   ROW_WID
----------
         1
         2
         3
         4
         5
        11
        12
        13
        31
        32
        33
        34

12 rows selected
 

Generate sequence available numbers:

SQL> with gaps as (
  2    select rw, gapsize
  3    from (
  4      select row_wid as rw
  5           , row_wid - lag(row_wid,1,0) over(order by row_wid) - 1 as gapsize
  6      from w_product_d_test
  7    )
  8    where gapsize > 0
  9  )
 10  select g.rw - t.column_value as available_rw
 11  from gaps g
 12     , table(
 13         cast(
 14           multiset( select level from dual connect by level <= g.gapsize )
 15           as sys.odcinumberlist
 16         )
 17       ) t
 18  ;

AVAILABLE_RW
------------
          10
           9
           8
           7
           6
          30
          29
          28
          27
          26
          25
          24
          23
          22
          21
          20
          19
          18
          17
          16
          15
          14

22 rows selected
 

Tags: Database

Similar Questions

  • run a group of files sql in the background in order

    Hey,.

    I made a simple script tries to run a group of files sequentially, sql

    It looks like


    $cat run_background.sh

    nohup sqlplus < user name > / < password > @ < db_name > @1.sql &
    nohup sqlplus < user name > / < password > @ < db_name > @2.sql &
    nohup sqlplus < user name > / < password > @ < db_name > @3.sql &

    what I worry is: I don't want 1.sql, 2 sql and sql 3. run in parallel on data base.

    so is this okay script to run as I want?

    Thank you very much.

    ground. Beach wrote:

    2949037 wrote:

    Hey,.

    I made a simple script tries to run a group of files sequentially, sql

    It looks like

    $cat run_background.sh

    nohup sqlplus /@ @1.sql &
    nohup sqlplus /@ @2.sql &
    nohup sqlplus /@ @3.sql &

    what I worry is: I don't want 1.sql, 2 sql and sql 3. run in parallel on data base.

    so is this okay script to run as I want?

    Thank you very much.

    make the file all.sql

    that contains the following lines

    @1.sql

    @2.sql

    @3.sql

    output

    nohup sqlplus /@ @all.sql &

    You don't want the password of the user ID on the command line for safety reasons ;-)

  • Export as .xls. Classic report type: SQL (body of function from PL/SQL returning the SQL) query

    Hey guys,.

    I'm using version 4.2.6 apex. The theme is 26.

    IM also using Listener Oracle APEX.

    I can print my classic report in PDF or CSV format.

    But I need to export it as a .xls extension.

    Report type: SQL (body of function from PL/SQL returning the SQL) query

    I need is like this cause my 'where' clause type is dynamic.

    Look at using this method: Tom's Blog: a non-standard export excel 2010 (.xlsx)

    I do something similar for downloads to excel in my projects...

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • SQL script to query the entire database?

    Hello

    I have column names, I need to figure out what array these column names in the database.

    In dev and prod table names are different. I need to understand what is the name of the table with some columns in prod that exsits in dev. Any help is appreciated.

    I use

    Oracle Database 11 g Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    Thank you.

    Hello

    You can query the data dictionary view dba_tab_columns.

    For example, if you want to find who files an EMPNO and DEPTNO column:

    SELECT master, table_name

    FROM dba_tab_columns

    WHERE nom_de_colonne IN ('EMPNO', 'DEPTNO')

    GROUP BY master, table_name

    HAVING COUNT (*) = 2

    ORDER BY owner, table_name

    ;

  • query sql in the OPS

    Hi all

    I need to get a value using a request in the LICS of the controller.below sql is the query

    sqlText = "SELECT application_id ';
    sqlText += 'FROM ego_attr_groups_v ';
    sqlText += ' WHERE attr_group_name = 'TREASURE "";

    I would like to know how get the jdbc connection, run the query and assign to a variable.

    Help, please.

    Thank you
    Robet

    Hello

    Import oracle.jdbc.OraclePreparedStatement;
    Import oracle.jdbc.OracleResultSet;
    Import oracle.apps.fnd.framework.server.OADBTransaction;

    see the following code

    OAMessageChoiceBean lineTypeBean = (OAMessageChoiceBean) webBean.findChildRecursive ("LineType");
    OraclePreparedStatement oraclePreparedStatement = null;
    OracleResultSet oracleResultSet = null;

    String lineTypeIdValue = null;
    StringBuffer stringBuffer = new StringBuffer();

    stringBuffer.append ("SELECT line_type_id FROM apps.po_line_types_val_v");
    stringBuffer.append ("WHERE SUPERIOR (line_type) = UPPER (" ' ");")
    stringBuffer.append (lineTypeStr);
    stringBuffer.append("')");
    OADBTransaction oadbTransaction = am.getOADBTransaction ();
    try {}
    oraclePreparedStatement (OraclePreparedStatement) = oadbTransaction.createPreparedStatement (stringBuffer.toString (), 1);
    oracleResultSet (OracleResultSet) = oraclePreparedStatement.executeQuery ();
    {if (oracleResultSet.Next ())}
    lineTypeIdValue = oracleResultSet.getString (1);
    }
    on the other
    oracleResultSet.close ();
    }
    {} catch (sqlexception Exception)
    pageContext.putDialogMessage (new OAException ("OraclePreparedStatement OR OracleResultSet Exception"));
    sqlexception.printStackTrace ();
    }

  • Tables created in a stored procedure cannot be used with dynamic SQL? The impact?

    There is a thread on the forum which explains how to create tables within a stored procedure (How to create a table in a stored procedure , however, it does create a table as such, but not how to use it (insert, select, update, etc.) the table in the stored procedure.) Looking around and in the light of the tests, it seems that you need to use dynamic SQL statements to execute ddl in a stored procedure in Oracle DB. In addition, it also seems that you cannot use dynamic SQL statements for reuse (insert, select, update, etc.) the table that was created in the stored procedure? Is this really the case?

    If this is the case, I am afraid that if tables cannot be 'created and used"in a stored procedure using the dynamic SQL, as is the case with most of the servers of DB dynamic SQL is not a part of the implementation plan and, therefore, is quite expensive (slow). This is the case with Oracle, and if yes what is the performance impact? (Apparently, with Informix, yield loss is about 3 - 4 times, MS SQL - 4 - 5 times and so on).

    In summary, tables created within a stored procedure cannot be 'used' with dynamic SQL, and if so, what is the impact of performance as such?

    Thank you and best regards,
    Amedeo.

    Published by: AGF on March 17, 2009 10:51

    AGF says:
    Hi, Frank.

    Thank you for your response. I understand that the dynamic SQL is required in this context.

    Unfortunately, I am yet to discover "that seeks to" using temporary tables inside stored procedures. I'm helping a migration from MySQL to Oracle DB, and this was one of the dilemmas encountered. I'll post what is the attempt, when more.

    In Oracle, we use [global temporary Tables | http://www.psoug.org/reference/OLD/gtt.html?PHPSESSID=67b3adaeaf970906c5e037b23ed380c2] aka TWG these tables need only be created once everything like a normal table, but they act differently when they are used. The data inserted in TWG will be visible at the session that inserted data, allowing you to use the table for their own temporary needs while not collide with them of all sessions. The data of the TWG will be automatically deleted (if not deleted programmatically) when a) a commit is issued or b) the session ends according to the parameter that is used during the creation of the TWG. There is no real need in Oracle to create tables dynamically in code.

    I noticed that many people say that the "Creation of the tables within a stored procedure" is not a good idea, but nobody seems necessarily explain why? Think you could elaborate a little bit? Would be appreciated.

    The main reason is that when you come to compile PL/SQL code on the database, all explicit references to tables in the code must correspond to an existing table, otherwise a djab error will occur. This is necessary so that Oracle can validate the columns that are referenced, the data types of those columns etc.. These compilation controls are an important element to ensure that the compiled code is as error free as possible (there is no accounting for the logic of programmers though ;)).

    If you start to create tables dynamically in your PL/SQL code, so any time you want to reference this table you must ensure that you write your SQL queries dynamically too. Once you start doing this, then Oracle will not be able to validate your SQL syntax, check the types of data or SQL logic. This makes your code more difficult to write and harder to debug, because inevitably it contains errors. It also means that for example if you want to write a simple query to get that one out in a variable value (which would take a single line of SQL with static tables), you end up writing a dynamic slider all for her. Very heavy and very messy. You also get the situation in which, if you create tables dynamically in the code, you are also likely to drop tables dynamically in code. If it is a fixed table name, then in an environment multi-user, you get in a mess well when different user sessions are trying to determine if the table exists already or is the last one to use so they can drop etc. What headache! If you create tables with table names, then variable Dynamics not only make you a lot end up creating (and falling) of objects on the database, which can cause an overload on the update of the data dictionary, but how can ensure you that you clean the tables, if your code has an exception any. Indeed, you'll find yourself with redundant tables lying around on your database, may contain sensitive data that should be removed.

    With the TWG, you have none of these issues.

    Also, what is the impact on the performance of the dynamic SQL statements in Oracle? I read some contrasting opinions, some indicating that it is not a lot of difference between static SQL and SQL dynamic in more recent versions of Oracle DB (Re: why dynamic sql is slower than static sql is this true?)

    When the query runs on the database, there will be no difference in performance because it is just a request for enforcement in the SQL engine. Performance problems may occur if your dynamic query is not binding variable in the query correctly (because this would cause difficult analysis of the query rather than sweet), and also the extra time, to dynamically write the query running.

    Another risk of dynamic query is SQL injection which may result in a security risk on the database.

    Good programming will have little need for the tables of dynamically created dynamically or SQL.

  • Information on how to execute SQL on the CUCM himself queries please

    Hello all,.

    I need to run a SQL on the CUCM enumerate all directory numbers, their score and their external mask values.

    I came across this snippet below earlier so I have a bit of an idea of how do but iw would be great to see some other examples of sql queries.

    Any help is most appreciated.

    Also, is there a document somewhere to tell me how to run these queries?

    Thanks in advance

    Concerning

    Amanda

    *******************************************************************************************************************************************************************************

    Helps you try if this the CLI SQL query execution, it must list all DN with CFA allowed the VM or a DN:

    run sql select dnorpattern, cfadestination, cfavoicemailenabled CallForwardDynamic c, numplan n where c.fknumplan = n.pkid and (cfadestination! = "or cfavoicemailenabled 't =')

    Hi Amanda

    Basically, this is standard SQL, so that he would not bad at google 'informix instructions' select and do a bit of reading to get the basics. There are millions of permutations of requests so it comes to understand the syntax and then only by applying to the database in question. The only difference when running the commands in the CLI are:

    -Precede you the standard informix with "execute sql" SQL statement

    -You get no help from CUCM with syntax, so you might be well advised to use something which includes SQL a bit and he colorized you type, and then paste the commands resulting in the CUCM SSH window. I use an editor called JEdit, if you create a text file and save it as a file ending with .sql, it will highlight your syntax.

    -Other programs are available that make reasonable syntactic (EQ SquirrelSQL) that are designed to query the DB directly, but you can't really query directly against the DB for security reasons. You will still need to copy and paste commands.

    Now... to understand the DB you will need a reference describing all the tables, etc.. Here it is:

    http://www.Cisco.com/en/us/products/SW/voicesw/ps556/products_programming_reference_guides_list.html

    Choose your version of CUCM and download the document 'data definition '.

    Some notes on the order:

    run sql: is just the CLI command which tells the shell to perform the following as SQL.

    Select: the SQL command to recover data

    dnorpattern, cfadestination, cfavoicemailenabled: column names to retrieve

    callforwarddynamic c, numplan n: the names of the two tables and abbreviations that you want to refer to them as

    where c.fknumplan = n.pkid: This tells SQL to return values in the two tables where these fields match. In the data definition, you will see notes that c.fknumplan (i.e. the column fknumplan in table callforwarddynamic, as indicated by the prefix c.) refers to the PKID column in the area of the numplan. It is a type of join in the very standard DB CCM.

    and ("cfadestination! =" or cfavoicemailenabled = "t"): another clause, fundamentally in this application that we want to see only the rows where cfadestination is not empty or cfavoicefmailenabled has the value 't' for real).

    Most of the tables are related in two ways in this database:

    -a column "fk" prefix refers to the field of pkid (there is always only one field per table pkid) in the table following the prefix "fk". For example above fknumplan refers to the numplan, pkid field table. fkdevice refers to the machine table, pkid field.

    -a prefiex of 'traditional knowledge' column usually refers to a table enum which is preceded by 'type '. It is a table that maps the numerical value in the field of 'traditional knowledge' into a string. An example would be tkmodel - it is the type of physical phone (e.g. as 7962) and mapped as the column and a table called typemodel model 'enum' in the table.

    Concerning

    Aaron Harrison

    Senior Engineer at Logicalis UK

    Please note the useful messages...

  • Why I don't see physical sql in the log file

    Hello everyone,

    I try to get the physical sql for one of my analysis on OBIEE. I copied and paste logic sql code into the editor of "PROBLEM SQL" on the Advanced tab, and check the log file. However, there is no physical sql code for this analysis. I find any other analysis. What can be the problem? Can he be on the physical tables / issue privileges etc.?

    Kind regards

    Dilek

    Hello everyone,

    I found the solution to my problem. Because I used the filter that contains the result of another analysis, physical sql code is not generated in the log file. When I remove it, it's ok. I'm going to how to change the filter condition. Then the problem is resolved.

    Kind regards

    Dilek

  • How to find the best log of SQL in the responses of the OBI?

    While I have an error by a request of the OBI in answers page, the error message in the result tab is usually not very useful, as:
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27005] Unresolved column: "Sales Facts Current Month"."Amount Sold (000) Current Month". (HY000)
    SQL Issued: {call NQSGetQueryColumnInfo('SELECT "Sales Facts Current Month"."Amount Sold (000) Current Month", "Sales Facts"."Amount Sold", Calendar."Calendar Month Desc", Calendar."Calendar Month Name", Products."Prod Category" FROM SH')}
    
    SQL Issued: SELECT "Sales Facts Current Month"."Amount Sold (000) Current Month", "Sales Facts"."Amount Sold", Calendar."Calendar Month Desc", Calendar."Calendar Month Name", Products."Prod Category" FROM SH
    I then go to the Session Monitor and click the view log. By doing so, sometimes, I got the complete sql statement. It is good and I can understand the problems. Sometimes, I have things like:
    -------------------- SQL Request:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_SRC_PATH='/shared/sh/Learn';SELECT Times."Calendar Month Name" saw_0, Times."Calendar Month Desc" saw_1, Products."Prod Category" saw_2, Salesfacts."Amount Sold" saw_3, REPORT_SUM(saw_3 BY saw_0, saw_1), REPORT_SUM(saw_3 BY ) FROM SH WHERE (TOPN(Times."Calendar Month Id",40) <= 40) AND (Channels."Channel Desc" = 'Direct Sales') ORDER BY saw_1, saw_0, saw_2
    
    +++Administrator:13290000:1329000f:----2009/09/29 09:18:33
    -------------------- General Query Info:
    Repository: Star, Subject Area: SH, Presentation: SH
    +++Administrator:13290000:1329000f:----2009/09/29 09:18:33
    -------------------- Cache Hit on query:
    Matching Query:     SET VARIABLE QUERY_SRC_CD='Report';SELECT Times."Calendar Month Name" saw_0, Times."Calendar Month Desc" saw_1, Products."Prod Category" saw_2, Salesfacts."Amount Sold" saw_3 FROM SH WHERE (TOPN(Times."Calendar Month Id",40) <= 40) AND (Channels."Channel Desc" = 'Direct Sales') ORDER BY saw_0, saw_1, saw_2
    Created by:     Administrator
    It is not enough that the selected tables are not entirely clear on. It appears like it find OBI the sql in the cache and process the request entirely.

    Is there a way I can force return OBI demand? Is there a way to get OBI newspaper the complete sql statement? This way I can copy the SQL to SQL * more and find exactly the problem

    Thank you.

    Physical SQL is not visible because it hits the cache.
    You can:
    (1) clear RPD physical cache and run the query again.
    or
    (2) copy the SQL logic, go to web Admin - number SQL - paste the SQL logic, then just change a setting or two, so it does not hit the cache. For example, to change a filter to Jan Feb... or just add a dummy column initially as select 1 or select 'a'... .rest of sql even.

    in this way, you can avoid hitting the cache and see the sql code (at the bottom of the results - view the journal)

    Make sure that you have enabled the option to cache presentation server and define the level of logging to 4 or more to see the details.

    HTH

  • SQL +-PROBLEM OF QUERY IN MULTI TABLE

    HAI ALL,

    ANY SUGGESTION PLEASE?

    SUP: SQL +-PROBLEM OF QUERY IN MULTI TABLE


    SQL + QUERY DATA:
    -----------
    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,

    HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,

    PATIENTS_MASTER1 DLC_POLYMORPHS_NORMAL_VALUE, HAEMATOLOGY1,

    DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM AND PATIENT_NUM = DLC_PATIENT_NUM AND PATIENT_NUM

    = & PATIENT_NUM;
    -----------
    RESULT:

    & PATIENT_NUM = 1
    no selected line
    ---------
    & PATIENT_NUM = 2
    no selected line
    ------------
    & PATIENT_NUM = 3
    PATIENT_NUM 3

    PATIENT_NAME KKKK

    HMTLY_TEST_NAME HEMATOLOGY

    HMTLY_RBC_VALUE 4
    4.6 - 6.0 HMTLY_RBC_NORMAL

    DLC_TEST_NAME LEUKOCYTE COUNT PREMIUM

    DLC_POLYMORPHS_VALUE 60

    DLC_POLYMORPHS_NORMAL_VALUE 40-65

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

    REAL WILL BE:

    & PATIENT_NUM = 1

    PATIENT_NUM 1

    PATIENT_NAME BBBB

    HMTLY_TEST_NAME HEMATOLOGY

    HMTLY_RBC_VALUE 5
    4.6 - 6.0 HMTLY_RBC_NORMAL

    -----------

    & PATIENT_NUM = 2

    PATIENT_NUM 2

    PATIENT_NAME GEORGE

    DLC_TEST_NAME LEUKOCYTE COUNT PREMIUM

    DLC_POLYMORPHS_VALUE 42

    DLC_POLYMORPHS_NORMAL_VALUE 40-65
    ---------------
    & PATIENT_NUM = 3
    PATIENT_NUM 3

    PATIENT_NAME KKKK

    HMTLY_TEST_NAME HEMATOLOGY

    HMTLY_RBC_VALUE 4
    4.6 - 6.0 HMTLY_RBC_NORMAL

    DLC_TEST_NAME LEUKOCYTE COUNT PREMIUM

    DLC_POLYMORPHS_VALUE 60

    DLC_POLYMORPHS_NORMAL_VALUE 40-65
    ----------------------------

    4 TABLES OF LABORATORY CLINIC FOR DATA ENTRY AND GET REPORT ONLY FOR THE TESTS CARRIED OUT FOR PARTICULAR

    PATIENT.

    TABLE1:PATIENTS_MASTER1
    COLUMNS: PATIENT_NUM, PATIENT_NAME,

    VALUES:
    PATIENT_NUM
    1
    2
    3
    4
    PATIENT_NAME
    BENAMER
    GIROT
    KKKK
    PPPP
    ---------------
    TABLE2:TESTS_MASTER1
    COLUMNS: TEST_NUM, TEST_NAME

    VALUES:
    TEST_NUM
    1
    2
    TEST_NAME
    HEMATOLOGY
    DIFFERENTIAL LEUKOCYTE COUNT
    -------------

    TABLE3:HAEMATOLOGY1
    COLUMNS:
    HMTLY_NUM, HMTLY_PATIENT_NUM, HMTLY_TEST_NAME, HMTLY_RBC_VALUE, HMTLY_RBC_NORMAL_VALUE

    VALUES:
    HMTLY_NUM
    1
    2
    HMTLY_PATIENT_NUM
    1
    3
    MTLY_TEST_NAME
    HEMATOLOGY
    HEMATOLOGY
    HMTLY_RBC_VALUE
    5
    4
    HMTLY_RBC_NORMAL_VALUE
    4.6 - 6.0
    4.6 - 6.0
    ------------

    TABLE4:DIFFERENTIAL_LEUCOCYTE_COUNT1
    COLUMNS: DLC_NUM, DLC_PATIENT_NUM, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE, DLC_POLYMORPHS_

    NORMAL_VALUE,

    VALUES:
    DLC_NUM
    1
    2
    DLC_PATIENT_NUM
    2
    3
    DLC_TEST_NAME
    DIFFERENTIAL LEUKOCYTE COUNT
    DIFFERENTIAL LEUKOCYTE COUNT
    DLC_POLYMORPHS_VALUE
    42
    60
    DLC_POLYMORPHS_NORMAL_VALUE
    40-65
    40-65
    -----------------


    Thank you
    RCS
    E-mail:[email protected]
    --------

    I think you want an OUTER JOIN

    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
     HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
     DLC_POLYMORPHS_NORMAL_VALUE
    FROM PATIENTS_MASTER1, HAEMATOLOGY1,  DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM (+)
    AND PATIENT_NUM = DLC_PATIENT_NUM (+)
    AND PATIENT_NUM = &PATIENT_NUM;
    

    Published by: shoblock on November 5, 2008 12:17
    the outer join brands became stupid emoticons or something. try hard

  • Please, be it a while I worked with oracle, but I need to develop my self in PL/SQL. But I'm a challenge to navigate from SQL to the windows command prompt 'diary of the oracle@oel6 '. I often do that before Linux but I don't even know

    Please help

    Janet Oluwadunsin wrote:

    Thanks Steve, I appreciate your correction.

    I want to start the listener from the command prompt, I have connected successfully to sql plus, but I don't remember how I'll get my way to

    [oracle@oel6 journal] $

    at startup my interlocutor.

    I hope this helps

    And just to clarify my and other previous posts... you do NOT get to a command prompt and start your receiver from sqlplus.  sqlplus is a command-line that connects to a database and provides a user interface to the question of the sql to the database statements.  lsncrctl is another command line utility, used to send commands to the listener.  lsnrctl and sqlplus are two completely separate and distinct, all tools two started from the command line of the operating system, that have nothing to do with the other.  Neither one is a kind of 'gateway' to the other.

  • SQL * more the 'timing' in SQL Developer command

    I installed SQL Developer version 4.1.1.19. In the sql worksheet, how can I use SQL * more order 'timing' in a script to see a time elapsed SQL? The "Timing" on 'set' did not return any info after running SQL, and 'calendar beginning mon_timer' back 'command Timing is obsolete. Help, please.

    Thank you

    • As you can see, there is no calendar information in the script output log.
    • Then I tried on the discussion forum, found it can be enabled in "tool > preference > Database > startup script" and set as startup script:

    Set serveroutput on

    set timing on

    • However, 2 questions are:
    1. the calendar that he returned is NOT the elapsed time of my stored procedure to run. He simply choose the 2 time points its time, before and not after MS point run. Set timing on is therefore not a solution for me.
    2. He did not follow the instructions in the startup script. After that I put the calendar in the startup script, stop & restart SQL Developer, same laptop charging, timing still on. The only way to turn off now is to configure it to NOT use

    any startup script.

    • Then I developed my own coding as a solution:

    3. control of the COIL

    VAR bv_start_ts VARCHAR2 (30)

    VAR bv_end_ts VARCHAR2 (30)

    VAR bv_elps_ts VARCHAR2 (30)

    DECLARE

    v_start_ts VARCHAR2 (30);

    BEGIN

    SELECT TO_CHAR (SYSTIMESTAMP, 'yyyymmddfxDyhh24miss.ff6') INTO v_start_ts FROM DUAL;

    : bv_start_ts: = v_start_ts;

    END;

    /

    IMPRESSION bv_start_ts

    EXEC pmsmmi.rpt.rpt_ethncty_race_smry (15);

    DECLARE

    v_end_ts VARCHAR2 (30);

    BEGIN

    SELECT TO_CHAR (SYSTIMESTAMP, 'yyyymmddfxDyhh24miss.ff6') INTO v_end_ts FROM DUAL;

    : bv_end_ts: = v_end_ts;

    END;

    /

    IMPRESSION bv_end_ts

    EXEC: bv_elps_ts: = TO_CHAR (TO_TIMESTAMP (: bv_end_ts, 'yyyymmddfxDyhh24miss.ff6')-TO_TIMESTAMP (: bv_start_ts, 'yyyymmddfxDyhh24miss.ff6'), 'hh:mi:ss.ff6');

    IMPRESSION bv_elps_ts

    SPOOL OFF

    • Then I got what I want, the answer is in the 'PRINT ': bv_elps_ts

    SQL > VAR bv_start_ts VARCHAR2 (30)

    SQL > VAR bv_end_ts VARCHAR2 (30)

    SQL > VAR bv_elps_ts VARCHAR2 (30)

    SQL > DECLARE

    v_start_ts VARCHAR2 (30);

    BEGIN

    SELECT TO_CHAR (SYSTIMESTAMP, 'yyyymmddfxDyhh24miss.ff6') INTO v_start_ts FROM DUAL;

    : bv_start_ts: = v_start_ts;

    END;

    /

    PL/SQL procedure successfully completed.

    Elapsed time: 00:00:00.031

    SQL > PRINT bv_start_ts

    BV_START_TS

    -----------

    20150702Thu112617.775545

    SQL > EXEC pmsmmi.rpt.rpt_ethncty_race_smry (15)

    PL/SQL procedure successfully completed.

    SQL > DECLARE

    v_end_ts VARCHAR2 (30);

    BEGIN

    SELECT TO_CHAR (SYSTIMESTAMP, 'yyyymmddfxDyhh24miss.ff6') INTO v_end_ts FROM DUAL;

    : bv_end_ts: = v_end_ts;

    END;

    /

    PL/SQL procedure successfully completed.

    Elapsed time: 00:00:00.062

    SQL > PRINT bv_end_ts

    BV_END_TS

    ---------

    20150702Thu112630.805786

    SQL > EXEC: bv_elps_ts: = TO_CHAR (TO_TIMESTAMP (: bv_end_ts, 'yyyymmddfxDyhh24miss.ff6')-TO_TIMESTAMP (: bv_start_ts, 'yyyymmddfxDyhh24miss.ff6'), 'hh:mi:ss.ff6')

    PL/SQL procedure successfully completed.

    SQL > PRINT bv_elps_ts

    BV_ELPS_TS

    ----------

    + 00:00:13.030241000 000000

    SQL > SPOOL OFF

  • After running sql of the lot, it is disconnected

    Hi all

    I wrote a batch program to run a pl/sql procedure. But after running, it disconnects.

    But I want to continue in the same session

    echo exec tracer.trace_pck.start_('alter session set sql_trace=true') | sqlplus hr/hr
    

    Output:

    Press a key to activate tracing

    SQL * more: Production of liberation 11.2.0.2.0 Thu Oct 10 15:59:56 2013

    Copyright (c) 1982, 2010, Oracle.  All rights reserved.

    Connected to:

    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production

    SQL >

    PL/SQL procedure successfully completed.

    SQL > disconnected from Oracle Database 11 g Express Edition Release 11.2.0.2.0.

    Production

    Trace enabled successfully. Press a key for entry you sql

    If you use a batch file, I assume you are using windows OS.

    Essentially, what you need to do is call a sql file in the batch file and then download the sql file to call all the other files.

    Batchfile test.bat file test.sql sql calls

    sqlplus /password @test.sql

    test. SQL calls test1.sql and test2.sql and stops

    @test1.sql;

    @test2.sql;

    "exit";

    test1. SQL displays the current sid and serial No. FRO our name and our session

    Select 'test1', sid, serial # in session $ v

    where audsid = userenv ('sessionid');

    test2. SQL displays the current sid and serial for our name and our session No.

    Select "test2", sid, serial # in session $ v

    where audsid = userenv ('sessionid');

    When you run this you get t output similar to the following: (your SID and serial will be different)

    ' TEST SID SERIAL #.

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

    771 97 Test1

    ' TEST SID SERIAL #.

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

    771 97 test2

    It shows two separate sql files have been called, but are always in the same session

  • SQL for the calculation of the salary

    Version: 11.2

    Permanent employees get monthly salary, contract workers get only commission.
    Some permanent employees such as PETER and JOHANN get salary and Commission


    I want to find the total amount paid to permanent and non-permanent.

    The computation of the total, for employees who receive the salary and Commission as PETER and JOHANN, I want to ignore the Commission and considers that pay them for the calculation of total compensation.
    ie. When computing the total amount paid to all these employees
    
        I want to ignore commision of 400 received by PETER 
        and
        I want to ignore commision of 1000 received by  JOHANN
    That is to say. The Total amount paid will be: 18 500

    create table pay_master (emp_type varchar2(50) , empname varchar2(50), salary number , comm number );
    
    
    insert into pay_master values ( 'PERM', 'KAREN' , 2000, 0 );
    insert into pay_master values ( 'PERM', 'HANS'  , 3000, 0 );
    insert into pay_master values ( 'CONTRACT', 'KEITH'  , 0, 1000 );
    
    insert into pay_master values ( 'CONTRACT', 'ABDUL'  , 0, 2000 );
    insert into pay_master values ( 'PERM', 'KRISHNA'  , 1000, 0 );
    insert into pay_master values ( 'CONTRACT', 'CHENG'  , 0, 1500 );
    insert into pay_master values ( 'PERM', 'PETER'  , 5000, 400 );
    insert into pay_master values ( 'PERM', 'JOHANN'  , 3000, 1000 );
    
    
    col EMP_TYPE format a10
    col EMPNAME format a10
    
    SQL> select * From pay_master order by empname;
    
    EMP_TYPE   EMPNAME        SALARY       COMM
    ---------- ---------- ---------- ----------
    CONTRACT   ABDUL               0       2000
    CONTRACT   CHENG               0       1500
    PERM       HANS             3000          0
    PERM       JOHANN           3000       1000           ---------------> Ignore this commision when calculating the total pay
    PERM       KAREN            2000          0
    CONTRACT   KEITH               0       1000
    PERM       KRISHNA          1000          0
    PERM       PETER            5000        400           ---------------> Ignore this commision when calculating the total pay
    
    8 rows selected.
    
    SQL> select EMPNAME , salary+comm from pay_master order by empname;
    
    EMPNAME    SALARY+COMM
    ---------- -----------
    ABDUL             2000
    CHENG             1500
    HANS              3000
    JOHANN            4000
    KAREN             2000
    KEITH             1000
    KRISHNA           1000
    PETER             5400
    
    8 rows selected.
    
    SQL> select sum(salary+comm) from pay_master;
    
    SUM(SALARY+COMM)
    ----------------
               19900
    
    
    Expected output from the SQL with the above mentioned logic is 18500
    How can I do this in SQL? I think that I can't use CASE here statement because the CASE statement works only in a single column. Right?

    Hello

    J.Kiechle wrote:
    ... I think that I can't use CASE here statement because the CASE statement works only in a single column. Right?

    A CASE results in a single value expression. It may depend on any number of columns (that is, of reference): 0, 1, 2, 3 or more.

    For example, the following is based on 2 columns, x and y:

    CASE
        WHEN  x > y
        THEN  x
        ELSE  y
    END
    

    which is just another way to get the same results that

    GREATEST (x, y)
    

    You can use either of the foregoing, for your problem (assuming that the salary and the Commission are always 0 or more).

    Published by: Frank Kulash, Sep 21, 2012 05:40

  • Embedded SQL. vs embedded PL/SQL in the ProC

    Hi all

    Start looking at the code embedded SQL, for the first time for many years. My question is: what (if any) are the benefits of the incorporation of PL/SQL in Pro * C (11g), rather than incorporate SQL? The code I inherited uses embedded SQL, but I thought it was a performance improvement using embedded PL/SQL.

    Are there specific reasons / examples when 1 is better than the other? Can you not always replace embedded SQL with embedded PL/SQL in Pro * C?

    Thanks in advance!

    -bw

    SQL and PL/SQL are not languages integrated (in C/C++ using Pro * C).

    An embedded is a language that is inside the application, that allows to modify and control the behavior of the application. JavaScript is a good example. It lies within the Web browser application. It can be used to improve the interaction between the application with the user (e.g., creating a rich interface), and how the application interacts with the web server (e.g. Ajax).

    The best language to use to talk to the database, depends on the nature of the database and the application. A written report request obviously need to use the language of SQL Server directly - as it will build dynamically SQL queries in order to meet the reporting criteria provided by the user (for example, the Business Objects application).

    For a type OLTP database and application, PL/SQL Server language is better - as the management interface full (create an invoice, invoice a customer, order a product, etc.) can be and should be build using the PL/SQL language. The application uses this interface, exactly the same way that it would use other interfaces (e.g. the GDI for rendering, the printing interface for printing invoices, MS Office COM interface for the creation of a letter to the customer, etc.).

    PL/SQL interface insulates the application from the database model. The application has no need to use SQL statements. The application doesn't have to worry about SQL and database performance. The interface of PL/SQL layer treats all of this. Changes and updates and changes to databases, can be totally transparent, because PL/SQL interface hide these changes to the application.

    This approach makes it easier for developers write application (didn't need to know SQL or PL/SQL, or have a solid understanding of the basics of Oracle). And as the business logic resides in PL/SQL, another business application will use the exact same interface and the business logic. So there a consistent interface to the database in all database applications using this database.

    As the design and drafting of the custom report applications are relatively rare, most Pro * C applications should make PL/SQL calls and should not use language SQL Server directly. PL/SQL will be used to create SQL cursors then move the handles of these Pro slider * C code. This code will then seek and consume the output SQL cursor (without needing SQL statements).

Maybe you are looking for