SQL select not data!

Hi, need help with folowing SQL

In this case, Sql return value

SELECT * FROM (select
min(id) AS id, hin_id as hin_id,code  as code, name as name,
min(valid_date_to) as valid_date_to
,max(valid_date_from) as valid_date_from
from subsidiaries
where ID = 50335
GROUP BY hin_id, code, name
order by code) ;

In this case is not

SELECT * FROM (select
min(id) AS id, hin_id as hin_id,code  as code, name as name,
min(valid_date_to) as valid_date_to
,max(valid_date_from) as valid_date_from
from subsidiaries

GROUP BY hin_id, code, name
order by code)
QRSLT  WHERE (( ID = 50335 ));

Why? And how I can fix this isue?

Thank you

ID.

Hello

1D10T wrote:

Hi, need help with folowing SQL

In this case, Sql return value

  1. SELECT * FROM (select
  2. min (ID) AS id, hin_id as hin_id, code as code, name, that
  3. min (valid_date_to) as valid_date_to
  4. max (valid_date_from) as valid_date_from
  5. subsidiaries
  6. WHERE ID = 50335
  7. GROUP BY hin_id, code, name
  8. order by code);

In this case is not

  1. SELECT * FROM (select
  2. min (ID) AS id, hin_id as hin_id, code as code, name, that
  3. min (valid_date_to) as valid_date_to
  4. max (valid_date_from) as valid_date_from
  5. subsidiaries
  6. GROUP BY hin_id, code, name
  7. order by code)
  8. QRSLT WHERE ((ID = 50335));

Why? And how I can fix this isue?

Thank you

ID.

The first query you're giving information on all lines that have IDs = 50335.

The second query you give information about groups where the lowest id in the group is 50335.  If the group is selected (and none of them are with sample data that you use), then the information displayed will include the IDS above 50335, as well as the lines where id is NULL.

How to fix depends on your data, and what results you want that data.

Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.

Explain, using specific examples, how you get these results from these data.

Always say what version of Oracle you are using (for example, 11.2.0.2.0).

See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

The first query you posted is a way to solve the problem.  Replacement of the WHERE clause in the second query with a HAVING clause is another.  There are hundreds of other ways.

Tags: Database

