How will get subquery return multiple values and passing to the main query

Hi all ;
here i given one sql query
1)select decode(a.FLG,'Y','yes','N','no','null')||'] '||a.p_type||' : '|| initcap(replace(substr(b.mgr,0,instr(b.mgr,'@')-1),'.',' '))||' - '||
b.name||' ('|| substr(a.name,0,instr(a.name,'-')-1)||')'
from table1 a
join table3 c on c.emptype = a.emptype
left outer join table2 b on a.name = b.name
where a.mgrid = 100;
if i run this above query returning multiple values depend on sa.mgr values.
like output coming like this
[yes]:2000-anbarasan
[yes]:2700-anb
[yes]:2000-rasan
[yes]:2807-anbarasan
[yes]:2700-anbanu
[yes]:2000-null
2) this sub query i am passing with main query
select sa.mgrid,sa.sal,(select decode(a.FLG,'Y','yes','N','no','null')||'] '||a.p_type||' : '||
initcap(replace(substr(b.mgr,0,instr(b.mgr,'@')-1),'.',' '))||' - '||
b .name||' ('|| substr(a.name,0,instr(a.name,'-')-1)||')'
from table1 a
join table3 c on c.emptype = a.emptype
left outer join table2 b on a.name = b.name
where a.mgrid = 100)" test " from table4 sa,table5 te ,table6 ft where sa.id(+)=te.id and sa.mgr=ft.mgr;
my final out put required like this:
mgrid sal test
100 20000 [yes]:2000-anbarasan
[yes]:2700-anb
[yes]:2000-rasan
[yes]:2807-anbarasan
[yes]:2700-anbanu
[yes]:2000-null
but i am getting erro:
1)missing paranths-it solved
2)single row subquery return more then one row.
give me the correct solution.how will solve this problem
Edited by: anbarasan on Sep 29, 2008 6:49 AM
Edited by: anbarasan on Sep 29, 2008 6:51 AM
Edited by: anbarasan on Sep 29, 2008 6:53 AM
Edited by: anbarasan on Sep 29, 2008 6:56 AM
Edited by: anbarasan on Sep 29, 2008 6:58 AM

Hi,
It doesn't look like you posted either the complete query or the complete error message (including line number). Try again.
"single row subquery return more then one row" usually means you are using a sub-query in a place where a single expression is expected, for example the column called avg_sal in this query:
SELECT  ename
,       sal
,       (SELECT  AVG (sal) FROM scott.dept WHERE deptno = e.deptno) AS avg_sal  -- Scalar-sub-query
FROM    scott.emp  e; The error occurs when the sub-query returns more than one row
If the sub-querry really is supoosed to be returning only one row, the solution is to fix the sub-query, usually be adding something to the WHERE clause.
If the sub-query is supposed to return more than one row, then the main query has to be re-written, perhaps as a join.
Post a little sample data and the results you want from that data if you need help.

