View returns a value when the return is null

I need a view that returns the following situation:
ID   VAL
1    A
2    B
Select VAL from my_view where ID = (?)
If the ID is different from 1 or 2, then the value must be 'C' another thing 'A' or 'B' as ID

Some tips on how I can do this?

Concerning

Assuming that the id is not null:

SQL> variable id number
SQL> exec :id := 1;

PL/SQL procedure successfully completed.

SQL>  select  val
  2     from  tbl
  3     where id = :id
  4  union all
  5   select  'C'
  6     from  dual
  7     where :id not in (
  8                       select  id
  9                         from  tbl
 10                      )
 11  /

V
-
A

SQL> exec :id := 2;

PL/SQL procedure successfully completed.

SQL>  select  val
  2     from  tbl
  3     where id = :id
  4  union all
  5   select  'C'
  6     from  dual
  7     where :id not in (
  8                       select  id
  9                         from  tbl
 10                      )
 11  /

V
-
B

SQL> exec :id := 3;

PL/SQL procedure successfully completed.

SQL>  select  val
  2     from  tbl
  3     where id = :id
  4  union all
  5   select  'C'
  6     from  dual
  7     where :id not in (
  8                       select  id
  9                         from  tbl
 10                      )
 11  /

V
-
C

SQL>

SY.

Tags: Database

