Problems with WHERE CLAUSE in selects executed by BAPIs

Dear Experts,
I'm trying to make a SAP Java Connector. My problem is that, when they are called by Java, BAPI functions don't run in the same manner as in SAP testing mode .
I tested two BAPI functions called through my connector and I saw with the debbuger that BAPI functions don't execute the select and loop at with a WHERE clause when they are called by Java, therefore they throw errors. But in the SAP testing mode functions work just fine.
I'm  new to SAP and I don't know why this happens. Would you like to explain to me how to fix this problem?
Thank you very much.
Kind regards,
Maricica

979380 wrote:
Yeah,i m sorry.I m a forum newbie.All right,we ve been given an oracle account for the purpose of this project,an we have connect to the oracle database either via linux terminal with sqlplus,or via oracle client and plsql.So i have to create some tables,then fill these tables with tuples(we ve been given fixed .sql files to do that),and we re suggested to do that from the linux terminal.I did that successfully.Then we have to run some queries either in terminal or plsql.I chose plsql.I connect,i can see the tables that i have created but when i run(in both sql and terminal window) for example the query "select * from table_1",i take 0 rows as a result.I tested to run the query from terminal(with sqlplus) to see if the tables are really empty,but i recieve the results as i should.
I am sorry for my chaotic writing but i cant even explain the problem to myself better and i m not a native.
(im using oracle version 11.2.0.1, this is the first time i m using oracle databases and i m a rookie in databases in general)
Edited by: 979380 on 1 Ιαν 2013 10:33 πμ
[oracle@localhost ~]$ sqlplus user1/user1
SQL*Plus: Release 11.2.0.2.0 Production on Tue Jan 1 11:19:29 2013
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table table_1 (id number);
Table created.
SQL> select * from table_1;
no rows selected
SQL> insert into table_1 values(1);
1 row created.
SQL> select * from table_1;
        ID
         1
SQL> in order to SELECT any rows from any table, first you must INSERT data into the table!
is COPY & PASTE broken for you?