Similar Questions

  • SQL - select the data with the nearest past date

    Hello
    I have a requirement to retrieve data based on a closer effective_date in the past.
    Here are examples of data

    Data in the table

    DESCRIPTION OF ARTICLE EFFECTIVE_DATE
    ---------------------------------------------------------------------------
    018885237 24 OCTOBER 09 DVD + R 47 10 PK
    DISC OF DVD + R 10 018885237 16 APRIL 10

    040706113 FLASH PLAYER 24 OCTOBER 09
    040706113 4 March 10 Micro USB 4 GB
    040706113 13 January 10 Flash drive 4 GB

    032140640 26 FEBRUARY 10 8 GB USB
    032140640 24 OCTOBER 09 8 GB FLASH

    The power required

    DESCRIPTION OF ARTICLE EFFECTIVE_DATE
    ---------------------------------------------------------------------------
    DISC OF DVD + R 10 018885237 16 APRIL 10
    040706113 4 March 10 Micro USB 4 GB
    032140640 26 FEBRUARY 10 8 GB USB

    Can someone help me with the SQL please?

    Concerning
    Harsha
    SQL> --- generating sample  data:
    SQL> with t as (
      2  select 018885237 item, to_date('24-OCT-09', 'dd-mon-yy') effective_date, 'DVD+R 47 10 PK' description from dual unio
      3  select 018885237, to_date('16-APR-10', 'dd-mon-yy'), 'DVD+R 10 DISC' from dual union
      4  select 040706113, to_date('24-OCT-09', 'dd-mon-yy'), 'FLASH DRIVE' from dual union
      5  select 040706113, to_date('04-MAR-10', 'dd-mon-yy'), '4GB USB Micro' from dual union
      6  select 040706113, to_date('13-JAN-10', 'dd-mon-yy'), 'Flash Driv 4GB' from dual union
      7  select 032140640, to_date('26-FEB-10', 'dd-mon-yy'), '8GB USB' from dual union
      8  select 032140640, to_date('24-OCT-09', 'dd-mon-yy'), '8GB FLASH' from dual
      9  )
     10  --
     11  -- actual query
     12  --
     13  select  item
     14  ,      effective_date
     15  ,      description
     16  from ( select item
     17         ,      effective_date
     18         ,      description
     19         ,      row_number() over (partition by item order by effective_date desc)  rn
     20         from   t
     21       )
     22  where rn=1;
    
          ITEM EFFECTIVE DESCRIPTION
    ---------- --------- --------------
      18885237 16-APR-10 DVD+R 10 DISC
      32140640 26-FEB-10 8GB USB
      40706113 04-MAR-10 4GB USB Micro
    
  • -You also get an invalid identifier error when executing this query sql for a data model, but not in TOAD/SQL Developer?

    Hello OTN.

    I don't understand why my sql query will pass by in the data model of the BI Publisher. I created a new data model, chose the data source and type of Standard SQL = SQL. I tried several databases and all the same error in BI Publisher, but the application works well in TOAD / SQL Developer. So, I think it might be something with my case so I'm tender hand to you to try and let me know if you get the same result as me.

    The query is:

    SELECT to_char (to_date ('15-' |)) TO_CHAR(:P_MONTH) | » -'|| (To_char(:P_YEAR), "YYYY-DD-MONTH") - 90, "YYYYMM") as yrmth FROM DUAL


    Values of the variable:

    : P_MONTH = APRIL

    : P_YEAR = 2015

    I tried multiple variations and not had much luck. Here are the other options I've tried:

    WITH DATES AS

    (

    Select TO_NUMBER (decode (: P_MONTH, 'JANUARY', '01',))

    'FEBRUARY', '02',.

    'MARCH', '03'.

    'APRIL', '04'

    'MAY', '05'.

    'JUNE', '06'.

    'JULY', '07',.

    'AUGUST', '08'.

    'SEPTEMBER', '09'.

    'OCTOBER', '10',.

    'NOVEMBER', '11'.

    "DECEMBER", "12."

    '01')) as mth_nbr

    of the double

    )

    SELECT to_char (to_date ('15-' |)) MTH_NBR | » -'|| (TO_CHAR(:P_YEAR), 'DD-MM-YYYY') - 90, "YYYYMM")

    OF DATES

    SELECT to_char (to_date ('15-' |: P_MONTH |)) » -'|| ((: P_YEAR, 'MONTH-DD-YYYY')-90, "YYYYMM") as yrmth FROM DUAL

    I'm running out of ideas and I don't know why it does not work. If anyone has any suggestions or ideas, please let me know. I always mark answers correct and useful in my thread and I appreciate all your help.

    Best regards

    -Konrad

    So I thought to it. It seems that there is a bug/lag between the guest screen that appears when you enter SQL in the data model and parameter values, to at model/value data.

    Here's how I solved my problem.

    I have created a new data model and first created all my settings required in the data model (including the default values without quotes, i.e. APRIL instead "Of APRIL") and then saved.

    Then I stuck my sql query in the data model and when I clicked ok, I entered my string values in the message box with single quotes (i.e. "in APRIL' instead of APRIL)

    After entering the values of string with single quotes in the dialog box, I was able to retrieve the columns in the data model and save.

    In the data tab, is no longer, I had to enter the values in single quotes, but entered values normally instead, and the code worked.

    It seems the box prompted to bind the values of the variables when the SQL text in a data model expects strings to be wrapped in single quotes, but no where else. It's a big headache for me, but I'm glad that I solved it, and I hope this can be of help to other institutions.

    See you soon.

  • Select quarterly data using SQL

    All-

    The database version that I use is 10.2.0.4.0

    This is probably simple, but for the life of me, I can't understand it. I have a table of approximately 200 Codes and a table that contains millions of records that are obliterated (data are from 1995 to sysdate). I need a query for a view to be used in a report that will show you the different codes used by the employee for specific areas based on a date parameter. If they have no data for this quarter I want to still show the quarter show 0 for the number.

    I created this simple example. If I see someone how I can integrate this logic in what I do.

    SQL for the test data:
    create the table bunch_of_codes
    (id_code number (12) primary key,)
    Description varchar2 (10));

    insert into bunch_of_codes
    values (1, 'APPLE');

    insert into bunch_of_codes
    values (2, 'ORANGE');

    insert into bunch_of_codes
    values (3, 'GRAPE');

    create the table bunch_of_data
    (id_code, number (12),)
    date of activity_date,
    CONSTRAINT data_id_code
    FOREIGN KEY (id_code) REFERENCES bunch_of_codes (id_code));

    INSERT INTO bunch_of_data
    VALUES (1, to_date('4/12/2011','MM/DD/YYYY'));

    INSERT INTO bunch_of_data
    VALUES (1, to_date('6/1/2011','MM/DD/YYYY'));

    INSERT INTO bunch_of_data
    VALUES (3, to_date('1/15/2011','MM/DD/YYYY'));

    INSERT INTO bunch_of_data
    VALUES (3, to_date('4/17/2011','MM/DD/YYYY'));

    INSERT INTO bunch_of_data
    VALUES (3, to_date('11/11/2011','MM/DD/YYYY'));

    COMMIT;

    What I see when I run the SQL statement is:
    DESCRIPTION QUARTER COUNTY
    ----------- ------- -----
    APPLE 1 0
    2 2 APPLE
    APPLE 3 0
    APPLE 4 0
    1 1 GRAPE
    1 2 GRAPES
    GRAPES 3 0
    4 1 GRAPE
    ORANGE 1 0
    ORANGE 2-0
    ORANGE 3 0
    ORANGE 4 0

    I need each printed code without worrying if it was not used. If it has not been used, I want to still see each quarter but show 0 for count.

    For this example, I can run this SQL to join the data:
    Select c.description,
    to_char(d.activity_date,'Q') quarter,
    Count County (d.id_code)
    of bunch_of_codes c,.
    bunch_of_data d
    where c.id_code = d.id_code
    C.description group, to_char(d.activity_date,'Q')
    order of description, quarter

    But if it is not no matter how much detail for the quarter then I don't get a row of data. I tried all sorts of things, but nothing seems to work.

    Please help if you have any ideas.

    Hi MLBrown,

    Here's a query that gives what you asked.
    Note: My table bunch_of_data has three lines that you have published, more a fourth line (the activity_date of this row is April 12, 2010, in the format DD-MON-YYYY).
    To account for the response you gave to the question of Etbin, a column Y (for data year) is included in the output. In this output, there is for the year, Q for the quarter and the total for the count.

    SQL> select * from bunch_of_codes;
    
       ID_CODE DESCRIPTION
    ---------- -----------
             1 APPLE
             2 ORANGE
             3 GRAPE
    
    SQL> select * from bunch_of_data;
    
       ID_CODE ACTIVITY_DATE
    ---------- ---------------
             1 12-APR-2010
             1 12-APR-2011
             1 01-JUN-2011
             3 15-JAN-2011
             3 17-APR-2011
             3 11-NOV-2011
    
    6 rows selected.
    
    SQL> with a as(select mi + level - 1 as y
      2            from (select min(extract(year from activity_date)) mi,
      3                         max(extract(year from activity_date)) ma
      4                         from bunch_of_data
      5                 )
      6           connect by level <= ma - mi + 1
      7            ),
      8       qt as(select '1' q from   dual
      9            union all
     10            select '2' from dual
     11            union all
     12            select '3' from dual
     13            union all
     14            select '4' from dual),
     15       allt as(select b.id_code,b.description,a.y, qt.q  as q
     16              from   bunch_of_codes b,a,qt
     17              ),
     18       temp as(select id_code,y,q,count(1) co
     19      from (select bd.id_code,extract(year from bd.activity_date) y,
     20                   to_char(bd.activity_date,'Q') q
     21      from   bunch_of_data bd)
     22      group by id_code, y,q)
     23      select allt.id_code,allt.description,allt.y,allt.q,nvl(co,0) total
     24      from allt,temp
     25      where allt.id_code =temp.id_code(+)
     26            and  allt.y=temp.y(+)
     27            and allt.q=temp.q(+)
     28      order by allt.id_code, allt.y, allt.q;
    
       ID_CODE DESCRIPTION          Y Q      TOTAL
    ---------- ----------- ---------- - ----------
             1 APPLE             2010 1          0
             1 APPLE             2010 2          1
             1 APPLE             2010 3          0
             1 APPLE             2010 4          0
             1 APPLE             2011 1          0
             1 APPLE             2011 2          2
             1 APPLE             2011 3          0
             1 APPLE             2011 4          0
             2 ORANGE            2010 1          0
             2 ORANGE            2010 2          0
             2 ORANGE            2010 3          0
    
       ID_CODE DESCRIPTION          Y Q      TOTAL
    ---------- ----------- ---------- - ----------
             2 ORANGE            2010 4          0
             2 ORANGE            2011 1          0
             2 ORANGE            2011 2          0
             2 ORANGE            2011 3          0
             2 ORANGE            2011 4          0
             3 GRAPE             2010 1          0
             3 GRAPE             2010 2          0
             3 GRAPE             2010 3          0
             3 GRAPE             2010 4          0
             3 GRAPE             2011 1          1
             3 GRAPE             2011 2          1
    
       ID_CODE DESCRIPTION          Y Q      TOTAL
    ---------- ----------- ---------- - ----------
             3 GRAPE             2011 3          0
             3 GRAPE             2011 4          1
    
    24 rows selected.
    
    SQL>
    

    Edited by: Manguilibe Jan 28 KAO. 2012 01:06

  • History of SQL do not sort by date; new format of TS v4?

    I was afraid that my history of SQL was not accumulating after upgrade, as it seemed not as I expected.


    I generally sort descending timestamp, but I find that hold since the installation of the version 4.0 production this different format of timestamp on the history of SQL took, ignoring the NLS settings that I put in my preferences (which were not those default to my territory and language, incidentally).

    I migrated all my settings from the previous installation, I had... .sqldev4 ea3.  previous migrations from v3 to v4 ea1 to v4 ai2 to v4 ea3 ever disturbed my history of SQL.

    Now my recent entries are buried in the history of SQL and show no longer on top, and sorting by date seems erratic, it is impossible to see a chronological order of the executed SQLs before and after migration.

    Y at - it shaped a command to put the SQL history timestamps or I have to go spelunking in the xml files to change a setting?

    Curiously,.

    Steve

    Toolmakers were the question ID and he set our next update.

  • SQL query by date

    Hello

    I had an Emp table with the following lines of example

    EMP_ID Travel in travel Out -> Date is varchar2 (YYYYMMDD) field and some bad data contains I want to avoid         

    3000018091 20090803 20100802-> I don't want to consider this line becaue it is not not last or 2nd last

    3000018091 20051222 20090802-> I don't want to consider this line becaue it is not not last or 2nd last

    3000018091 20140916 20140929 -> it's the 2nd last entry for journey

    3000018091 20141001 20150701-> This is the most recent entry for travel

    How can I display all employees with more than 4 days of difference between the last trip in and 2nd last trip? example above, the difference is 2 days?

    I don't want any exceptions if bad there is incorrect data in or travel in him travel performed...

    Buxant

    Wrote file afiedt.buf                                                                                   
    
      1  With data_set as
      2  (
      3  SELECT 3000018091  EMP_ID,    '20090803'  Travel_In  , '20100802'  Travel_Out from dual union all
      4  SELECT 3000018091  ,    '20051222'  ,    '20090802'  from dual union all
      5  SELECT 3000018091  ,    '20140916'  ,    '20140929'  from dual union all
      6  SELECT 3000018091  ,    '20141001'  ,    '20150701'  from dual union all
      7  select 3000018091  , 'BADDATA', 'BADDATA' from dual
      8  )
      9  select emp_id,last_travel_in-second_last_travel_out difference
    10  from
    11  (
    12      select emp_id,
    13      (  select max(to_date(travel_out,'yyyymmdd'))
    14          from data_set
    15          where to_date(travel_out,'yyyymmdd') <
    16              (select to_date(max(travel_out),'yyyymmdd')
    17              from data_set d1
    18              where d1.emp_id = d2.emp_id
    19              )
    20      )
    21      second_last_travel_out,
    22      (  select max(to_date(travel_in,'yyyymmdd'))
    23          from data_set d1
    24          where d1.emp_id = d2.emp_id
    25      )
    26      last_travel_in
    27      from data_set d2
    28      group by emp_id
    29* )
    SQL> /
        (   select max(to_date(travel_in,'yyyymmdd'))
                               *
    ERROR at line 22:
    ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    

    Fixed to use the varchar2 type for the "dates" and adding the incorrect data.

    You're going to want to use your own to_date custom to avoid this...

  • Shows SQL ID, OEM, but says: * SQL text not available *.

    I'm a bit confused on this and was hoping that someone can help you.

    I use DBConsole to an Oracle 11.2 (on Solaris 10) database.

    I see really high momentary ' * + tips + * ' in an activity greater than about 20 to 30 minute intervals.
    When I try to understand which SQL is causing the Spike, I drag the section shaded the area containing the Spike and look at all the SQL statements during this period.
    I first try to look the SQL statements by highlighting, or by clicking on the entries in the column of ID of SQL in SQL from the top (bottom left of the page).
    Then I copy and paste the statements in my sqlplus session and see if it causes any sort of spike that I followed in another window OEM looking at key activities.
    Usually, I don't not even a blip on the radar, so I'm not find the SQL statement that causes the spikes.
    Sometimes, however, when I hover over an ID of SQL, it does not show the SQL statement and instead of it shows just the words: [SQL ID].

    Then, I run a report of ASH for the 5 minute window of the shaded area containing the Spike.
    When I look at the "full list of SQL text" ASH report, I found an entry or the Scriptures have to say: * SQL text not available *.

    So then I try to select sql_text from v$ sqlarea where sql_id = «...» "(whatever this sql_id is), and I get no rows found.
    for example,.
    SQL> select sql_text from v$sqlarea where sql_id = '99mjdv0hkh5km';
    
    no rows selected
    In fact, when I try other sql_id, I don't get them either and I guess that's because they are already old v $ sqlarea.
    If I check the v$ sqlarea for up-to-date notifications, they work fine.
    So, the first thing, what controls the duration of v$ sqlarea (pool size)?

    Then I chose to DBA_HIST_ACTIVE_SESS_HISTORY and it displays the information related to the ID of SQL, but of course, it does not show the sql text.
      1* select * from DBA_HIST_ACTIVE_SESS_HISTORY where sql_id = '99mjdv0hkh5km'
    SQL> /
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------
         19242 1311231241               1   68759345
    21-MAR-13 07.24.50.524 AM                                                          394            2337 FOREGROUND
            16         65 99mjdv0hkh5km Y                0          3
    SELECT                                                                         6.2052E+18 99mjdv0hkh5km
                       3          2792326754                4
    TABLE ACCESS
    FULL                                                                16777216 21-MAR-2013 07:24
    Note above FULL TABLE SCAN. That's what I'm trying to dig into who I think is the culprit causing the spikes.

    If your application uses literals, SQL is simply disappeared from sqlarea until you know.

    Although it will certainly be when it is running, then maybe you should look at the right time :)

    the alternative is a 10046 trace to capture the SQL...

  • Procedure runs in SQL, but not in my form of Oracle

    Hello. I have this code to send a warning message that the user is updating a file on my my form of Oracle database table. I use dbms_scheduler so that it is presented as a background task and so the treatment of electronic mail does not delay my Oracle to quickly record form. If I submit this code in SQL Plus, she runs and I receive the email as expected.
    begin
    dbms_scheduler.create_job (  
         job_name            => 'IMMEDIATE_JOB',  
         job_type            => 'PLSQL_BLOCK',  
         job_action          => 'begin TTMS.dropperVacationConflict_Notify (62547, ''01-SEP-11'', ''02-SEP-11''); end;',  
         number_of_arguments => 0,  
         start_date          => sysdate +1/24/59, -- sysdate + 1 minute  
         enabled             => TRUE,  
         auto_drop           => TRUE,  
         comments            => 'Immediate, one-time run');
    end;
    However if I submit this a subsequent update trigger code in my form, the code runs without error, but my email is never received (the same parameter values would be conveyed to this trigger):
    begin
    
    -- Submit the email notification in the background so as to not slow down the screen while saving.    
    dbms_scheduler.create_job (  
         job_name            => 'IMMEDIATE_JOB',  
         job_type            => 'PLSQL_BLOCK',  
         job_action          => 'begin TTMS.dropperVacationConflict_Notify (:dropper_vacations.dropper_id, :dropper_vacations.begin_dt, :dropper_vacations.end_dt); end;',  
         number_of_arguments => 0,  
         start_date          => sysdate +1/24/59, -- sysdate + 1 minute  
         enabled             => TRUE,  
         auto_drop           => TRUE,  
         comments            => 'Immediate, one-time run');
    end;     
    Any ideas why this might be happening?

    Oh, and of course after that you have a lot of other type conversions that may fail.

    Let's take a look. You propose the work like this:

    job_action => 'begin TTMS.dropperVacationemailurl_new ('||p_dropper_id||','|| p_begin_date||','||p_begin_date||'); end;', 
    

    p_begin_date and p_begin_date (why 2 times start date? in any case). are concattenated in a varchar2, so a type conversion occurs; the date format used is the nls_date_format of your session. If this will result to

    begin TTMS.dropperVacationemailurl_new (1234,01-FEB-11,01-FEB-11); end;
    

    now take this block and run it in SQL * more. I can see miles it won't work, because the date data types that you pass are not yet passed as strings.
    It might work, if you pass them as strings:

    begin TTMS.dropperVacationemailurl_new (1234,'01-FEB-11','01-FEB-11'); end;
    

    but then I say I just change the nls_date_format of my session and break your code, because the implicit conversion from varchar2 to date will fail.

    the very ugly solution for this should be

    job_action => 'begin TTMS.dropperVacationemailurl_new ('||p_dropper_id||',to_date('''|| to_char(p_begin_date,'dd-mon-yy')||''', ''dd-mon-yy''),to_date('''|| to_char(p_begin_date,'dd-mon-yy')||''', ''dd-mon-yy'')'); end;'
    

    If you have a tank that is converted to a date that you go to the external procedure which then gets converted to a tank which then gets converted to a date once again. My head hurts. If simply insert you dates into a table and select the dates in dropperVacationemailurl_new instead of 10000 conversions and pass them you wouldn't make 10000 converts and don't care the date format.

    see you soon

  • Strategic review of using Pro * C package vs embedded SQL Select

    Hello
    I have an old application package.procedure that I'm looking using proC call to get the necessary data through Oracle Package.Procedure. Real call to the package see below, 1 parameter, released as a REF Cursor, SQL Select is simple-nothing fancy.

    I was wondering what might be the benefits (if any) to do that instead of coding real SQL Select into my proC code?
    In the case of any change, you need to change the proC and body package, rather than just do it in place if used directly?

    Source control, PM, nice structure inside of the Oracle, departmental approach just? Everyone at least one list?

    Appreciate your opinion, thank you all.



    Trent

    ----------------
    DECLARE
    number of in_idryba2;
    SIA OUT_LIST. UP_CRUD_ryba. SOR_LIST;
    RLIST SIA.t_ryba%ROWTYPE;
    BEGIN
    IN_IDryba2: = 2;
    SIA. UPK_CRUD_ryba. USP__GETLIST_01 (in_idryba2 = > in_idryba2, OUT_LIST = > OUT_LIST);
    LOOP
    EXTRACT THE OUT_LIST IN RLIST;
    WHEN THE EXIT OUT_LIST % NOTFOUND;
    DBMS_OUTPUT. PUT_LINE ("ID ='|") RLIST.ID_ryba |' DESCRP =' | RLIST. SRIPT);
    END LOOP;

    END;

    Hello

    This is not so much a direct answer to your question, but this thread AskTom discusses some of the advantages to using code in the database and the client.

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:30732069210515

    If search you around you can find several other discussions about the same thing.

    The centralization and reusability are two factors that lead me to focus on the code that is stored in the database.

    Kind regards

    Mark

  • Need help with SQL SELECT

    Hello

    I have a table named WORK_CODES
    There only a single column CODE
    The CODE values are
    YES
    NO.
    A
    B
    C

    I get a connection variable: var1
    If: var1 is TRUE = > YES, I'll be back
    If: var1 is NOT TRUE = > I would alternate record in the WORK_CODES table.

    The tricky part is that it must be managed in a SQL query.
    Any help on this is appreciated.

    Thank you
    Pradeep


    The first problem I see is that SQL does not support the Boolean data type. Then you must consider changing the data type of your variable binding.

    Assuming that you change it to integer where 1 = 0 = false and true, you can do

    I guess I misunderstood. You can do it simply.

    select *
      from 
     where (:var = 'TRUE' and code = 'YES') or (:var = 'NOT TRUE' and code != 'YES')
    

    Published by: Karthick_Arp on January 14, 2010 23:30

  • NULL in PL/SQL SELECT statement..

    Hi all

    I need to use as a result of a SELECT statement in my function to get PCODE from the table. Cur_rec here. CODE comes from cursor that runs before the declaration.

    SELECT PCODE in v_pcode TABLE_XYZ where CODE = cur_rec. CODE and PCODE = 'VIEW '.


    Now the problem is the part of the CODE has all the information in the table TABLE_XYZ. In this case, it triggers an error NO_DATA_FOUND. To solve it, I can put a part of the EXCEPTION and handle it. But I think in another way...

    If there is no data for a CODE, the default value of v_pcode would be 'No Code'. I tried to use the NVL function, but it does not work here as a SQL SELECT statement.

    Can someone give an idea how to achieve this?

    Hello

    declare
      ...
      v_cnt number;
    begin
      SELECT count(*)
           into v_cnt
          from TABLE_XYZ
        where CODE = cur_rec.CODE
           and PCODE='SEE';
      if v_cnt=0 then
        v_pcode = 'No code';
      else
        v_pcode = 'SEE';
      end if;
    end;
    

    Bartek

  • SQL does not work

    I posted this already, but I can't so I'm posting again so apologies...

    I downloaded Oracle Express. I used the utilities tab and downloaded a file. I can see the file with "select * from all_tables ' and I can't
    see that I am the owner. I have s/n privs, and using the object browser, I can see the data and and I have granted all privileges to the public.
    Although I can see the table of the dictionary with SQL, and object browser, I am the owner; but, SQL will not allow me
    describe the table
    Select from the table
    even remove the table, so I can recreate another way.

    All I get never the SQL tab or BACK SQL command line is "ORA-00942: table or view does not exist '- but it does not exist under my ownership and all privileges have been granted on the table. What's wrong? Thank you... Richard ([email protected])

    You need to learn how to CUT & PASTE

    Select * from 'Movie '.

    has provided previously you & you still ignore it.

  • Tricky SQL - is possible using just SQL and not of PL/SQL

    Hi all

    Here's my data

    create table experience (exp_id number (10), exp_name varchar2 (20), root_exp_id number (10));
    insert into a values (642, 'Test', 5172) experience;

    create table experience_node (exp_node_id number (10), exp_node_type_id number (2));
    insert into experience_node values (5172, 1);
    insert into experience_node values (5173, 2);
    insert into experience_node values (5174, 2);

    create table experience_connector (exp_conn_id number (10), exp_conn_type_id number (2), exp_node_id number (10), parent_exp_node number (10));
    insert into experience_connector values (1, 5173, 4287 5172);
    insert into experience_connector values (4288, 2, 5174, 5173);
    insert into experience_connector values (2, 5175, 4289 5174);

    When you run these queries:

    Select parent_experience_node_id
    of experience_connector
    where experience_node_id = 5175;

    Select parent_experience_node_id
    of experience_connector
    where experience_node_id = 5174;

    Select parent_experience_node_id
    of experience_connector
    where experience_node_id = 5173;

    Select parent_experience_node_id
    of experience_connector
    where experience_node_id = 5172;

    gives 5174, 5173 and 5172 and null. exp_node_type_id = 1 and exp_node_conn_type_id = 1 indicates that it is at the root. Hope my explanation is useful. Is what I'm trying to get - to get the big concession to 5175 grandparent who is 5172. Is it possible to do it with SQL?

    Thank you very much for you help.

    Best,
    Lacombe

    user6773 wrote:

    We don't know if the level. There could be any number of levels. Is there any other way around? Thank you once again.

    Well, you say that you need to root, not great great grandparent? If so, use:

    SQL> select  parent_exp_node
      2    from  experience_connector
      3    where connect_by_isleaf = 1
      4    start with exp_node_id = 5175
      5    connect by exp_node_id = prior parent_exp_node
      6  /
    
    PARENT_EXP_NODE
    ---------------
               5172
    
    SQL> 
    

    SY.

  • Unable to connect to the selected mobile data Simulator service

    First of all, let me say that I am a newbie with BlackBerry and simulators.

    I just downloaded 9630_Verizon and 9630_Sprint simulators as well as the MDS Simulator package. I start the MDS Simulator and the DOS window opens and seems to work very well. I start be 9630 simulators and while it seems to work, when I click on the button of the browser and try to go to any web page, I get:

    Unable to connect to the selected Mobile Data Service, please try again later.

    The version of the 9630 Simulator is 2.12.0.47

    The MDS Simulator version is ' SCM 4.1.4.19 19 2007/07/10»

    I can connect to the MDS Simulator using my browser of desktop connection to localhost: 8080. Statistics show all values of zero, so it seems that the 9630 is not yet connect to the Simulator. Is there a configuration file somewhere that I have to change to make it work?

    After that I posted this, I continued to search the forums of possible solutions. One recommendation, I found was to delete the files ".dmp" and restart the device Simulator. That did the trick, things work now.

  • reset_image_prefix. SQL does not work

    Hello

    My DB has two instances with two different versions of the top charge. One is the version 4.1.1 (works well) and I decided to upgrade the other 4.1.1 to 4.2. I created a new location in the httpd.conf file entry in my case of OSH to point to the new instance 4.2 referencing a new Alias image on the server. When I installed APEX 4.2 I showed the images the New Alias directory setting "i42' but it does not work. Applications always refer to is

    I ran the script reset_image_prefix.sql with /i42/ as an input parameter, but the applications are always reference/i /.

    There was a similar discussion in October 2012 and Patrick Wolf wrote on bug # 14785456.

    But the BUG seems to be fixed?

    After executeing the script Iget:

    SQL > select text from dba_source where owner = 'APEX_040200' and lower (name) = "wwv_flow_image_prefix";

    TEXT

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

    package wwv_flow_image_prefix

    is

    constant g_image_prefix VARCHAR2 (255): = ' / i42 / ";

    end wwv_flow_image_prefix;

    4 selected lines.

    Is there a solution?

    Kind regards

    Carola

    Hi Carola,

    What exact version of APEX 4.2 do you use? Are you using the latest 4.2.2? Because it includes the hotfix that you referenced. After installation of this version or the patch installed, it will automatically erase all the prefixes image-level asks if they are identical to the current instance image prefix. So in your case, you should set the prefix image back to / i /, install the hotfix and then reset_image_prefix again to set the parameter instance/i42.

    Joel has some useful information on this blog (YABAOAE) yet another Blog about Oracle Application Express: prefix of Image Exchange in Oracle Application Express 4.2.2

    Some background info on reset_image_prefix.sql. Who has never changed the image prefix used in applications, only the prefix of image for our application Builder.

    Concerning

    Patrick

    Member of the APEX development team

    My Blog: http://www.inside-oracle-apex.com

    APEX Plug-Ins: http://apex.oracle.com/plugins

    Twitter: http://www.twitter.com/patrickwolf

    Post edited by: PatrickWolf

Maybe you are looking for

  • virus in a firefox addon

    stupidly, when I was tired last night I added an addon from ebay and it must have been a "click here or not thing" that I forgot.now I have a virus that I can't get rid of.There dj mixi and I am very upset and angry.

  • reset the password of the forgotten mailbox iCloud

    How to reset the password of the forgotten mailbox iCloud?

  • 924 problems Driver Dell Photo AIO

    I recently get windows 7 Professional to use it on my desktop and have a dell photo AIO 924 printer.  I tried several times to install drivers for it, and the computer recognizes the printer is present and ready for use.  However, when I try to print

  • Where can I find which Intel chipset is used for my Precision T3500?

    I have upgraded to Windows 10, only now to find that the T3500 is "untested for Windows 10." Technology Intel Rapid store takes up 30% of my CPU quad. Downloads of Intel RST all depending on which Intel chipset or on the motherboard. Speccy tells me

  • missing data file

    Hello worldin my user database RAJA there is USER DATA, with default table spacethe database is in open mode, after a while, that the data of the USER DATA table space file is deleted.here my doubt is if user RAJA insert data into the database, where