SubQuery in TopLink

I amn trying to create SubQuery using TopLink.
I am using an expression like this
ReportQuery salarySubQuery= new ReportQuery(Employee.class,new ExpressionBuilder());
salarySubQuery.addMaximum("salary");
salarySubQuery = salarySubQuery.and(expressionBuilder.get("deptNo").equal("10"));
salarySubQuery = salarySubQuery.and(expressionBuilder.get("designation").equal("MANAGER"));
I wanted to add one where clause to this subquery like detpno=10.
The total query will be like
SELECT EMPNAME FROM EMP WHERE NAME LIKE 'SO%' and SALARY = (SELECT MAX(SALARY) FROM EMP WHERE DEPTNO=10 AND DESIGNATION='MANAGER')
I am creating main expression like this
MainExpr = MainExpr.and(expressionBuilder.get("salary").equal(expressionBuilder.subQuery(salaryQuery)));
This leaves off the WHERE clause and it creates the query like
SELECT EMPNAME FROM EMP WHERE NAME LIKE 'SO%' and SALARY = (SELECT MAX(SALARY) FROM EMP )AND DEPTNO=10 AND DESIGNATION='MANAGER'
Pls help me regarding this. Is there any other method available?
Regards
Solomon

Your code should look like the following:
ReportQuery salarySubQuery= new ReportQuery(Employee.class,new ExpressionBuilder());
salarySubQuery.addMaximum("salary");
salarySubQuery.setSelectionCriteria(salarySubQuery.getExpressionBuilder().get("deptNo").equal("10").and(salarySubQuery.getExpressionBuilder().get("designation").equal("MANAGER")));
MainExpr.and(expressionBuilder.get("salary").equal(salarySubQuery);
--Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Update with subquery in TopLink ?

    I want to activate the user account updating its status to ACTIVE.
    UPDATE PujUserEntity as user SET user.status.id = (SELECT status.id from PujUserStatusEntity status WHERE status.tag='ACTIVE') WHERE user.login= :login AND user.email= :email
    the error during the deployment on Glassfish (TopLink):
    CLI171 Command deploy failed : Deploying application in domain failed;
    Exception Description: Syntax error parsing the query [activateUserAccount: UPDATE PujUserEntity as user SET user.status.id = (SELECT status.id from PujUserStatusEntity status WHERE status.tag='ACTIVE') WHERE user.login= :userLogin AND user.email= :userEmail], line 1, column 52: unexpected token [SELECT].
    Internal Exception: line 1:52: unexpected token: SELECT

    According to JPA specification you are not allowed to use subquery in that place. In SET part you can only use simple_arithmetic_expression | string_primary | datetime_primary | boolean_primary | enum_primary | simple_entity_expression | NULL (JSR 220 Java Persistence API specification page 104). You should be able to use native query, or find status.id first and then just pass it as parameter.

  • Subquery in select attributes

    I don't think this is possible, I've exhausted every option I can think of to output this sql in toplink. I've searched the web and this forum but found no info about it. If it's not possible please let me know and I will move on to something else.
    This is a simplified example of what I want to do in toplink:
    select r.name, (select count(*) from items i where i.request_id = r.request_id), r.comments from requests r where r.requestor like '%FRED%' ... etc
    I can get the subquery in the where clause fine, but I can't work out how to put it in the select part of the statement.
    Thanks for your help!

    Oh lookie at me, I'm replying to myself. Again.
    If you want a subquery in the select attributes then gosh darn it use a function. Create an oracle function that does the subquery and add it as an attribute with:
    query.addFunctionItem("numRequests", request.get("id"), "request_counter")

  • DB polling : query with subquery

    Hi,
    We are upgrading the 10g code to 11g, where one process has the DB polling with custom SQQL. This SQL has a subquery like,
    Select Name, ID, CID from tabl1 where lastdate + (select num_value from table2 where column2 = "xxx") <= sysdate
    We want the similar functionality in 11g. The upgraded code generated few artifiacts like toplink. We have bulilt that and deployed to server. But it is not polling the data eventhough the matching records are present in the tables.
    Please let us know how to fix this issue.
    Thanks,
    Vinoth

    Hi,
    Not sure about your question.
    But you say when you uss 01-apr-10 you get the expected results.
    So why dont you try using trunc on botht sides
    SELECT vfn.cat
      FROM vps_fishery_ner vfn, valid_fishery vf
    WHERE vfn.plan = vf.plan
       AND vfn.cat = vf.cat
       AND vf.permit_year = 2010
       AND vf.moratorium_fishery = 'T'
       AND vfn.vp_num = 211652
       AND vfn.ap_year = 2010
       AND vfn.plan = 'MUL'
       AND trunc(vfn.date_issued) = (SELECT MAX(trunc(date_issued))
                                FROM vps_fishery_ner
                               WHERE vp_num = 211652
                                 AND ap_year = 2010);Rememeber if you are couting on some Index to be used you might want to recheck.
    IN answer to your question why it does not return with subquery included, because the TIME PART is not the same.
    You yourself proved it by using the supplying only the date part.
    Regards,
    Bhushan

  • Bug in OC4J [unexpected token: IN] when use Subquery

    Hi
    I use this named query in my entity, but when I run it from JDeveloper 10.1.3.0.4 (SU2)
    it throw exception
    Thia is as sample query:
    @NamedQuery(name="EmpbyDept",query="SELECT object(o) FROM Employees o WHERE o.departments IN(SELECT object(d) FROM Departments d)")
    Internal Exception: Exception [TOPLINK-0] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.EJBQLException
    Exception Description: Syntax Recognition Problem parsing the EJBQL [SELECT object(o) FROM Employees o WHERE o.departments IN(SELECT object(d) FROM Departments d)]. The parser returned the following [unexpected token: IN]
    I looked in the Java Persistence API Proposed final for the In Expressions and it look like this:
    in_expression ::=state_field_path_expression [NOT] IN ( in_item {, in_item}* | subquery)
    in_item ::= literal | input_parameter
    Ghassan

    Hi Ghassan,
    At the moment we don't have a final date for the release, but we are hopeful to have a 10.1.3.1 Beta release very soon (in a few weeks), please keep watching the OTN space, and we will also announce it here in the forums.
    Thanks for your patience.
    Deepak

  • How to CREATE SUBQUERY in ADF or generate the ADF table consisting of colum

    hi,
    I have to generate the ADF table consisting of columns from different database tables depending on some criteria.. kindly help me in generating the subquery or retrive the columns from different database tables......

    hi, i m using adf bc, toplink . i have got 3 row of data in a table now i wnt to pass these values one by one in the query to fetch the coloumn from the different database table and place the result obtained in the third new coloumn... can u give me the detailed answer

  • URGENT: Subquery IN error

    Hi
    I want to execute a select as follows -
    select * from obj, re where re.obj_key in (select obj.obj_key from obj where obj.obj_name like '%' )
    To handle this - I have the following code:
    ReportQuery subQuery =new ReportQuery(Obj.class, objExpr);
    subQuery.addAttribute("objKey", subQuery.getExpressionBuilder().get("objKey"));
    subQuery.setShouldCacheStatement(false);
    subQuery.setSelectionCriteria(objExpr);
    System.out.println("reportqry ok:"+subQuery.getSQLString());
    newExpr = new ExpressionBuilder().get("objKey").in(subQuery);
    System.out.println("reportqry ok:"+subQuery.getSQLString());
    newExpr = new ExpressionBuilder().get("objKey").in(subQuery);
    I get error - "Invalid Query Key" error for "objKey". Also if I pring the SQLStatement for subQuery I get null.
    Any suggestions on what I might be doing wrong here ?

    Thx for your response. My descriptor has this query key defined.
    Here is the snippet from my toplink xmlfile :
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>actKey</opm:attribute-name>
    <opm:field table="RECON_EVENTS" name="ACT_KEY" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>objKey</opm:attribute-name>
    <opm:field table="RECON_EVENTS" name="OBJ_KEY" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    Full stacktrace is: Exception [TOPLINK-6015] (Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 080228)): oracle.toplink.exceptions.QueryException
    [junit] Exception Description: Invalid query key [objKey] in expression.
    [junit] at oracle.toplink.exceptions.QueryException.invalidQueryKeyInExpression(QueryException.java:620)
    [junit] at oracle.toplink.internal.expressions.QueryKeyExpression.getQueryKeyOrNull(QueryKeyExpression.java:362)
    [junit] at oracle.toplink.internal.expressions.ObjectExpression.getDescriptor(ObjectExpression.java:215)
    [junit] at oracle.toplink.internal.expressions.DataExpression.getOwnedTables(DataExpression.java:214)
    at oracle.toplink.internal.expressions.ObjectExpression.getOwnedTables(ObjectExpression.java:304)
    [junit] at oracle.toplink.internal.expressions.QueryKeyExpression.getOwnedTables(QueryKeyExpression.java:348)
    [junit] at oracle.toplink.expressions.Expression.assignTableAliasesStartingAt(Expression.java:465)
    [junit] at oracle.toplink.internal.expressions.SQLSelectStatement$1.iterate(SQLSelectStatement.java:697)
    [junit] at oracle.toplink.expressions.Expression.iterateOn(Expression.java:2199)
    [junit] at oracle.toplink.internal.expressions.DataExpression.iterateOn(DataExpression.java:305)
    [junit] at oracle.toplink.internal.expressions.SubSelectExpression.iterateOn(SubSelectExpression.java:59)
    at oracle.toplink.internal.expressions.FunctionExpression.iterateOn(FunctionExpression.java:311)
    [junit] at oracle.toplink.internal.expressions.CompoundExpression.iterateOn(CompoundExpression.java:190)
    [junit] at oracle.toplink.internal.expressions.ExpressionIterator.iterateOn(ExpressionIterator.java:65)
    [junit] at oracle.toplink.internal.expressions.SQLSelectStatement.assignAliases(SQLSelectStatement.java:710)
    [junit] at oracle.toplink.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1333)
    [junit] at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.buildReportQuerySelectStatement(ExpressionQueryMechanism.java:512)
    [junit] at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.buildReportQuerySelectStatement(ExpressionQueryMechanism.java:464)
    [junit] at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.prepareReportQuerySelectAllRows(ExpressionQueryMechanism.java:1489)
    [junit] at oracle.toplink.queryframework.ReportQuery.prepareSelectAllRows(ReportQuery.java:1201)
    [junit] at oracle.toplink.queryframework.ReadAllQuery.prepare(ReadAllQuery.java:767)
    [junit] at oracle.toplink.queryframework.ReportQuery.prepare(ReportQuery.java:973)
    [junit] at oracle.toplink.queryframework.DatabaseQuery.checkPrepare(DatabaseQuery.java:443)
    [junit] at oracle.toplink.queryframework.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:608)
    [junit] at oracle.toplink.queryframework.DatabaseQuery.prepareCall(DatabaseQuery.java:1528)
    [junit] at oracle.iam.reconciliation.dao.event.EventMgmtDao.getSearchResultCount(EventMgmtDao.java:434)
    [junit] at oracle.iam.reconciliation.impl.EventMgmtServiceImpl.getSearchCount(EventMgmtServiceImpl.java:121)
    Also my sql whereclause has more than just this condition - so here is the expression output I get:
    Function operator IN
    [junit] Query Key objKey
    [junit] Base QUERY OBJECT
    [junit] overall expr:
    [junit] Logical operator OR
    [junit] Logical operator OR
    [junit] Logical operator OR
    [junit] Relation operator =
    [junit] Query Key reChangeType
    [junit] Base QUERY OBJECT
    [junit] Constant No Match Found
    [junit] Relation operator =
    [junit] Query Key reEntityType
    [junit] Base QUERY OBJECT
    [junit] Constant No Match Found
    [junit] Relation operator =
    [junit] Query Key reStatus
    [junit] Base QUERY OBJECT
    [junit] Constant No Match Found
    [junit] Function operator IN
    [junit] Query Key objKey
    [junit] Base QUERY OBJECT
    If I wanted to - is it possible to use SQL just to handle this expression alone ?

  • How to SQL intersect using Toplink expressions

    I try to do this SQL intersect
    SELECT part_k FROM ATTR_VALUE
    where commodity_n ='dab badge' and attribute_n='Badge Width' and attribute_value_x='10'
    INTERSECT
    SELECT part_k FROM ATTR_VALUE
    where commodity_n='dab badge' and attribute_n='Brand Logo' and attribute_value_x='Jaguar'
    using the following Toplink expressions:
    Expression e1 = builder.get("commodity").equal("dab badge")
    .and(builder.get("attribute").equal("Badge Width"))
    .and(builder.get("value").equal("10"));
    Expression e2 = builder.get("commodity").equal("dab badge")
    .and(builder.get("attribute").equal("Brand Logo"))
         .and(builder.get("value").equal("Jagua"));
    Expression myExpression = e1.and(e2);
    However, this would not give me the correct result.
    Any suggestions would be greatly appreicated.

    Right, TopLink doesn't have an Intersect operator. If it did, you might still get the same problem unless you are using a report query to return only the "part_k" value instead of an object since attribute_n cannot have a value of both 'Badge Width' and 'Brand Logo' at the same time.
    You can get the part_k values or the objects from the ATTR_VALUE
    table by using a report query for the second expression as a subquery to the IN clause. Something like
      ReportQuery subquery = new ReportQuery(yourclass.class);
      ExpressionBuilder subBuilder = subquery.getBuilder();
      Expression e2 = subBuilder.get("commodity").equal("dab badge").and(subBuilder.get("attribute").equal("Brand Logo")).and(subBuilder.get("value").equal("Jagua"));
      subquery.setSelectionCriteria(e2);
      subquery.addAttribute("partk");
      Expression myExpression = e1.and( builder.get("partk").in(subquery) );Regards,
    Chris

  • Subquery as Select Attribute

    How would I do the following query using Toplink expressions:
    select a.something, ( select min(b.column) from b where b.fk = a.pk)
    from a
    where ...
    I have figured out how to do:
    select a.something
    from a
    where whatever = ( select min(b.column) ... )
    but when I try to add the subquery as an attribute instead of as part of the where clause, I get the following error:
    "The expression has not been initialized correctly. Only a single ExpressionBuilder should be used for a query.
    For parallel expressions, the query class must be provided to the ExpressionBuilder constructor, and the query's ExpressionBuilder must
    always be on the left side of the expression."
    Thanks.

    Group by clauses are for usage with aggregate functions. Since you don't have an aggregate function in your outer query, you don't need a group by clause in your outer query. Although you do have aggregate functions (count) in your sub-queries, since they are only on one column, you don't need a group by there either. Please see the corrected query below.
    SELECT DISTINCT pro.proj_name,
           a.doc_name,
           b.description,
           substr (b.CATEGORY,6) Doc_Type,
           TO_DATE (SUBSTR (a.delidate, 1, 7), 'YYYY-MM') open_date,
           a.status,
           (select COUNT(item_id) as cnt_maj
            from   day_cmcs_comment
            where  status IN ('CL', 'OP')
            AND    classification IN ('MA', 'NF')) cnt_major,
           (select COUNT(item_id) as cnt_mnr
            from   day_cmcs_comment
            where  status IN ('CL', 'OP')
            AND    classification IN ('ED', 'NC')) cnt_minor
    FROM   day_cmcs_comment a,
           day_cmcs_main b,
           gen_proj_catg gen,
           proj_cmcs_proj_mapping pro
    WHERE  pro.doc_name = a.doc_name
    AND    pro.proj_id = gen.other_id
    AND    a.doc_name(+) = b.name
    AND    pro.edition = b.edition
    ORDER  BY pro.proj_name

  • How to use jta in toplink and stateless session bean EJB 3.0?

    I have an application with techologies jsf,stateless session bean, adf, toplink
    generated by toplink workbench.
    In web side ı want to use two methods in stateless session bean which are updated
    different tables. I call these methods in my page backing bean.
    I also want to JTA in web side. My first methods is done correctly, but second method has an error. I wanto to rollback all transaction.
    How can ı do that? with using JTA in Toplink...

    Yuichi
    Did you manage to solve this?  I'm doing something similar and seeing the same problem, although they're up to 7.3 SP7.
    Any help greatly appreciated.
    Lewis

  • Upgrading from Weblogic 6.1sp5/TopLink 3.6.3 to Weblogic 8.1/TopLink 9.0.4

    Hi.
    We are doing the migration from Weblogic 6.1sp5/TopLink 3.6.3 to Weblogic 8.1 & TopLink 9.0.4
    We have been reading available documentation and started the migration. We have not had any problems with package ranaming issues and XML DOCTYPES changes.
    As we do have a lot of ammedmed querys, we do prefer to use a java class as our proyect mapping descriptor rather than a huge XML.
    We are currently porting all our querys to the new system.
    As we are doing a lot of changes we are also updating our EJB 1.1 entity beans to EJB 2.0 (maybe in the future we will deploy our EJBs with local interfaces too).
    The main problem we are facing right now is with all the querys we had in our toplink-cmp-<bean>.xml files. Even if most of the finders are "REDIRECT" querys that had to be ammendmed we have a good number of "EXPRESSION"s on them.
    As far as we are able to see we should move them to the TopLink Project java file in the querys section. The question is: is it possible to declare them in the ejb-jar.xml file into the <ejb-ql> tag (we have seen that the TopLinkImplemented string appears on the <ejb-ql> telling the container who should handle the query, so if Weblogic can be "tricked" to do that "ejb-ql" it may be possible to do the same with a TopLink expression isn't it?.
    Another issue we don't have clear is if now all the querys must be either ejb-ql (compliant with the EJB 2.0 standard) or named querys (either TopLink expressions or SQL querys) defined in the TopLink Project java or XML files. What happened with the redirect querys
    I would like to point just another issue we have "solved" but we are not really satisfied with how we solved it.
    We are using timestamp locking with our entity beans. The shouldBindAllParameters is set to true too and we have the logging activated so we have been able to track down the problem.
    The problem seems to be something like this.
    You create a new entity bean and TopLink issues a sentence like this against the DB (Oracle 8.1.7 I must say we have also configured the login session to use the Oracle8PlatformSupport)
    INSERT INTO FOO(OID,OCA) VALUES (?, ?)
    bind => [1, 2004-04-26 13:16:45.251]
    As far as we know Oracle 8.1.7 doesn't store the milliseconds (we are using DATE type in Oracle tables) so the ".251" value is stored as "0"
    Then we try to delete the entity bean and TopLink sends this sentence to the database:
    DELETE FROM FOO WHERE ((OID = ? AND OCA = ?))
    bind => [1, 2004-04-26 13:16:45.251]
    Then, a TOPLINK-5003 (the object has been modified or deleted since last read) is raised and the transaction is rolled back.
    We tried without binding and it works perfect (it seems that the timestamp is treated as YYYY-MM-DD SSSSS in the "to_date" function issued)
    As we would like to keep with binding all parameters in order to optimize our database accesses we have changed the default jdbc driver (sun.jdbc...) that is showed when reading the proper property of the login sesion with the oracle.jdbc.driver.OracleDriver. This latest driver seems to solve the problem with the reminders of the timestamps but this brings us a doubt.
    If we have configured two datasources in our Weblogic's config.xml file (one for transactional operations, beeing that one also an XA driver as we need to coordinate RDBMS operations with a JMS service, and the other one being a "standar" oracle.jdbc.driver.OracleDriver) why is that the driver used as default by the login method is that "weird" sun.jdbc... driver? Shouldn't TopLink use one (the XA driver I hopefully) of the drivers defined in Weblogic's datasource?
    1. Is the issue we are seeing with the timestamp a known bug/problem?
    2. Is there a better way to solve it than changing the driver (we are affraid of the "new" issues changing it could raise)
    I have seen that with TopLink 3.6.3 and the "default" driver used in the login (it is the same by default on both TopLink 3.6.3 and TopLink 9.0.4) the binded timestamp are "truncated" to the second resolution and it works without any problem.
    Thanks in advance.
    Ignacio

    Not sure on all of the issues, but can provide some information on some of them.
    Re-directors:
    Support was added for re-director to core queries, so now your named queries can make use of re-director if they require advanced dynamic execution. So all re-director queries can become named queries.
    Timestamp locking:
    In general we would always suggest numeric version locking if you have the choice. I'm not clear on what you are saying about the driver having an effect on the problem, however in general Oracle 8 does not support milliseconds, if you use timestamp locking with local timestamps they will have milliseconds and the database values will not match the ones in memory.
    To resolve this you can,
    - Use server timestamps TimestampLockingPolicy.useServerTime()
    - Clear the timestamp's milli/nano second value through an aboutToInsert event.
    - Extend Oracle8Platform.convertObject to clear the timestamp's milli/nano second value.
    - If you can use Oracle 9 or 10 there is now a TIMESTAMP type that does support milliseconds.
    If a different driver seems to be solving this, it is most likely the database ignores the milliseconds in the comparison, but the driver you are using sends the millisecond to the database incorrectly when binding.

  • Help on Decode function in Toplink

    Hi,
    I have a sql statement like this:
    select field1, field2 from table1 where upper(field1) like 'ADELPHI%'
    order by field1,
    DECODE(TO_CHAR(NVL(LENGTH(TRANSLATE(field1,'A1234567890','A')),0)),'0',LPAD(field1 ,50),field1)
    How would I converted this to toplink query?
    I appreciate any help you guys can extend to me.

    I just spent about a half hour writing a response here, and the damned forum timed out on me. #$^!@$#!^!@$%.
    Here is the summary:
    - Using TL Expressions and EJBQL are to allow Java developers who don't necessarily know SQL to write queries and to facilitate portability/maintainability of the apps. For REALLY gnarly queries, using TL Expressions or EJBQL won't buy you this. I.e., SQL is more expressive and easier for this kind of quer, so it's not easier to use, and frankly with the code needed to support it, it won't be easier to maintain or port... Bottom line, maybe SQL is the best option here?
    - If you want to experiment, search for TO_CHAR on this forum, and the decode function in the javadoc. You need to build the expressions in pieces and you can treat expressions as arguments to other expressions -- in other words, you can build an expression like builder.leftPad(50, builder.get("field1")) and use it as one of the key/values in the hashtable to the decode function (in theory).
    - Don

  • Multiple Rows Update / Refresh Toplink Query when database trigger involved

    Hi everybody!
    I have two easy troubles for you; the platform is the same as the SRDemo Toplink version.
    1.     Multiple Rows Update: I want to update with mergeEntity method, multiple rows for an isolated table; that method receives a parameter that I try to bind with the iterator "dataProvider" but it only merges the first row, not all, any other combination returns an error.
    What I want to do is to have a form (like tabular forms in Apex) that lets me update multiple rows in a single page. ¿May anyone tell me how to do it?
    2.     Refresh Toplink Named Query: I have a list on a page with two columns. From another page, a button does an action that fires a database trigger that updates one of the columns on the list´s page. When I go back to the list, it is not updated; however, the CacheResults´s property is set to false on the iterator.
    Thanks in advance,
    Alejandro T

    I didn't use it (yet), but - you might take a look. You'll find a [url http://www.oracle.com/technetwork/developer-tools/apex/application-express/apex-plug-ins-182042.html]Timer plug-in on this page. It is a dynamic action which allows you to periodically fire other dynamic actions in the browser. For example use the timer to refresh a region every five minutes. You can perform any dynamic action you want using this infrastructure.So I was thinking: you might use it to run a dynamic action which would check whether something changed in that table (I suppose you'll know the way) (for example, a database trigger might set a flag in some table, timestamp or similar), and - if you find that something really changed - refresh the page.
    As I said, I never used it so that's pure theory. Someone else might know better, though.

  • Can't view the sheets when using subquery in discoverer desktop

    Hi All,
    I have created 5 subqueries sheets and I need the data from sheet1, sheet3, sheet5. But in the main sheet when I choose the subquery sheets, its showing only 3 sheets(i.e., sheet1, sheet2, sheet4). I don't want the data from sheet2 and sheet4 but I want from sheet1,3,5. I can't view the sheet3,5.
    Please advice.
    Thanks,
    Kamal

    I use Image Converter for iPad to convert my Sony RAW file.
    Not sure if it'll work for Canon.

  • TWO ERRO ORA-01427: single-row subquery returns more than one row

    Hi,
    I have a procedure which contains a cursor. If i run the select statement in the cursor separetly, it returns only value and works fine. But the same select statement in the cursor of a procedure throws me the error as below:
    TWO ERRO ORA-01427: single-row subquery returns more than one row
    Not sure what going on...any help appreciated.
    Below is the select statement:
    SELECT DISTINCT PSE.PARENT_POSITION_ID,
    (SELECT DISTINCT PPD1.SEGMENT2
    FROM PER_POSITION_DEFINITIONS PPD1,
    HR_ALL_POSITIONS_F HAPF2,
    PER_POS_STRUCTURE_ELEMENTS PSE2
    WHERE TRUNC(SYSDATE) BETWEEN
    HAPF2.EFFECTIVE_START_DATE AND
    HAPF2.EFFECTIVE_END_DATE
    AND PPD1.POSITION_DEFINITION_ID =
    HAPF2.POSITION_DEFINITION_ID
    AND
    HAPF2.POSITION_ID = PSE2.PARENT_POSITION_ID
    AND PSE2.PARENT_POSITION_ID =
    PSE.PARENT_POSITION_ID
    AND ROWNUM = 1) SEGMENT2,
    (SELECT DISTINCT PAPF1.FIRST_NAME || ' ' ||
    PAPF1.LAST_NAME CHIEF_NAME
    FROM PER_ALL_PEOPLE_F PAPF1,
    PER_ALL_ASSIGNMENTS_F PAAF1
    WHERE TRUNC(SYSDATE) BETWEEN
    PAPF1.EFFECTIVE_START_DATE AND
    PAPF1.EFFECTIVE_END_DATE
    AND TRUNC(SYSDATE) BETWEEN
    PAAF1.EFFECTIVE_START_DATE AND
    PAAF1.EFFECTIVE_END_DATE
    AND PAAF1.POSITION_ID = PSE.PARENT_POSITION_ID
    AND PAPF1.PERSON_ID = PAAF1.PERSON_ID
    AND ROWNUM = 1) CHIEF_NAME
    FROM PER_POS_STRUCTURE_ELEMENTS PSE,
    HR_ALL_POSITIONS_F HAPF,
    PER_POSITION_DEFINITIONS PPD
    WHERE PSE.SUBORDINATE_POSITION_ID = 52744
    AND TRUNC(SYSDATE) BETWEEN HAPF.EFFECTIVE_START_DATE AND
    HAPF.EFFECTIVE_END_DATE
    AND HAPF.POSITION_ID = PSE.SUBORDINATE_POSITION_ID
    AND HAPF.POSITION_DEFINITION_ID = PPD.POSITION_DEFINITION_ID;
    Thanks
    PK
    Edited by: user539616 on Jun 30, 2009 6:30 PM

    Hi,
    The cursor has a different parameter? Maybe the query is not exactly the same. Could you check this?
    This is your query (formatted):
    SELECT DISTINCT PSE.PARENT_POSITION_ID,
                    (SELECT DISTINCT PPD1.SEGMENT2
                       FROM PER_POSITION_DEFINITIONS   PPD1,
                            HR_ALL_POSITIONS_F         HAPF2,
                            PER_POS_STRUCTURE_ELEMENTS PSE2
                      WHERE TRUNC(SYSDATE) BETWEEN HAPF2.EFFECTIVE_START_DATE AND
                            HAPF2.EFFECTIVE_END_DATE
                        AND PPD1.POSITION_DEFINITION_ID = HAPF2.POSITION_DEFINITION_ID
                        AND HAPF2.POSITION_ID = PSE2.PARENT_POSITION_ID
                        AND PSE2.PARENT_POSITION_ID = PSE.PARENT_POSITION_ID
                        AND ROWNUM = 1) SEGMENT2,
                    (SELECT DISTINCT PAPF1.FIRST_NAME || ' ' || PAPF1.LAST_NAME CHIEF_NAME
                       FROM PER_ALL_PEOPLE_F      PAPF1,
                            PER_ALL_ASSIGNMENTS_F PAAF1
                      WHERE TRUNC(SYSDATE) BETWEEN PAPF1.EFFECTIVE_START_DATE AND
                            PAPF1.EFFECTIVE_END_DATE
                        AND TRUNC(SYSDATE) BETWEEN PAAF1.EFFECTIVE_START_DATE AND
                            PAAF1.EFFECTIVE_END_DATE
                        AND PAAF1.POSITION_ID = PSE.PARENT_POSITION_ID
                        AND PAPF1.PERSON_ID = PAAF1.PERSON_ID
                        AND ROWNUM = 1) CHIEF_NAME
      FROM PER_POS_STRUCTURE_ELEMENTS PSE,
           HR_ALL_POSITIONS_F         HAPF,
           PER_POSITION_DEFINITIONS   PPD
    WHERE PSE.SUBORDINATE_POSITION_ID = 52744
       AND TRUNC(SYSDATE) BETWEEN HAPF.EFFECTIVE_START_DATE AND HAPF.EFFECTIVE_END_DATE
       AND HAPF.POSITION_ID = PSE.SUBORDINATE_POSITION_ID
       AND HAPF.POSITION_DEFINITION_ID = PPD.POSITION_DEFINITION_ID;Tips: To put formatted code you must use {noformat}{noformat} tags, start tag and end tag are the same,you don't need to put '/' in the close tag.
    Regards,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for