Similar Questions

  • The text element values value when the user clicks a report line.

    The text element values value when the user clicks a report line.

    I have a report based on the EMP table and two elements P911_EMPNO, P911_DEPTNO. When I click on one of the lines the EMPNO and DEPTNO is copied to the text elements.
    It works fine if I leave the EMPNO and DEPTNO as SHOW report, but if I then these clear values are not retrieved the report form (my javascript is very limited).

    I need a method to retrieve the data hidden in the report and display in the text without the reposting of the page elements.

    Also, would be nice if the line was highlighted until another line is clicked but especially is my priority.

    Elements
    P911_EMPNO, P911_DEPTNO (field of disabled text, saves the State)

    Report
    Select * from emp using the model of report below.

    Custom model.
    standard_report_cust_P330-a copy of the standard report with a change model.
    BEFORE EACH LINE
    < tr onclick = "selectRow (this);" #HIGHLIGHT_ROW # >


    * Javascript in the Page Header.*
    < script language = "JavaScript1.1" type = "text/javascript" >
    function selectRow (p_tr)
    {
    var l_deptno = p_tr.childNodes [8] .innerHTML;
    var l_empno = p_tr.childNodes [1] .innerHTML;
    html_GetElement ('P911_DEPTNO'). Value = l_deptno;
    html_GetElement ('P911_EMPNO'). Value = l_empno;
    }
    < /script >

    If anyone has any ideas. Thanks, Pete

    Hello

    When you use this type of report model, you actually control on where the column values are used - and they can be used several times.

    For example, a setting of 'Model line 1' for one such model could be:

    <tr>
    <td class="c1">#1#</td>
    <td class="c2">#2#</td>
    <td class="c2">#3#</td>
    <td class="c2">#4#</td>
    <td class="c3">#5#</td>
    </tr>
    

    #1 # fact refers to the data in the first column, #2 # for the second and so on. So you can do:

    <tr onclick="javascript:dosomething('#1#','#2#');">
    <td class="c1">#1#</td>
    <td class="c2">#2#</td>
    <td class="c2">#3#</td>
    <td class="c3">#5#</td>
    </tr>
    

    For example, by clicking on the line would trigger the dosomething() function and pass in that the values of the first and second columns. Also note that the 4 # does not appear now - this column is 'hidden' (but note that you must check the box to show the column)

    Andy

  • How return values when the page of the ofa procedure call

    Hello

    I need to return multiple values in the OPS page calling procedure.i using below code.bt I'm able to return a single value. Please suggest me how to return multiple values.

    Co:

    -----

    If (pageContext.getParameter ("Calc")! = null) {}

    Vo1 OAViewObject = (OAViewObject) am.findViewObject ("AddonBillingVO");

    System.out.println ("VO");

    {if(VO1!=null)}

    CNT int = vo1.getRowCount ();

    System.out.println ("count:" + cnt);

    If (cnt > 0)

    {

    RowSetIterator rs = vo1.createRowSetIterator("empIterator");

    System.out.println ("EMP");

    If (rs! = null)

    {

    While (rs.hasNext ())

    {

    AddonBillingVORowImpl line = rs.next ((AddonBillingVORowImpl));

    System.out.println ("impl");

    If (line! = null)

    {

    String laseid = row.getAttribute("LeaseId").toString ();

    System.out.println (laseid);

    String billingid = row.getAttribute("AddonBillingId").toString ();

    System.out.println (billingid);

    [Serializable] param = {}

    laseid, billingid

    };

    String newupc = (String) am.invokeMethod ("callPLSQLProc", param);

    System.out.println (newupc);

    String myValue = newupc;

    OAMessageTextInputBean textBean = (OAMessageTextInputBean) webBean.findChildRecursive ("prorate");

    textBean.setValue (pageContext, myValue);

    }

    }

    AM:

    --------

    public String callPLSQLProc (String laseid, String billingid)

    {

    OracleCallableStatement callableStatement = null;

    Try

    {

    String callProc = "BEGIN LEASE_PRORATE_PKG. LEASE_PRORATE_PROC1 ' + '.

    "(p_lease_id = >: 1,» +)"

    ' p_billing_id = >: 2 +,

    "(p_prorate = >: 3) +;

    'END;';

    callableStatement (OracleCallableStatement) = getOADBTransaction ().createCallableStatement(callProc,1);

    callableStatement.setInt (1, Integer.parseInt (laseid));

    System.out.println (laseid);

    callableStatement.setInt (2, Integer.parseInt (billingid));

    System.out.println (billingid);

    callableStatement.registerOutParameter(3,OracleTypes.VARCHAR,255);

    callableStatement.execute ();

    String resultMessage = (String) callableStatement.getString (3);

    System.out.println (resultMessage);

    Return resultMessage;

    }

    catch (System.Exception e)

    {

    e.printStackTrace ();

    System.out.println ("execepn");

    throw new OAException (try (), OAException.ERROR);

    }

    printscreen.PNG

    Khalil.

    Hello

    You are the PL/SQL procedure in a loop on the right? Just assign the value to the attribute appropirate.

    if (pageContext.getParameter("Calc")!=null)  {
      OAViewObject vo1 = (OAViewObject)am.findViewObject("AddonBillingVO");
      System.out.println("vo");
      if(vo1!=null) {
      int cnt = vo1.getRowCount();
      System.out.println("count :" + cnt);
      if (cnt > 0){
      RowSetIterator rs = vo1.createRowSetIterator("empIterator");
      System.out.println("emp");
      if (rs != null){
      while (rs.hasNext()){
      AddonBillingVORowImpl row = (AddonBillingVORowImpl) rs.next();
      System.out.println("impl");
      if (row != null){
      String laseid = row.getAttribute("LeaseId").toString();
      System.out.println(laseid);
      String billingid=      row.getAttribute("AddonBillingId").toString();
      System.out.println(billingid);
      Serializable[] param = { laseid,billingid };
      String newupc = (String) am.invokeMethod("callPLSQLProc",param);
      System.out.println(newupc);
      //String myValue = newupc ;
      //OAMessageTextInputBean textBean = (OAMessageTextInputBean)webBean.findChildRecursive("prorate");
      //textBean.setValue(pageContext, myValue);
      row.setAttribute("Prorate",newupc);
      }
      }
      }
      }
      }
    }
    

    Check the last lines. If the attribute name is nothing else than "Pro rata", updated accordingly.

    See you soon

    AJ

  • TextField mutiply by value when the box is check

    Hi all

    I have a form, built in Adobe Acrobat X Pro, I create as a form of reparation with charges included in it.

    I know how to have a value filled in a text field when a check box is selected.

    My question is this.  I have a textfield labeled as "labor_hrs" which is a number format.  What I want to do is to have this box multiplied by a given value of populous 45.00 to the text field 'labor_chrg '.  Can I get this feature to work on its own.


    I want to do is only to be filled to the "labor_chrg" when the "billable" checkbox is checked.


    adobe.png

    Any help would be appreciated.

    A quick way is to set the export value of the checkbox "billable" 1.

    You can then use the simplified field notation script of:

    (labor_hrs * 45) * billable

    A custom JavaScript calculation:

    function GetField (cName) {}
    Returns the field with error checking object;
    oField var = this.getField (cName);
    if(oField == null) app.alert ("field of error for access to the"+ cName, 0.1 ");
    return oField;
    } / / end GetField function;

    Event.Value = (isNaN (GetField("billable").value) == false) * GetField("labor_hrs").value * 45;

    If you add a hidden field to the rate of work called "labor_rate", you can use the ' field is the product of the following fields: "and select the fields"billable","labor_hrs"and"labor_rate ".

  • Move links to javascript value when the page is loaded

    Hello

    I use JDeveloper 11.1.2.4.0.

    When loading my jsf page, I want to pass the value of the lat, long columns of links the attribute so that the map google map is rendered correct loading of the page.

    I can do when a button is clicked.  But I want to do it when the page is loaded.

    Any ideas?

    Thanks in advance.

    Here is the code snippet, which includes the javascript function: instead of coding hard - 34.397 and 150.644, I would like to happen next as parameters or

    access it some how from the pagedef attribute binding.

    < f: facet name = "metaContainer" >
    " < af:resource type = 'javascript' source = ' https://maps.googleapis.com/maps/API/js?v=3.exp & Sensor = false "/>
    < af:resource type = "javascript" >
    var map;

    initialize() function
    {
    var mapOptions =
    {
    Zoom: 8, Center: new google.maps.LatLng (-34.397, 150.644)
    };
    card = new google.maps.Map (document.getElementById('map-canvas'), mapOptions);
    }

    google.maps.event.addDomListener (window, "load", initialize);
    < / af:resource >
    < / f: facet >

    Hello

    set a listener of phase for the view (using the beforeMethod on the f: view of the page markup). In the method, then use the ExtendedRenderKit Service to call JavaScript from Java. The method must listen for the phase PREPARE_RENDER, who is the liaison for the page to exist. You can access the link from BindingContext.getCurrent () .getCurrentBindings () layer. From there, you call (AttributeBinding) bindings.get ("the binding of the attribute name") to get the attribute mandatory and then - in a next step - the inputValue with data to transmit

    Call JavaScript from Java:

    String script = «...» Add JS calls to set values in JS variables accessed by Google Maps"

    ExtendedRenderKitService erks = Service.getRenderKitService (context, ExtendedRenderKitService.class);

    erks.addScript (context, script);

    Frank

  • How to disable Lov when the value of the attribute is NULL at the level line

    Hi all

    JDev 11.1.1.5.0

    I have a view as a table ADF jsff page object. Value of the attribute in a row may have null values.
    And I want that Lov must be disabled when the value of the attribute in the row is null or not.
    So please suggest me how can I implement this.

    Kind regards
    Marie-Claude

    Set to the disabled for LOV attribute property

    disabled="#{bindings.YourAttribute.inputValue eq null}
    {code}                                                                                                                                                                                                                                        
    
  • "console View" is grayed out when the user is sharing with another user config

    The subject pretty much sums up it. LM 4.0 running and some of my users have stated that when they share configs they have with other users (in the same organization), the added users cannot "Console Mode". It is grayed out. I checked the properties of these roles and roles (the list of options is amazing) and returned to the LM 4.0 User Guide.

    I can't move. When the owner is going to share their config with a user, the only available access level is "read only". I have the same problem and I am a global system administrator.

    Why is this?

    Sorry about that, I realized I have not really solve your problem.

    I'm curious though; Under sharing, if you chose the ' users selected in the workspace: hand ' rahtner that ' everyone in the workspace: hand ' and then specify individual users, you are able to change their level of access to 'Edit' or 'total control '. On my setup, it seems that you cannot change the level of access beyond Read-Only "unless you are addressing the specific workspace.

  • How to ensure that the value of a control (for example double) initializes the last value when the VI has been closed?

    I use a cluster as a control. I would like to double in this control to automoatically values to fill their last values set when the VI is opened or accessed for the first time. It would be great if someone could point out for me. Thanks in advance!

    In my opinion, the configuration files are the easiest method and the best.  Simply save your last values to the file when your code ends.  At the beginning of your code, to read the file and fill in the controls with the values read.  With the configuration files, the section name can be the name of the cluster, and key names can be control names.

    I know OpenG has some pretty nice to do, but I prefer to use the native functions OR when I can.  When porting to a new system, there is no need to copy any additional screws library (OpenG library).  The native DV come with Labview.

  • TabbedPane - sending of property value when the new tab is selected

    Hi just designed tutorial, I have two tabs: vegetables and fruits.

    The two tabs will use the same qml file (inside is a unique list) but of course will use different DataModel.

    So, I set up a property for the DataModel source and place it when the current tab changes,

    Here's my simplified code:

    //main.qml
    TabbedPane{
        Tab{
            title: "Veggie"
            MyNextPage{}
        }
        Tab{
            title: "Fruit"
            MyNextPage{}
        }
        //Looks like here's the problem
        onActiveTabChanged:{
            var page = myComponentDefinition.createObject();
            if(activeTab.title == "Veggie")
                page.dataModelSource = "models/veggie.xml";
            else{
                page.dataModelSource = "models/fruit.xml";
            }
        }
    
        attachedObjects: [
            ComponentDefinition {
                id: myComponentDefinition
                source: "MyNextPage.qml"
            }
        ]
    }
    
    //MyNextPage.qml
    Page{
        property alias dataModelSource: myListView.dataModel.source
        Content{
            ListView{
                id: myListView
                layout: ...
                dataModel: XmlDataModel{
                    source: "models/veggie.xml"
                }
            }
        }
    }
    

    But he blocks my request. I don't know about works like that of property. Anyway the solution or alternative to send a value to another page?

    Thanks before

    It's easier if you do not attach the page, as follows:

    //MyNextPage.qml
    Page{
        property alias dataSource: dataModel.source
        Content{
            ListView{
                id: myListView
                layout: ...
                dataModel: XmlDataModel{
                    id : dataModel
                    //source: "models/veggie.xml"
                }
            }
        }
    }
    

    and then in your tabbedpane

    TabbedPane{
        Tab{
            title: "Veggie"
            MyNextPage{
    dataSource : "models/veggie.xml";
    }
        }
        Tab{
            title: "Fruit"
            MyNextPage{
        dataSource : "models/fruit.xml";
    }
        }
    }
    
  • validation of the values when the user entering advanced table

    Hi all

    I developed a page that has progressed to table and calculating the total of table in advance. I get the total value when I click on the Recalculate button.

    but I want to restrict the user to enter negative values in the row of this column how to make this senario

    Open AMImpl.java

    This finding validate method if it is not there double click on select java am file and method validate tick click ok it creates the validate method in AMImpl.java and write your validation

  • ODI - Variable error has no value when the regeneration of scenario

    Hey people, how are you doing?

    In my environment, there are two servers, DEV and PROD. We have exported a file to XML of PROD and imported for DEV, there are several packages within this folder that share the same variables of the project. When we import which, if we run one of the scenarios, he asks for a parameter, XXTEST.idExec. Provide us and the interface works normally.

    However, if regenerate us the DEV script without even touching the package, we expected that it works very well, but it gives an error: "XXTEST.idExec - Variable has no value", even if we provided a value for the parameter. What intrigues me is that the package is absolutely the same, simply regenerate it begins to give the Variable has no value errors. Another detail: this is not specific for a single package, all scenarios that regenerate us start giving this same error with this variable.

    Which is perhaps a difference in the environment? Is there something we can do to track this problem?

    Best regards and thanks in advance!
    Thiago

    I think it's a good idea going to 10.1.3.5_02

    To display values, change the variable and have a look at the third tab.

    do the same thing in production... and tell me the results.

    Cezar Santos
    http://odiexperts.com

  • Management when the percentage getting null values

    Hi all

    I'm writing a query that gives me the account, the total number of transactions, the total number of transactions that are being matched (from the same table) and finally a percentage.

    After the documentation and brushing my knowledge of sql, this is the query.

    Select A.ACCOUNT_ID,A.TOTAL_TXN,B.TOTAL_MATCHED,(B.TOTAL_MATCHED/A.TOTAL_TXN) * 100 AS PERCENTAGE

    FROM (select account_id, count (*) bdr_transaction TOTAL_TXN

    where

    value_date = January 9, 15 '

    Account_id group) has

    LEFT JOIN

    (select account_id, count (*) bdr_transaction TOTAL_MATCHED where)

    value_date = January 9, 15 ' and

    type in (1,2)

    Account_id group) B

    ON A.ACCOUNT_ID = B.ACCOUNT_ID;

    This query gives me almost the expected output (if it takes too much time), but when the result of the B.TOTAL_MATCHED column is null the percentage is also set to null.

    Is there a way or a workaround to handle this?

    There might be another way more quick/clean, to do so.

    Thank you

    TK

    Select ACCOUNT_ID, TOTAL_TXN, TOTAL_MATCHED, (TOTAL_MATCHED / TOTAL_TXN) * 100 AS PERCENTAGE

    de)

    Select ACCOUNT_ID, count (case when type (1, 2) then 1 end) TOTAL_MATCHED, count (*) TOTAL_TXN

    of BDR_TRANSACTION

    where VALUE_DATE = January 9, 15 '

    ACCOUNT_ID group

    )

  • Case when the field IS NULL then... end

    Hello world

    (a) If a field is null, display a message.

    (b) the field shows beak null. application for admin to make outer joins between the tables.

    (c) I have 9 rows, 3 have NULL values,
    So, I want to show a literal message on 3 rows.

    problem is that the message shows on all the 9 lines.


    now:
    ====
    I could have adopted an approach very unorthodox at this request, please bear with me.
    I work for a college and am interested in students who did not encourage the "" in the last six months
    for this semester, beak. they repeat the year.

    200830 M1 generally promote to 200920 M2 (m1 attribute replaced by m2)

    M1 - 1 year 200830 = winter
    M2 - 2nd year 200920 = fall (200910 is special and not interested by this semester for this request)


    I want to run a query to search for the students who did not encourage.

    hand the sql would be:

    SELECT st1.id
    st1.name
    sa1.academic_period
    sa1.student_attribute
    sa2.academic_period
    sa2.student_attribute
    Student st1
    INNER JOIN student_attribute sa1
    ON st1.person_uid = sa1.person_uid
    AND sa1.academic_period = '200830'
    AND sa1.student_attribute = 'M1 '.
    LEFT JOIN student_attribute sa2
    ON st1.person_uid = sa2.person_uid
    AND sa2.academic_period = '200920'
    AND sa2.student_attribute = 'M2 '.
    where st1.academic_period = '200830'
    and sa2.student_attribute is null
    ORDER BY st1.name;


    ===========

    taking the hardcoded values and putting a LEFT JOIN simplified in a display/custom folder
    and then by creating the conditions in discoverer, essentially behaved as an EQUI-join and do not show the
    null lines

    =============

    I compare a "slice" of data "another" data 200920/m2 200830/m1

    so I begged the admin as an experiment to "clone" the desired table as 2 views and external to join them
    Discover the left join to student attribute #1 to
    attribute of student views #2


    and using the technique to deceive the discoverer of a LEFT JOIN in: student_attribute is null or student_attribute is null

    I got what I wanted - pupils with NULL values in attribut2, beak. they did not encourage

    ==============

    so now I wanted to create a new discoverer in copying the above query query and adding new 'logic ':

    In this new queyr am interested if the student extensible query determined #1
    have been coded by the staff in order to take into account that they repeat:
    M1 200830 as:
    M1 200920 (their bump up current semester with the same code attribute)

    so I thought... hmmmmm... I also have the ordinary table: attribute of the student
    now watch a 3rd data slice: 200920 m1


    Discover the left join to student attribute #1 to
    attribute of student views #2

    left to join University
    attribute of student views #1

    I access the beak ordinary table this pre-established join :

    University to join
    student table attribute

    ====================
    so my 2nd query uses:
    -Discover the condition attribute #1 student: 200830/m1
    -Discover the condition attribute #2 students: 200920/m2
    -University studies
    -condition of table student attribute: 200920 / * m1 *.


    and to maintain the table: attribute of student for M1 200920
    to see if records created the current semester for Extensible students staff


    This query has worked, got the 9 lines, of which 3 had to be coded to 200920/m1
    For lines 3 nulls, want to create a calc that would show this literal:

    "needs 200920 m1 folder.

    the problem is the literal is printing even on rows that have a value in the fields from the table, it's the calc:


    BOX WHEN (period DMC_Student_Att2.Academic IS NULL) THEN

    "NEEDS" | "'-> ' |: Parm_AcademicPeriod_Current |" " ' || : Parm_StudentAttribute_Prev

    END


    Any advice that might work with this unorthodox approach would be greatly appreciated,
    Advice to the other approaches would be also appreciated, tx, sandra

    Hi, Sandra
    When you work with outer joins, with that I conclude with a double whammy an OR statement allows me to make some incredible manipulations.

    For example, if you have a folder that the master joined the detail folder B with an outer join on B you get records from one if they exist in B or no - no?

    It doesn't have to be the case, you're just limit your way of thinking. It must get off the beaten and tell ourselves, if I could force discoverer to create a subquery with the NULL filter outside, I could find these B that don't have any corresponding entry in B, or I could find who had only the entries in the two.

    Let's say there's a STUDENTID b, using a normal like condition: B.STUDENTID IS NULL will not work because of the outer join. But if you create a Boolean condition, like this:

    B.STUDENTID IS NULL or B.STUDENTID IS NULL you will see amazing results.

    This tip can help.

    In which your question, taking the knowledge above, I was wondering what would happen if you did:

    BOX WHEN (period DMC_Student_Att2.Academic IS NULL) OR (period DMC_Student_Att2.Academic IS NULL) THEN

    "NEEDS" | "'--> ' |: Parm_AcademicPeriod_Current |" " ' || : Parm_StudentAttribute_Prev

    I am not sure it will work. If it isn't then you need create 2 worksheets, one containing the students who made the promotion and the other for those who do not. You need the conditions to make this work, one like this:

    * (Period of DMC_Student_Att2.Academic IS NOT NULL) OR (DMC_Student_Att2.Academic period IS NOT NULL) *.

    and other like this: * (DMC_Student_Att2.Academic period IS NULL) OR (DMC_Student_Att2.Academic period IS NULL) *.

    Best wishes
    Michael

  • Change the conditions when the parameter is null

    I am building an Apex application where the client will fill out a form to get the data. I want to know if there is a way to modify the WHERE clause based on the selections of the customer allows shaped.

    Here is the scenerio:

    The user form has 3 fields, which should all be able to be null to return all results. We will call them P10_A, P10_B and P10_C

    If the user selects a value for all three, where clause is:

    where column_a =: P10_A
    and column_b =: P10_B
    and column_c =: P10_C.

    It works correctly if the user chooses a value for everyone, but if they do not choose a value for P10_B, I need my query to edit the where clause is

    where column_a =: P10_A
    and column_c =: P10_C.

    I have not found a way to do this, so I put my question to you. Is it possible to selectively include certain parts of the place where clause based on the presence of null values?

    Hello

    You must change your where clause to something like this:

    where (column_a = :P10_A OR :P10_A IS NULL)
    and (column_b = :P10_B OR :P10_B IS NULL)
    and ( column_c = :P10_C OR :P10_C IS NULL)
    

    I hope this helps!

    --
    Paulo Vale
    http://Apex-notes.blogspot.com

  • Region HTML - hide when the element is null

    Hello

    I want to hide the "HTML-area" where an element (P2_Item) is null... Please advice...

    Thank you

    P2_CUST_SYMBOL should work. PL. make sure the element is null.

Maybe you are looking for