Similar Messages

  • Urgent: Performance problem with where clause using IN and an OR condition

    Select statement is:
    select fl.feed_line_id
    from ap_expense_feed_lines_all fl
    where ((:1 is not null and
    fl.feed_line_id in (select distinct r2.object_id
    from xxdl_pcard_wf_routing_lists r2,
         per_people_f hr2
    where upper(hr2.full_name) like upper(:1||'%')
              and hr2.person_id = r2.person_id
    and r2.fyi_list is null
              and r2.sequence_number <> 0))
    or
    (:1 is null))
    If I modify the statement to remove the "or (:1 is null))" part at the bottom of the where clause, it returns in .16 seconds. If I modify the statement to only contain the "(:1 is null))" part of the where clause, it returns in .02 seconds. With the whole statement above, it returns in 477 seconds. Anyone have any suggestions?
    Explain plan for the whole statement is:
    (1) SELECT STATEMENT CHOOSE
    Est. Rows: 10,960 Cost: 212
    FILTER
    (2) TABLE ACCESS FULL AP.AP_EXPENSE_FEED_LINES_ALL [Analyzed]
    (2) Blocks: 8,610 Est. Rows: 10,960 of 209,260 Cost: 212
    Tablespace: APD
    (6) TABLE ACCESS BY INDEX ROWID HR.PER_ALL_PEOPLE_F [Analyzed]
    (6) Blocks: 4,580 Est. Rows: 1 of 85,500 Cost: 2
    Tablespace: HRD
    (5) NESTED LOOPS
    Est. Rows: 1 Cost: 4
    (3) TABLE ACCESS FULL XXDL.XXDL_PCARD_WF_ROUTING_LISTS [Analyzed]
    (3) Blocks: 19 Est. Rows: 1 of 1,303 Cost: 2
    Tablespace: XXDLD
    (4) UNIQUE INDEX RANGE SCAN HR.PER_PEOPLE_F_PK [Analyzed]
    Est. Rows: 1 Cost: 1
    Thanks in advance,
    Peter

    Thanks for the reply, but I have already checked what you are suggesting and I am pretty sure those are not causing the problem. The hr2.full_name column has an upper index and the (4) line of the explain plan shows that index being used. In addition, that part of the query executes on its own quickly.
    Because the sql is not displayed in an indented format on this page it is a little hard to understand the structure so I am going to restate what is happening.
    My sql is:
    select a_column
    from a_table
    where ((:1 is not null) and a_column in (sub-select statement)
    or
    (:1 is null))
    The :1 bind variable is set to a varchar2 entered on the screen of an application.
    If I execute either part of the sql without the OR condition, performance is good.
    If the :1 bind variable is null with the whole sql statement (so all rows or a_table are returned), performance is still good.
    If the :1 bind variable is a not-null value with the whole sql statement, performance stinks.
    As an example:
    where (('wa' is not null) and a_column in (sub-select statement)) -- fast
    where (('wa' is null)) -- fast
    where (('' is not null) and a_column in (sub-select statement) -- fast
    or
    ('' is null))
    where (('wa' is not null) and a_column in (sub-select statement) -- slow
    or
    ('wa' is null))

  • Populate list by executing query with where clause

    Hi,
    I m populating my list from database table using following command.
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("learning", new HashMap());
    EntityManager em = emf.createEntityManager();
    String query = "select d from Dept d";
    List list = em.createQuery(query).getResultList();
    My list is getting populated with all of rows in my database table(dept). The problem is, I cant use where clause in my query string.
    String query = "select d from Dept d where d.dept_name='ANYNAME'";
    Moreover I cant select even indivisual columns by using following line
    String query = "select d.dept_code,d.dept_name from Dept d";
    It looks like that my query is getting all rows from table as Object.
    What to do to
    1. put some where clause
    2. get some particular colums instead of all columns
    3. apply some table joins in query
    plz help.

    Hi Alex,
    I misunderstood your question. You had mentioned "My list is getting populated with all of rows in my database table(dept). The problem is, I cant use where clause in my query string. "
    I thought you might not have permissions to modify the code in the class, and that's why I suggested that you could write new classes.
    1) write new classes,? means if I need just two columns from a table >(instead of all columns), do I need to write new class with just two >columns (getters and setters)?You can write a SQL statement anyway you want , there are no restrictions in JDBC , so if you need just 2 columns you can write a custom query for that.
    "select column1 as a, column2 as be from table_name where column3 = xyz" etc.
    2) Is not anyway to write SQL statement like
    select dept_code,dept_name from dept where dept_name='anything'The above SQL is correct, it should work.
    3) Stored procedures? can I get some example(code) to get an idea >how to implement complex queries with where clause and joinings >using stored procedures?Stored procedures are specific to the database you are using, Oracle has a particular syntax for store procdures.
    You can call stored procedures from JDBC also, search on Google for
    "Calling stored procedures from JDBC"
    4) I m using hibernate. can I get any example of using hibernate own >query?Tutorial on Hibernate Query Language:
    http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html

  • Problem with IN clause substitution in Sybase

    I am experiencing a problem with IN clause substitution in
    embedded SQL with a Sybase databse.
    My Cold Fusion server is MX 7.
    The Database is Adaptive Server Enterprise/12.5.0.3/EBF 10689
    IR/P/Sun_svr4/OS 5.8/rel12503/1915/64-bit/FBO/Thu Jan 23 16:05:19
    2003
    Here's the problem. I have a Cold Fusion variable
    bureau_incode which I am using to define the values in my IN
    clause. When I comment out my query and display this value to the
    HTML page, bureau_incode has the following value:
    ('OET','OGC','OIG','OLA','OMD','OMR','OSP','OTHER','OWD','PSHSB','WCB','WTB')
    My embedded SQL CFQUERY looks like this:
    quote:
    <cfquery name="qResults" datasource="#request.dsn#">
    Select Name,
    bureau_code,
    Telephone,
    CellPhone,
    Pager,
    Email,
    Availability,
    Explanation,
    Password,
    Admin,
    last_login = convert(varchar(20),last_login,0)
    from PAMS where Availability = 'N'
    <cfif #request.seltype# IS NOT "ALL">
    and bureau_code IN #bureau_incode#
    </cfif>
    </cfquery>
    When the code runs, I get the error
    Error Executing Database Query. Incorrect syntax near 'OET'.
    There is no incorrect syntax. Is there any special way to
    submit the IN clause to ColdFusion MX 7? Previously, we were using
    ColdFusion 4.5 (I believe) server, and the code worked perfectly,
    albiet with double-quotes in the replacement string. Any help would
    be appreciated. This type of substitution worked nicely in the
    previous server version, I can't imagine why it would no longer
    work.

    No, I am not. The parentheses are part of the #bureau_incode#
    coldfusion variable. I've edited the first message to make this
    more clear. I have tried the query with the parentheses in the
    #bureau_incode# variable, and with the parentheses in the CFquery
    with (#bureau_incode#). The results are always the same.
    I will indeed try to help with other stuff in the future. :)
    Thanks for trying to help!

  • Export (expdp) with where clause

    Hello Gurus,
    I am trying to export with where clause. I am getting below error.
    Here is my export command.
    expdp "'/ as sysdba'" tables = USER1.TABLE1 directory=DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= “USER1.TABLE1:where auditdate>'01-JAN-10'” Here is error
    [keeth]DB1 /oracle/data_15/db1> DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= USER1.TABLE1:where auditdate>'01-JAN-10'                    <
    Export: Release 11.2.0.3.0 - Production on Tue Mar 26 03:03:26 2013
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Starting "SYS"."SYS_EXPORT_TABLE_03":  "/******** AS SYSDBA" tables=USER1.TABLE1 directory=DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= USER1.TABLE1:where auditdate
    Estimate in progress using BLOCKS method...
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 386 MB
    Processing object type TABLE_EXPORT/TABLE/TABLE
    Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
    Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
    Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
    Processing object type TABLE_EXPORT/TABLE/TRIGGER
    Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
    ORA-31693: Table data object "USER1"."TABLE1" failed to load/unload and is being skipped due to error:
    ORA-00933: SQL command not properly ended
    Master table "SYS"."SYS_EXPORT_TABLE_03" successfully loaded/unloaded
    Dump file set for SYS.SYS_EXPORT_TABLE_03 is:
      /oracle/data_15/db1/TABLE1.dmp
    Job "SYS"."SYS_EXPORT_TABLE_03" completed with 1 error(s) at 03:03:58Version
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production

    Hello,
    You should use parameter file.Another question i can see you are using 11g.Why don't you use data pump?.
    Data Pump is faster and have more features and enhancement than regular imp and exp.
    You can do the following:
    sqlplus / as sysdba
    Create directory DPUMP_DIR3  for 'Type here your os path that you want to export to';then touch a file:
    touch par.txt
    In this file type the following the following :
    tables=schema.table_name
    dumpfile=yourdump.dmp
    DIRECTORY=DPUMP_DIR3
    logfile=Your_logfile.log
    QUERY =abs.texp:"where hiredate>'01-JAN-13' "then do the following
    expdp username/password parfile='par.txt'
    If you will import from Oracle 11g to version 10g then you have to addthe parameter "version=10" to the parameter file above
    BR
    Mohamed ELAzab
    http://mohamedelazab.blogspot.com/

  • Outer Join with Where Clause in LTS

    HI all,
    I have a requirement like this in ANSI SQL:
    select p1.product_id, p1.product_name, p2.product_group
    from product p1 left outer join product_group p2 on p1.product_id = p2.product_id
    and p2.product_group = 'NEW'
    In Regular SQL:
    select p1.product_id, p1.product_name, p2.product_group
    from product p1, product_group p2
    WHERE p1.product_id *= p2.product_id and p2.product_group = 'NEW'
    In OBIEE, I am using a left outer join between these two in Logical table Source, and also, Gave
    p2.product_group = 'NEW' in WHERE clause of LTS.
    This doesn't seem to solve purpose.
    Do you have any idea how to convert WHERE clause in physical query that OBIEE is generating to something like
    product p1 left outer join product_group p2 on p1.product_id = p2.product_id AND p2.product_group = 'NEW'
    I am using Version 10.1.3.4.1
    Creating an Opaque view would be my last option though.

    Hello
    I have read your post and the responses as well. and I understand that you have issues with the Outer Join with where Clause in LTS.
    Try this solution which worked for me (using your example ) -
    1. In the Physical Layer created a Complex join between PRODUCT and PRODUCT_GROUP tables and use this join relationship :
    PRODUCT.PROD_ID = PRODUCT_GROUP.PROD_ID  AND  PRODUCT_GROUP.GROUP_NAME = 'MECHANICAL' 
    2. In the General Tab of PRODUCT table LTS add PRODUCT_GROUP  table and select Join Type as Left Outer Join.
    3. Check Consistency and make sure there are no errors .
    when you run a request you should see the following query generated -
    select distinct T26908.PROD_ID as c1,
         T26908.PROD_NAME as c2,
         T26912.GROUP_NAME as c3
    from
         PRODUCT T26908 left outer join PRODUCT_GROUP T26912 On T26908.PROD_ID = T26912.PROD_ID and T26912.GROUP_NAME = 'MECHANICAL'
    order by c1, c2, c3
    Hope this works for you. If it does please mark this response as 'Correct' .
    Good Luck.

  • Merge with where clause after matched and unmatched

    Hai,
    Can anybody give me one example of merge statement with
    where clause after matched condition and after the unmatched condition.
    MERGE INTO V1 VV1
    USING (SELECT     A.CNO XXCNO, A.SUNITS XXSU, A.DDATE XXDD, XX.SUM_UNITS SUMMED
    FROM V1 A,
    (SELECT                
    SUM(SUNITS) SUM_UNITS FROM V1 B                                   
    GROUP BY CNO) c
    WHERE
    A.DDATE=0 AND A.SUNITS <>0 AND
    A.ROWID=(SELECT MAX(ROWID) FROM V1 )) XX
    ON (1=1)
    WHEN MATCHED THEN UPDATE SET
    VV1.SUNITS=XX.SUMMED
    WHERE XX.XXDD=0
    WHEN NOT MATCHED THEN INSERT
    (VV1.CNO, VV1.SUNITS, VV1.SUNITS)
    VALUES (XX.XXCNO, XX.XXSU, XX.XXDD)
    WHERE XX.XXDD<>0
    i am getting the error
    WHERE XX.XXDD=0
    ERROR at line 13:
    ORA-00905: missing keyword
    Thanks,
    Pal

    One of the example is there:
    http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_9016.htm#sthref7014
    What Oracle version do you use ?
    Besides the condition (1=1) is non-deterministic,
    I would expect there an exception like "unable to get a stable set of rows".
    Rgds.

  • Insert with Where Clause

    Hi,
    Can we write Insert with 'Where' clause? I'm looking for something similar to the below one (which is giving me an error)
    insert into PS_AUDIT_OUT (AUDIT_ID, EMPLID, RECNAME, FIELDNAME, MATCHVAL, ERRORMSG)
    Values ('1','10000139','NAMES','FIRST_NAME',';','')
    Where AUDIT_ID IN
    (  select AUDIT_ID from PS_AUDIT_FLD where AUDIT_ID ='1' and RECNAME ='NAMES'
    AND FIELDNAME = 'FIRST_NAME' AND MATCHVAL = ';' );
    Thanks
    Durai

    It is not clear what are you trying to do, but it looks like:
    insert
      into PS_AUDIT_OUT(
                        AUDIT_ID,
                        EMPLID,
                        RECNAME,
                        FIELDNAME,
                        MATCHVAL,
                        ERRORMSG
    select  '1',
            '10000139',
            'NAMES',
            'FIRST_NAME',
      from  PS_AUDIT_FLD
      where AUDIT_ID = '1'
        and RECNAME ='NAMES'
        and FIELDNAME = 'FIRST_NAME'
        and MATCHVAL = ';'
    SY.

  • Hierarchical query with where clause

    Hi,
    How can I query hierarchically a query with WHERE clause? I have a table with three fields session_id,id and root_id.
    When I try with the following query,
    select id, level from relation
    where session_id = 79977
    connect by prior id = root_id start with id = 5042;
    It gets duplicate values.
    I want the query to show in the hierarchical manner with a filter condition using WHERE clause. Please help me how can I achieve this. If you know any link that describes more about this, please send it.
    Thanks in Advance.
    Regards,
    -Parmy

    Hi Sridhar Murthy an others,
    Thanks a lot for your/the answer. It's working for me. It saved a lot of other work around without the proper knowledge of hierarchical query. Please send me any link that describes these issues in detail and also I hope as I have mentioned in the other message, same cannot be achieved on views or ( on two different tables ???)
    Any way thanks for your reply,
    It's working for me.
    With happiness,
    -Parmy

  • WHERE clause in SELECT statement

    hi experts..
    i want to give 'OR' condition in the 'where' clause of 'SELECT' statement.
    is it possible?
    for examlpe..
    IF EXIDV2 IS NOT INITIAL.
       SELECT * FROM YSDT_SHIPLOAD
                INTO TABLE IG_SHIPLOAD
                WHERE EXIDV2 = EXIDV2 AND
                             VHILM = PC1 OR PC2 OR PC3.
    ENDIF.
    i want that VHILM should be one of those three.
    how can i do this?
    thanks..

    Hi ,
    its possible,
    Select * from ysdt_shipload int table ig_shipload where exidv2 = exidv2
                                                                            AND vhilm = pc1
                                                                            OR     vhilm = pc2
                                                                             OR   vhilm = pc3.
    OR
    Select * from ysdt_shipload int table ig_shipload where exidv2 = exidv2
                        AND (vhilm = pc1 or vhilm = pc2 or vhilm = pc3).
    Regards
    Arani Bhaskar
    Edited by: arani bhaskar on Mar 16, 2009 5:14 PM

  • Regarding  dynamically assigning the where clause to select query

    hi,
      Please send the code regarding how to dynamically assign the where clause to select query.
    thanks in advance

    SELECT <fileds>
            INTO TABLE itab
            FROM dbase
            WHERE  condition.

  • How to create VO with multiple dynamic where clauses on select with UNION?

    I am trying to implement the View Object for the UNION query that looks like this:
         select a,b,c...
              from t1,t2,...
              where dynamic_where_clause1     
         union all
         select a,b,c,...
              from t11,t12, ...
              where dynamic_where_clause2
    There are up to 60 input parameters that are used to generate dynamic where clauses. They are actually created by calling PL SQL function.
    So far, I was not able to assign both where clauses to the view object. Is there a workable solution for this problem, besides resorting to programmatic View Object?
    I understand that recommended way with UNIONs is to wrap both queries into a parent select:
    select * from (
         select a,b,c...
              from t1,t2,...
              where ... -- table relationship joints
         union all
         select a,b,c,...
              from t11,t12, ...
              where ... -- table relationship joints
    ) QRSLT
         where dynamic_where_clause
    Unfortunately this approach doesn't work here, since individual selects are producing unmanageable amount of data and resulting query takes forever to complete.

    I afraid I would not have any real benefits from using VO if I replace the entire query with every request. Actually, the performance may suffer.
    I solved the problem by creating a POJO Data Control and invoking the custom select query from java. Not sure if it is the best approach to the problem, but implementation time is limited and it works.
    Actually, this is not the first time I see the need to implement VO with complicated SQL like select with unions and dynamic pieces. It would be nice to find a solution and not resort to workarounds.
    Edited by: viksicom on Aug 2, 2012 8:48 AM

  • Select sdo_nn with where-clause on large table

    Hi spatial-experts,
    I've following problem. I use a table with more than 2.500.000 dataset. Every dataset represents one point (SDO_GEOMETRY, SDO_POINT_TYPE) and have further (text) information. (PI (point of interest) table from TeleAtlas mn_pi)
    Following Select works fine:
    SELECT /*+ ORDERED NO_INDEX(pi IX_PI_FEATTYP) */
    sdo_nn_distance(1) distance,
    id, feattyp, arnamelc, name, stname, stnamelc, hsnum, postcode
    FROM multinet.mn_pi pi
    WHERE
    pi.feattyp IN ( 9373,9374)
    AND
    SDO_NN(
    pi.geom,
    SDO_GEOMETRY( 2001, 8307, SDO_POINT_TYPE(613.86865234375/60, 3002.94677734375/60, NULL), NULL, NULL),
    'sdo_batch_size=0', 1) = 'TRUE'
    AND rownum = 1
    ORDER BY distance
    (P.S. IX_PI_FEATTYP is an index on column feattyp, here not used. When I'm using it the select do not work (it last very long...))
    When I now modify the where clause to an pi which feat type that does not exists (no entry in table) the select lasts very long (I canceled the select after 5 minutes).
    for example: pi.feattyp = 9756
    Otherwise I add a further where clause like
    AND arnamelc = 'ITA'
    the select also works very long. The point are now in italy. refrence point is in germany and is more than 500km away.
    Are there some solutions to solve this problems
    (should I use for every feat type a own table)?
    Why is the select so slow?
    Thanks for all helpfully answers,
    Matthias

    Hi Matthias,
    When you use nearest neighbor, Oracle will use the spatial index to find the nearest neighbor that meets the query criteria. It probes into the index, calculates distances, and returns data in distance order.
    Using SDO_BATCH_SIZE, it keeps going back to the database, returning more and more records in distance order until the other predicates are satisfied (in your case, pi.feattyp IN ( 9373,9374).
    When you specified pi.feattyp = 9756 (which doesn't exist), you told Oracle to keep going and calculating distances for each of the more than 2.500.000 records in the the data set (you killed it after 5 minutes).
    I don't know why adding: AND arnamelc = 'ITA' caused Oracle to take extra time. Sometimes I will do a: set autotrace trace exp
    then compare plans for something that runs quickly vs. something that runs slowly. If you want to post the plans for the fast and slow versions it might be interesting to look at.
    My guess is you may want to look at a solution that incorporates various possibilities. For instance, if there are only a few of some feattyp values, you may want to select those using the non-spatial index then use sdo_geom.sdo_distance to find the closest point rather than risk having to look through a few million values for a match.
    I'm sure other people have thoughts as well...
    Kind regards,
    Dan

  • Issue in select query with where clause

    Hi guys,
    I'm facing an issue while using select query with the where clause. When I'm selecting all the data from the table it returns the correct result. But when I'm using the where clause to get the specific rows from the table it returns no rows. But the data I'm trying to fetch using the where condition exists in the table.
    Here is my query which causing the issue,
    select * from mytable where myfield = 'myvalue'
    But if I use the following query it returns the result correctly.
    select * from mytable
    Also the myfield value 'myvalue' exists in the table.
    I have tried by running this query in both SQL Developer and SQL Plus. I have tried this query in mssql as well. It works perfectly and returns correct result sets for both the queries I have mentioned above. I'm unable to predict the issue as I'm new to ORACLE. Please help.
    Thanks,
    Ram.

    Hi Ram,
    I experienced an issue similar to this with a varchar2 field. Some of our records had a hidden newline character at the end of them, which was making queries like the one below fail:
    select * from employees
    where email = '[email protected]'The best way I found to detect this was to use
    select 'XX'||email||'XX' from employeesTo make sure that there were no newlines. But that is just a guess. If you could provide some example table data and the outputs of your selects, it would be helpful.
    Jeff

  • PL/SQL Evaluation problem of where clause in case of  NUMBER column type

    I found the following problem in Oracle® Database 2 Day Developer's Guide 11g Release 1 (11.1) B28843-04:
    The sole parameter of function eval_frequency is employee_id IN employees.employee_id%TYPE.
    An ORA-01422 exception occurs when the execution reaches the following select command
    SELECT e.hire_date
    INTO hire_date
    FROM employees e
    WHERE employee_id= e.employee_id;
    A possible cause of the error is that the type of employee_id is NUMBER while the employees.employee_id is NUMBER(6,0) . The result of the selection is the same as there were no WHERE clause at all.
    Everything worked fine, when I declared a temporary variable of NUMBER(6,0) for storing the actual parameter of function and used this variable in the where clause, but I consider this "solution" as being no solution.
    It is pointless to use %TYPE parameter of a function for flexibility if I must degrade this flexibility by a fixed declaration of a temporary variable of the same type as the column in question.
    What is wrong?
    The Developer'Guide I used, the Oracle Sql Developer I used or the PL/SQL version ?

    Hi,
    Welcome to the forum!
    user8949829 wrote:
    A possible cause of the error is that the type of employee_id is NUMBER while the employees.employee_id is NUMBER(6,0) . The result of the selection is the same as there I don't think so. The variable employee_id is defined as having the exact same type as the eponymous column. Even if it didn't, I believe Oracle will always implicity convert between datatypes when possible, rounding if necessary. That may cause errors, but it isn't causing this error.
    No, the error has nothing to do with the data type. It has to do with the ambiguity of employee_id: is it a column, or is it a variable?
    The default is that it means the column name, so
    WHERE   employee_id = e.employee_idis equivalent to saying
    WHERE   e.employee_id = e.employee_idwhich isn't quite the same thing as not having a WHERE clause; rows with NULL employee_id would still be excluded, if there were any.
    I think it's best not to use variable names that are the same as column names. You could call the variable v_employee_id, or, since it's an IN-argument, in_employee_id.
    If you must use a variable that can be mistaken for a column, then qulaify it with the name of the procedure, like this:
    WHERE   eval_frequency.employee_id = e.employee_id
    Everything worked fine, when I declared a temporary variable of NUMBER(6,0) for storing the actual parameter of function That makes sens. You probably gave that variable a name that couldn't be mistaken for a column in the table.
    Edited by: Frank Kulash on Jan 12, 2011 8:27 PM

Maybe you are looking for

  • IMac will not wake from sleep after 10.4.8 Update

    Recently after a couple of software updates my IMac goes to sleep and the Bluetooth keyboard and mouse will not wake it. The option for wake with Bluetooth is checked. I zapped the PRAM and also checked the HD, Nothing has changed. NOTE: No new softw

  • Creating Worksheets with Fill-In Form Fields

    What is the best application for creating worksheets with fill-in form fields?  The worksheets will be emailed to my clients for completion.  Once completed they need to be able to save them to their computer and/or email them back to me.  What appli

  • Cannot setup e1000 due to MS service pack 3 problem

    I am directed by the software to download service pack 3 but I am unable to download.  Update is loaded about half way and gives me a message " unable to complete download.  I have tried three times without success and therefore cannot use new wirele

  • Item Category D and Account Assignment F error message in RFQ

    Hi gurus, Am experiencing a strange error message creating an RFQ from a Purchase requisition generated by a maintenance order : "Combination item category D/account assignment category not defined". The combination Service D/ Order F is actually def

  • Restoring N200 to factory settings while preserving partitions?

    Recently my Vista has given me the 0xc0000001 error on bootup and I haven't done a backup. In Rescue and Recovery 4, I have the option to restore the C: drive to it's default, so I copied my important data to an external drive and planned to do this.