Similar Messages

  • Hi how will get subquery returns multiple values for main query

    Hi all ;
    here i given one sql query
    1)select decode(a.FLG,'Y','yes','N','no','null')||'] '||a.p_type||' : '|| initcap(replace(substr(b.mgr,0,instr(b.mgr,'@')-1),'.',' '))||' - '||
    b.name||' ('|| substr(a.name,0,instr(a.name,'-')-1)||')'
    from table1 a
    join table3 c on c.emptype = a.emptype
    left outer join table2 b on a.name = b.name
    where a.mgrid = 100;
    if i run this above query returning multiple values depend on sa.mgr values.
    like output coming like this
    yes:2000-anbarasan
    yes:2700-anb
    yes:2000-rasan
    yes:2807-anbarasan
    yes:2700-anbanu
    yes:2000-null
    2) this sub query i am passing with main query
    select sa.mgrid,sa.sal,(select decode(a.FLG,'Y','yes','N','no','null')||'] '||a.p_type||' : '||
    initcap(replace(substr(b.mgr,0,instr(b.mgr,'@')-1),'.',' '))||' - '||
    b .name||' ('|| substr(a.name,0,instr(a.name,'-')-1)||')'
    from table1 a
    join table3 c on c.emptype = a.emptype
    left outer join table2 b on a.name = b.name
    where a.mgrid = 100)" test " from table4 sa,table5 te ,table6 ft where sa.id(+)=te.id and sa.mgr=ft.mgr;
    my final out put required like this:
    mgrid sal test
    100 20000 yes:2000-anbarasan
    yes:2700-anb
    yes:2000-rasan
    yes:2807-anbarasan
    yes:2700-anbanu
    yes:2000-null
    but i am getting erro:
    1)missing paranths
    2)single row subquery return more then one row.
    hi kindly give me answer to me as soon as possible
    Edited by: anbarasan on Sep 29, 2008 9:48 PM

    I refuse to read all of that code and guess what error message you are getting. Apparently others feel the same way.
    Run the final SQL statement and then cut and paste the code and full error statement into a post.
    Also include your full version number to three decimal places.
    My refusal is not an unwillingness to help you but rather an unwillingness to spend 10 minutes reconstructing what you could have pasted in in a fraction of a second. We are all volunteers here and there are many people that need help. I hope you understand.

  • How can i read every"number" value and not only the 1st?

    in the vi only the first "number" value(from the data acquisition)is read in the small loop.how can i make every value to be read?every value must be compared with the "numeric" constant,and,if greater the led must turn on.afterwards,when a value which is less than the "numeric" is found the led must turn off.please answer or send mail to [email protected]
    Attachments:
    oximet5.vi ‏152 KB

    The more I look at your program, the less I understand it.
    Why are you setting number = number in a case if SO2 = ""? number always equals number.
    In your sequence frames 1 and 4, you have no control over which write (date or time) happens first. Just placing one function to the left of another doesn't make it happen first if your wiring doesn't create data dependency. Review the section on Data Dependency in chapter 5 of the LabView User's Manual.
    It looks you're writing to and reading from the same file using Write File and Read Lines from File.vi. Why read back data you just wrote? You have the data on your diagram. If you want to convert it from string to numeric, use a Sring/Number Conversion function from the String palette.
    On Read Lines from File.vi (which I'm not sure you even need), you should use a shift register for the start of read offset rather than a local variable for mark after read (chars.). With a shift register, you can initialize it to 0 when the VI starts. Using a local, if you restart the VI, it will try to startup from where you left off the last time, but you just opened the file for create or replace.
    In your sequence frames 2 and 3, why do you wait for the number to be less than the numeric before writing a carriage return to the file? Also, LabView has a End of Line constant which adapts to the expected value for the operating system. That's generally more flexible than a Carriage Return.
    It looks to me like you're overusing control refnums. You don't need to use a control refnum and a property node to set or read a control's value if you can wire directly to the control's terminal.
    I really don't understand what you're doing with pause and variants. I may be missing the point, but it looks like you made this much more complicated than it needs to be. Why not keep it a boolean?
    For your pause-path, you open the file but never close it. You can lose data that way. You also open it using open function 3, create new file. You'll get an error if the file already exists.
    On a general note, your diagram would be easier to read if you were more selective in how you routed your wires: you have wires on top of wires, wires running under sub-VIs, wires running in the frame of a while loop, wires running under labels.
    I think there's a temptation to overuse sequences. I don't think you need one here. As I mentioned in my earlier message, case structures and shift registers will be more useful to you.

  • How to get a connection which does not participate in the main usertransaction

              Hi All I am on WLS 6.1 sp2 on win2k. I have a requirement which is like this: I
              use connection pools/txdatasources/JTA in my application. Now when a JTA transaction
              (UserTransaction) is active - I want to take a connection from the pool and do
              some operation and commit it independently of the UserTransction commit/rollback.
              Its pretty much like this - 3 components A , B, C (none of them are EJBs) are
              involved in a UserTransactions and all of them access database via a TxDataSource
              (say TD) which points to a connectionpool (say CP). Now I want B to get a connection
              handle which is not participating in the main transaction - so that the operation
              that B does is independent of what happens to the main transaction. Now I know
              I can use TransactionManager api to suspend a UserTransaction and then let B take
              a connection from the pool and commit it and then resume the transaction. But
              is there any easier way out of it? Like if B uses a DataSource instead of a TXDataSource
              - will that give B a connection which is not part of the main transaction? if
              not then whats the difference between DataSource and TXDataSource? Any help is
              appreciated.
              thanks
              Anamitra
              

    I would recommend that you mark the method as NotSupported or
              RequiresNew rather than using DataSource or suspending/resuming
              transactions on your own.
              If anything, it will be much clearer to the next person who maintains
              your code.
              -- Rob
              Anamitra wrote:
              > Hi All I am on WLS 6.1 sp2 on win2k. I have a requirement which is like this: I
              > use connection pools/txdatasources/JTA in my application. Now when a JTA transaction
              > (UserTransaction) is active - I want to take a connection from the pool and do
              > some operation and commit it independently of the UserTransction commit/rollback.
              >
              >
              >
              > Its pretty much like this - 3 components A , B, C (none of them are EJBs) are
              > involved in a UserTransactions and all of them access database via a TxDataSource
              > (say TD) which points to a connectionpool (say CP). Now I want B to get a connection
              > handle which is not participating in the main transaction - so that the operation
              > that B does is independent of what happens to the main transaction. Now I know
              > I can use TransactionManager api to suspend a UserTransaction and then let B take
              > a connection from the pool and commit it and then resume the transaction. But
              > is there any easier way out of it? Like if B uses a DataSource instead of a TXDataSource
              > - will that give B a connection which is not part of the main transaction? if
              > not then whats the difference between DataSource and TXDataSource? Any help is
              > appreciated.
              > thanks
              > Anamitra
              

  • Error single row subquery returns multiple values

    Hi All,
    I have a below query. This is query is throwiing error like single row subquery is returing more than number of records. That subquery is in my SELECT statement query. I have a value like 'tests'. That test contains more than one record. I am fetching that 'tests' child values from this query. If the test contains only one child at that time it is working fine. Can anyone share with how update this query?
    SELECT
        czpn.FEATURE_TYPE,
        czci.PS_NODE_NAME,
        DECODE(czci.VALUE_TYPE_CODE,2,czci.ITEM_VAL,
                                    3, NVL((SELECT
                                             lines_config.PS_NODE_NAME
                                         FROM
                                             CZ_CONFIG_ITEMS lines_config
                                         WHERE
                                             lines_config.PARENT_CONFIG_ITEM_ID = czci.CONFIG_ITEM_ID
                                             AND lines_config.CONFIG_HDR_ID = czci.CONFIG_HDR_ID
                                             AND lines_config.CONFIG_REV_NBR = czci.CONFIG_REV_NBR),
                                        DECODE(czci.ITEM_NUM_VAL,1,'',czci.ITEM_NUM_VAL)),
                                    0,NVL(czci.ITEM_NUM_VAL,'')) NODE_VALUE  
    FROM
        CZ_CONFIG_ITEMS czci,
        CZ_PS_NODES czpn
    WHERE
        czpn.PERSISTENT_NODE_ID = czci.PS_NODE_ID
        AND czci.CONFIG_HDR_ID = 1827349
        AND czci.CONFIG_REV_NBR = 1
        --AND czci.VALUE_TYPE_CODE <> 4
        AND czpn.FEATURE_TYPE IS NOT NULL
        --AND czci.PS_NODE_ID = 356474       
        AND czpn.DEVL_PROJECT_ID = (SELECT MAX(ps_devl1.DEVL_PROJECT_ID) FROM CZ_DEVL_PROJECTS ps_devl1, CZ_PS_NODES ps_devl, CZ_CONFIG_ITEMS ps_config_sub
                                         WHERE (ps_devl.PERSISTENT_NODE_ID = ps_config_sub.PS_NODE_ID
                                         AND ps_config_sub.PARENT_CONFIG_ITEM_ID = (SELECT ps_config_sub1.CONFIG_ITEM_ID FROM CZ_CONFIG_ITEMS ps_config_sub1
                                                                                     WHERE ps_config_sub.CONFIG_HDR_ID = ps_config_sub1.CONFIG_HDR_ID
                                                                                    AND ps_config_sub.CONFIG_REV_NBR = ps_config_sub1.CONFIG_REV_NBR 
                                                                                     AND ps_config_sub1.PS_NODE_NAME = 'ACCESSORIES'))
                                        AND ps_devl1.DEVL_PROJECT_ID = ps_devl.REFERENCE_ID                                                                                 
                                         AND ps_config_sub.CONFIG_HDR_ID = czci.CONFIG_HDR_ID
                                         AND ps_config_sub.CONFIG_REV_NBR = czci.CONFIG_REV_NBR)
        AND czci.PS_NODE_NAME = 'tests'Thanks

    Hello,
    This should work:
    SELECT
        czpn.FEATURE_TYPE,
        czci.PS_NODE_NAME,
        DECODE(czci.VALUE_TYPE_CODE,2,czci.ITEM_VAL,
                                    3, NVL((SELECT
                                             lines_config.PS_NODE_NAME
                                         FROM
                                             CZ_CONFIG_ITEMS lines_config
                                         WHERE
                                             lines_config.PARENT_CONFIG_ITEM_ID = czci.CONFIG_ITEM_ID
                                             AND lines_config.CONFIG_HDR_ID = czci.CONFIG_HDR_ID
                                             AND lines_config.CONFIG_REV_NBR = czci.CONFIG_REV_NBR
                                             AND ROWNUM <= 1),
                                        DECODE(czci.ITEM_NUM_VAL,1,'',czci.ITEM_NUM_VAL)),
                                    0,NVL(czci.ITEM_NUM_VAL,'')) NODE_VALUE  
    FROM
        CZ_CONFIG_ITEMS czci,
        CZ_PS_NODES czpn
    WHERE
        czpn.PERSISTENT_NODE_ID = czci.PS_NODE_ID
        AND czci.CONFIG_HDR_ID = 1827349
        AND czci.CONFIG_REV_NBR = 1
        --AND czci.VALUE_TYPE_CODE  4
        AND czpn.FEATURE_TYPE IS NOT NULL
        --AND czci.PS_NODE_ID = 356474       
        AND czpn.DEVL_PROJECT_ID = (SELECT MAX(ps_devl1.DEVL_PROJECT_ID) FROM CZ_DEVL_PROJECTS ps_devl1, CZ_PS_NODES ps_devl, CZ_CONFIG_ITEMS ps_config_sub
                                         WHERE (ps_devl.PERSISTENT_NODE_ID = ps_config_sub.PS_NODE_ID
                                         AND ps_config_sub.PARENT_CONFIG_ITEM_ID = (SELECT ps_config_sub1.CONFIG_ITEM_ID FROM CZ_CONFIG_ITEMS ps_config_sub1
                                                                                     WHERE ps_config_sub.CONFIG_HDR_ID = ps_config_sub1.CONFIG_HDR_ID
                                                                                    AND ps_config_sub.CONFIG_REV_NBR = ps_config_sub1.CONFIG_REV_NBR 
                                                                                     AND ps_config_sub1.PS_NODE_NAME = 'ACCESSORIES'))
                                        AND ps_devl1.DEVL_PROJECT_ID = ps_devl.REFERENCE_ID                                                                                 
                                         AND ps_config_sub.CONFIG_HDR_ID = czci.CONFIG_HDR_ID
                                         AND ps_config_sub.CONFIG_REV_NBR = czci.CONFIG_REV_NBR)
        AND czci.PS_NODE_NAME = 'tests'Where this is restricting the records returned by your columnar subquery to one record with ROWNUM.

  • Returning multiple values from a table

    Hi there i am working on a bit of sql which will return values when they exist in a table.
    The code I have returns the correct value when there is only one entry in the tbl_studentmodules table, as soon as there is more than one entry in this table it displays no rows at all :(.
    Can anyone point out how I go about returning multiple values?
                 select modulename from tbl_modulefeedback
    where 1 = (select count(*) from tbl_studentmodules
           where upper(:APP_USER) = upper(student_id))
    and 1 = (select count(*) from tbl_modulefeedback, tbl_studentmodules
          where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)Thanks in advance!
    Ashleigh

    I'm not quite sure I understand what you are looking for, but I think a simple join may be what you need. something like:
    select modulename
    from tbl_modulefeedback mfb
       join tbl_studentmodules sm
          on mfb.modulecode = sm.modulecode
    where upper(sm.student_id) = upper(:APP_USER)This will return the module name for all modules that the given student has provided feeedback for. If there is a possibility that a student/module combination could appear in tbl_studentmodules more than once, something like this might be better to show the modulename only once.
    select modulename
    from tbl_modulefeedback mfb
    where mfb.modulecode in (select sm.modulecode
                             from tbl_studentmodules sm
                             where mfb.modulecode = sm.modulecode and
                                   upper(sm.student_id) = upper(:APP_USER))If this is not what you want, then post some sample data (preferrable in the form of insert statements or a with clause) and the results you expect rom that sample data.
    John

  • [UIX] How To: Return multiple values from a LOV

    Hi gang
    I've been receiving a number of queries via email on how to return multiple items from a LOV using UIX thanks to earlier posts of mine on OTN. I'm unfortunately aware my previous posts on this are not that clear thanks to the nature of the forums Q&A type approach. So I thought I'd write one clear post, and then direct any queries to it from now on to save me time.
    Following is my solution to this problem. Please note it's just one method of many in skinning a cat. It's my understanding via chatting to Oracle employees that LOVs are to be changed in a future release of JDeveloper to be more like Oracle Forms LOVs, so my skinning skills may be rather bloody & crude very soon (already?).
    I'll base my example on the hr schema supplied with the standard RDBMS install.
    Say we have an UIX input-form screen to modify an employees record. The employees record has a department_id field and a fk to the departments table. Our requirement is to build a LOV for the department_id field such that we can link the employees record to any department_id in the database. In turn we want the department_name shown on the employees input form, so this must be returned via the LOV too.
    To meet this requirement follow these steps:
    1) In your ADF BC model project, create 2 EOs for employees and departments.
    2) Also in your model, create 2 VOs for the same EOs.
    3) Open your employees VO and create a new attribute DepartmentName. Check “selected in query”. In expressions type “(SELECT dept.department_name FROM departments dept WHERE dept.department_id = employees.department_id)”. Check Updateable “always”.
    4) Create a new empty UIX page in your ViewController project called editEmployees.uix.
    5) From the data control palette, drag and drop EmployeesView1 as an input-form. Notice that the new field DepartmentName is also included in the input-form.
    6) As the DepartmentName will be populated either from querying existing employees records, or via the LOV, disable the field as the user should not have the ability to edit it.
    7) Select the DepartmentId field and delete it. In the UI Model window delete the DepartmentId binding.
    8) From the data controls palette, drag and drop the DepartmentId field as a messageLovInput onto your page. Note in your application navigator a new UIX page lovWindow0.uix (or similar) has been created for you.
    9) While the lovWindow0.uix is still in italics (before you save it), rename the file to departmentsLov.uix.
    10) Back in your editEmployees.uix page, your messageLovInput source will look like the following:
    <messageLovInput
        model="${bindings.DepartmentId}"
        id="${bindings.DepartmentId.path}"
        destination="lovWindow0.uix"/>Change it to be:
    <messageLovInput
        model="${bindings.DepartmentId}"
        id="DepartmentId"
        destination="departmentsLov.uix"
        partialRenderMode="multiple"
        partialTargets="_uixState DepartmentName"/>11) Also change your DepartmentName source to look like the following:
    <messageTextInput
        id=”DepartmentName”
        model="${bindings.DepartmentName}"
        columns="10"
        disabled="true"/>12) Open your departmentsLov.uix page.
    13) In the data control palette, drag and drop the DepartmentId field of the DepartmentView1 as a LovTable into the Results area on your page.
    14) Notice in the UI Model window that the 3 binding controls have been created for you, an iterator, a range and a binding for DepartmentId.
    15) Right click on the DepartmentsLovUIModel node in the UI Model window, then create binding, display, and finally attribute. The attribute binding editor will pop up. In the select-an-iterator drop down select the DepartmentsView1Iterator. Now select DepartmentName in the attribute list and then the ok button.
    16) Note in the UI Model you now have a new binding called DCDefaultControl. Select this, and in the property palette change the Id to DepartmentName.
    17) View the LOV page’s source, and change the lovUpdate event as follows:
    <event name="lovSelect">
        <compound>
            <set value="${bindings.DepartmentId.inputValue}" target="${sessionScope}" property="MyAppDepartmentId" />
            <set value="${bindings.DepartmentName.inputValue}" target="${sessionScope}" property="MyAppDepartmentName" />
        </compound>
    </event>18) Return to editEmployees.uix source, and modify the lovUpdate event to look as follows:
    <event name="lovUpdate">
        <compound>
            <set value="${sessionScope.MyAppDepartmentId}" target="${bindings.DepartmentId}" property="inputValue"/>
            <set value="${sessionScope.MyAppDepartmentName}" target="${bindings.DepartmentName}" property="inputValue"/>     
        </compound>
    </event>That’s it. Now when you select a value in your LOV, it will return 2 (multiple!) values.
    A couple things to note:
    1) In the messageLovInput id field we don’t use the “.path” notation. This is mechanism for returning 1 value from the LOV and is useless for us.
    2) Again in the messageLovInput we supply “_uixState” as an entry in the partialTargets.
    3) We are relying on partial-page-refresh functionality to update multiple items on the screen.
    I’m not going to take the time out to explain these 3 points, but it’s worthwhile you learning more about them, especially the last 2, as a separate exercise.
    One other useful thing to do is, in your messageLovInput, include as a last entry in the partialTargets list “MessageBox”. In turn locate the messageBox control on your page (if any), and supply an id=”MessageBox”. This will allow the LOV to place any errors raised in the MessageBox and show them to the user.
    I hope this works for you :)
    Cheers,
    CM.

    Thanks Chris,
    It took me some time to find the information I needed, how to use return multiple values from a LOV popup window, then I found your post and all problems were solved. Its working perfectly, well, almost perfectly.
    Im always fighting with ADF-UIX, it never does the thing that I expect it to do, I guess its because I have a hard time letting go of the total control you have as a developer and let the framework take care of a few things.
    Anyway, I'm using your example to fill 5 fields at once, one of the fields being a messageChoice (a list with countries) with a LOV to a lookup table (id , country).
    I return the countryId from the popup LOV window, that works great, but it doesn't set the correct value in my messageChoice . I think its because its using the CountryId for the listbox index.
    So how can I select the correct value inside my messageChoice? Come to think of it, I dont realy think its LOV related...
    Can someone help me out out here?
    Kind regards
    Ido

  • How to return multiple values from dialog popup

    hi all
    I'm using ADF 10g. I have a requirement that I have to return multiple values from a dialog.
    I have a page containing a table with a button which calls the dialog. The dialog contains a multi-select table where i want to select multiple records and add them to the table in the calling page.
    In the backing bean of the calling page, I have the returnListener method.
    I am thinking that I have to store the selected rows from dialog in an array and return that array to the returnListener...but I don't know how to go about it with the code.
    Can someone help me out with it?
    thanks

    Hi Frank,
    I'm trying to implement your suggestion but getting comfused.
    AdfFacesContext.getCurrentInstance().returnFromDialog(null, hashMap) is called in ActionListener method, from what I understood.
    ReturnListener method already calls it, so no need to call explicitly.
    Okay here's what i'm doing.
    command button launches the dialog on the calling page.
    In the dialog page, there is a button "select", which when i click, closes the dialog and returns to calling page. I put a af:returnActionListener on this button, which logically should have a corresponding ReturnListener() in the calling page backing bean.
    Now I have 3 questions:
    1. do i have to use ActionListener or ReturnListener?
    2. where do I create the hashMap? Is it in the backing bean of the dialog or in the one of calling page?
    3. how do I retrieve the keys n values from hashmap?
    please help! thanks
    This is found in the backing bean of calling page:
    package mu.gcc.dms.view.bean.backing;
    import com.sun.java.util.collections.ArrayList;
    import com.sun.java.util.collections.HashMap;
    import com.sun.java.util.collections.List;
    import java.io.IOException;
    import java.util.Map;
    import javax.faces.application.Application;
    import javax.faces.application.ViewHandler;
    import javax.faces.component.UIViewRoot;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import javax.faces.event.ActionEvent;
    import mu.gcc.dms.model.services.DMSServiceImpl;
    import mu.gcc.dms.model.views.SiteCompaniesImpl;
    import mu.gcc.dms.model.views.SiteCompaniesRowImpl;
    import mu.gcc.dms.model.views.lookup.LkpGlobalCompaniesImpl;
    import mu.gcc.util.ADFUtils;
    import mu.gcc.util.JSFUtils;
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.adf.model.binding.DCIteratorBinding;
    import oracle.adf.view.faces.context.AdfFacesContext;
    import oracle.adf.view.faces.event.ReturnEvent;
    import oracle.adf.view.faces.model.RowKeySet;
    import oracle.binding.AttributeBinding;
    import oracle.binding.BindingContainer;
    import oracle.binding.OperationBinding;
    import oracle.jbo.AttributeDef;
    import oracle.jbo.Key;
    import oracle.jbo.Row;
    import oracle.jbo.RowIterator;
    import oracle.jbo.RowSetIterator;
    import oracle.jbo.domain.Number;
    import oracle.jbo.server.java.util.Iterator;
    public class CompanyList {
    private BindingContainer bindings;
    private Map hashMap;
    DMSServiceImpl service =(DMSServiceImpl)ADFUtils.getDataControlApplicationModule("DMSServiceDataControl");
    SiteCompaniesImpl siteCompanyList = service.getSiteCompanies();
    LkpGlobalCompaniesImpl globalCompanyList = service.getLkpGlobalCompanies();
    public CompanyList() {
    public BindingContainer getBindings() {
    return this.bindings;
    public void setBindings(BindingContainer bindings) {
    this.bindings = bindings;
    *public void setHashMap(Map hashMap) {*
    *// hashMap = (Map)new HashMap();*
    this.hashMap = hashMap;
    *public Map getHashMap() {*
    return hashMap;
    public String searchCompanyButton_action() {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    bindings.getOperationBinding("Execute");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    *public void addCompanyActionListener(ActionEvent actionEvent){*
    AdfFacesContext.getCurrentInstance().returnFromDialog(null, hashMap);
    public void addCompanyReturnListener(ReturnEvent returnEvent){
    //how to get hashmap from here??
    public String addCompanyButton_action() {
    return "dialog:globalLovCompanies";
    }

  • How can I return multiple values with PL/SQL Web Services

    Hi,
    I'm new to developping Web Services. I'm doing some tests with JDeveloper and OC4J on my local machine with a Web Services based on a PL/SQL function within a package. Right now that function only returns one value. So the xml response only has one output.
    I'd like to know how can I return multiple values with my PL/SQL Web Service. For example, if I want to return an employee's name and id? And that the xml contains two output : <employee>, <empid>?
    Reginald
    ps : I have searched the forum and I couldn't find an answer to this question, if that has been discussed AND answered before, can you please post the link? Thanks

    Alright, I actually found my answer. Since this was asked I think as a followup somewhere else I'll give my answer.
    It is very simple, all you have to do is create an Object Type and then Return that object type. After that, JDeveloper will take care of everything and you will have an xml response with multiple values. Here
    {color:#ff0000}
    create or replace TYPE person AS OBJECT
    ( id_interv number,
    first_name VARCHAR2(50),
    last_name VARCHAR2(50),
    date_birth date
    );{color}
    Then your function used in your Web Service should look something like this :
    {color:#ff0000}
    function info_emp (p_empno IN VARCHAR2) RETURN person AS
    l_emp person := person(-1,'','','');
    BEGIN
    SELECT first_name
    ,last_name
    ,emp_no
    INTO l_emp.first_name
    ,l_emp.last_name
    ,l_emp.emp_no
    FROM emp
    WHERE upper(emp_no) = upper (emp_no);
    {color}
    {color:#ff0000}
    RETURN l_emp;
    EXCEPTION WHEN NO_DATA_FOUND THEN
    l_emp := person (-1,'n/a','n/a','n/a');
    RETURN l_emp ;
    END info_emp;{color}
    {color:#ff0000}{color:#000000}After that, this is what the xml response looks like :{color}{color}
    &lt;first_name xsi:type="xsd:string"&gt;John&lt;/first_name&gt;
    &lt;last_name xsi:type="xsd:string"&gt;Doe&lt;/last_name&gt;
    &lt;emp_no xsi:type="xsd:string"&gt;0250193&lt;/emp_no&gt;

  • How to return multiples values useing functions

    Hi to all,
    I am using functions to return multiple values of two rows or multiple rows.
    For example emp id = 100 and i need to return the value for this(empid) input and output of this first_name and salary.
    I am tried in this way below but got errors (ORA-00932: inconsistent datatypes: expected NUMBER got HR.EMP_TYPE)
    create or replace type emp_type as object(first_name varchar2(20),salary number);
    create or replace function f1(empid in number)
    return emp_type
    as
    emp_record emp_type;
    begin
    select first_name,salary into emp_record.first_name,emp_record.salary from employees where employee_id = empid ;
    return emp_record;
    end;
    select f1(100) from dual;

    Sql is Sql and plsql is plsql. Though we can almost use all the sql objects inside a plsql code but vice versa is not always possible. Since plsql is tightly integrated with sql , if you return a number/date/varchar2 datatype values from plsql code to sql code,there is nothing wrong .Sql acknowledges this return type and knows well about how to handle it .But plsql record is a plsql specific datatype ,oracle was not built keeping in mind the fact that people will be creating difference types of records in plsql .So if you return a plsql datatype into a sql statement (which is processed by a sql engine) ,you need to tell oracle that I have written a plsql code which is going to return a record type so that sql engine can interpret it well.
    So all you need to do is create record in sql (known as object in sql ),when you make one, the entry is going to be shown in user_types views. Now use it like any other data type. I assume that the forum link provided in the above post is the best one to understand.
    Thanks,
    Rahul

  • How can IWD_VALUE_HELP return multiple values, instead of one

    Hello expert,
    I have requirement to use F4 help to return multiple values to the using WD component. Basically in my main WD component, I have a View where I have a list box, this list box has a F4 assigned to it, clicking on the F4 brings up hte F4 help, in the F4 help, user can select multiple values which should be returned to my main component / view to be displayed in the list box.
    I'd implement IWD_VALUE_HELP to create my own F4 help component. However I have difficulty to return multiple values. As I understand there is only way to return data from F4 help to the calling Main WD component / view:
    Item_LISTENER->F4_CONTEXT_ELEMENT->set_attribute( name = 'MYATTRName' value = myvalue).
    Do you guys know how to archive what is required here?
    Thanks
    Jayson

    Hello Jayson,
    the element reference that is passed into the IWD_VALUE_HELP implementing component is the element of the calling application's context.
    Therefore you can use methods like
    IF_WD_CONTEXT_ELEMENT->GET_NODE
    (to get the parent node of the element) and 
    IF_WD_CONTEXT_ELEMENT->GET_CHILD_NODE
    to get access to other parts of the context.
    say for example your value help should populate a pop-in table with multiple entries.
    your application allows you to choose a type of ice-cream cone and then to choose the flavour of ice-cream (multi selection)has a structure like:
    Context_root
    --> List_of_ice_creams (0..n)
    >Ice_cream_flavours(1..n)
    In the element of list_of_ice_creams you have an attribute "flavour" which links to your value help.
    Choosing this value-help should allow you to select multiple flavours, return these and populate them into the sub-node Ice_cream_flavours.
    Within your custom value help you can get a reference to the node Ice_cream_flavours by calling the method
    lo_flavour_node = IItem_LISTENER->F4_CONTEXT_ELEMENT->GET_CHILD_NODE("ICE_CREAM_FLAVOURS"). You could then populate this in you value help component.
    As I mentioned - this isn't great as it means the value help cannot really be used elsewhere as it has a dependency on the structure of the calling context. But that may not be an issue for you.
    Hope that helps,
    Chris

  • How to get line item net price and net value?

    I have using "BAPI_SALESORDER_SIMULATE" to SIMULATE to create SO,
    the return table
    ORDER_ITEMS_OUT-NET_VALUE is not equals than created by VA01 .
    how to get line item net price and net value?

    Hi,
    Can u elaborate ur query ?
    By this FM you cannot create a SO . Use FM --> BAPI_SALESORDER_CREATEFROMDAT2
    Regards,
    MAdhukar Shetty

  • How to get a list of values used in the WHERE filter of stored procedures and functions in SQL Server

    How can I get a list of values (one or more) used in the WHERE filter of stored procedures and functions in SQL Server?
    How can get a list of values as shown (highlighted) in the sample stored procedure below?
    ALTER PROC [dbo].[sp_LoanInfo_Data_Extract] AS
    SELECT   [LOAN_ACCT].PROD_DT,
                  [LOAN_ACCT].ACCT_NBR, 
                  [LOAN_NOTE2].OFCR_CD, 
                  [LOAN_NOTE1].CURR_PRIN_BAL_AMT, 
                  [LOAN_NOTE2].BR_NBR,
    INTO #Table1
    FROM
                    dbo.[LOAN_NOTE1],
                    dbo.[LOAN_NOTE2],
                    dbo.[LOAN_ACCT]
    WHERE
                    [LOAN_ACCT].PROD_DT = [LOAN_NOTE1].PROD_DT
                    and
                    [LOAN_ACCT].ACCT_NBR = [LOAN_NOTE1].ACCT_NBR
                    and
                    [LOAN_NOTE1].PROD_DT = [LOAN_NOTE2].PROD_DT
                    and
                    [LOAN_NOTE1].MSTR_ACCT_NBR = [LOAN_NOTE2].MSTR_ACCT_NBR
                    and
                    [LOAN_ACCT].PROD_DT = '2015-03-10'
                    and
                    [LOAN_ACCT].ACCT_STAT_CD IN
    ('A','D')
                    and
                    [LOAN_NOTE2].LOAN_STAT_CD IN
    ('J','Z')
    Lenfinkel

    Hi LenFinkel,
    May I know what is purpose of this requirement, as olaf said,you may parse the T-SQL code (or the execution plan), which is not that easy.
    I have noticed that the condition values in your Stored Procedure(SP) are hard coded and among them there is a date values, I believe some day you may have to alter the SP when the date expires. So why not declare 3 parameters of the SP instead hard coding?
    For multiple values paramter you can use a
    table-valued parameter. Then there's no problem getting the values.
    If you could elaborate your purpose, we may help to find better workaround.
    Eric Zhang
    TechNet Community Support

  • Return multiple values from a function to a SELECT statement

    I hope I've provided enough information here. If not, just let me know what I'm missing.
    I am creating a view that will combine information from a few tables. Most of it is fairly straightforward, but there are a couple of columns in the view that I need to get by running a function within a package. Even this is fairly straightforward (I have a function named action_date in a package called rp, for instance, which I can use to return the date I need via SELECT rp.action_date(sequence_number).
    Here's the issue: I actually need to return several bits of information from the same record (not just action_date, but also action_office, action_value, etc.) - a join of the tables won't work here as I'll explain below. I can, of course, run a separate function for each statement but that is obviously inefficient. Within the confines of the view select statement however, I'm not sure how to return each of the values I need.
    For instance, right now, I have:
    Table1:
    sequence_number NUMBER(10),
    name VARCHAR(30),
    Table2:
    Table1_seq NUMBER(10),
    action_seq NUMBER(10),
    action_date DATE,
    action_office VARCHAR(3),
    action_value VARCHAR(60),
    I can't simply join Table1 and Table2 because I have to do some processing in order to determine which of the matching returned rows I actually need to select. So the package opens a cursor and processes each row until it finds the one that I need.
    The following works but is inefficient since all of the calls to the package will return columns from the same record. I just don't know how to return all the values I need into the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    rp.action_date(sequence_number) action_date,
    rp.action_office(sequence_number) action_office,
    rp.action_value(sequence_number) action_value
    FROM table1
    Is there a way to return multiple values into my SELECT statement or am I going about this all wrong?
    Any suggestions?
    Thanks so much!

    Hi,
    What you want is a Top-N Query , which you can do using the analytic ROW_NUMBER function in a sub-query, like this:
    WITH     got_rnum     AS
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;As written, this will return (at most) one row.
    I suspect you'll really want to get one row for each group , where a group is defined by some value in a table to which you're joining.
    In that case, add a PARTITION BY clause to the ROW_NUMBER function.
    If you'd post a little sample data (CREATE TABLE and INSERT statements), I could show you exactly how.
    Since I don't have your tables, I'll show you using tables in the scott schema.
    Here's a view that has data from the scott.dept table and also from scott.emp, but only for the most senior employee in each department (that is, the employee with the earliest hiredate). If there happens to be a tie for the earliest hiredate, then the contender with the lowest empno is chosen.
    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    SELECT     *
    FROM     senior_emp
    ;Output:
    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81 
    By the way, one of the conditions in the query you posted was
    action_office     LIKE 'E'which is equivalent to
    action_office     = 'E'(LIKE is always equivalent to = if the string after LIKE doesn't contain any wildcards.)
    Did you mean to say that, or did you mean something like this:
    action_office     LIKE 'E%'instead?

  • Lov to return multiple values

    I had a made a dynamic query "Select empno,empname from emp",
    but it returns me only one value.In my main form i had 2 fields
    EMP_NO and EMP_NAME.
    How to get both the values through LOV.
    Any advice.
    Regards,
    aakash

    If your select statement is "Select empno,empname from emp" in the dynamic LOV you have created, then it means that the diaplay value is "empno" and the return value is "empname". Always, the first column selected is the display name and the second one is the return value for the dynamic LOV. You cannot return multiple values thru LOVs since forms will not accept currently. In your case, you need to have 2 LOVs... one for empno and the other for empname.

Maybe you are looking for