SQL Statement / index on function ??

Hello
My environment is : Oracle 9.2.0.7
In "top sql sessions" I obtained that sql statement as below consumes many ressources.
When I use "SQL Analyzer" ... no recommandation was specified but I wonder if an index on function may be use to optimize this request.
I'd like to have your opinion on how to optimize this kind of request :
SELECT trim(CARD_NUMBER) as CARD_NUMBER,
trim(CUSTOMER.CLIENTS.CUSTOMER_ID) as CUSTOMER_ID,
trim(LASTNAME) as LASTNAME,
trim(FIRSTNAME) as FIRSTNAME,
trim(EMAIL) as EMAIL,
FROM CUSTOMER.CARTES, CUSTOMER.CLIENTS
WHERE CUSTOMER.CARTES.CUSTOMER_ID = CUSTOMER.CLIENTS.CUSTOMER_ID
AND trim(CUSTOMER.CARTES.CARD_NUMBER) = '1234567890'
AND (trim(CUSTOMER.CLIENTS.POST_CODE)='12345')
Plan execution is :
SQL STATEMENT :
JOIN
TABLE ACCESS (FULL) CUSTOMER.CARTES
TABLE ACCESS (FULL) CUSTOMER.CLIENTS
Many thanks for any help.
Regards,
Guillaume

AND trim(CUSTOMER.CARTES.CARD_NUMBER) =
'1234567890'
AND (trim(CUSTOMER.CLIENTS.POST_CODE)='12345')Yea function based index on trim(CUSTOMER.CARTES.CARD_NUMBER) and trim(CUSTOMER.CLIENTS.POST_CODE) might help.
BUT I suggest to correct data insertion app and insert already trimmed data in your table to avoid such ugly queries.
Gints Plivna
http://www.gplivna.eu

Similar Messages

  • How should I pass complicated sql statements to a function ?

    Hello
    Some built-in functions, such as dbms_advisor.quicktune accepts sql statements as in parameters. Those parameters are treated as varchar2, but if the sql statement is complicated and contain " ' " characters then its hard to pass those params, Sometimes they arent parsed correctly.
    How should I pass a complicated statement (with subqueries, strings and so) to a function ?
    Thanks
    Guy

    user11973359 wrote:
    Hello
    Some built-in functions, such as dbms_advisor.quicktune accepts sql statements as in parameters. Those parameters are treated as varchar2, but if the sql statement is complicated and contain " ' " characters then its hard to pass those params, Sometimes they arent parsed correctly.
    How should I pass a complicated statement (with subqueries, strings and so) to a function ?
    Thanks
    GuyWhats your db verzion. To over come the single quotes issue in string you can use q'[]' representation of string.
    select q'[Karthick's]' from dual

  • Help with simple sql statement usiing Rank function..

    Hello I have very important question..this is how i have a dataset...
    This is the Log Table 
    And the actual Table holds the current value.   12345
    Current Table 
    12345    575 232 4567
    Log Table Values
    Objectid InvalidatedTime
    PhoneArea
    Phoneno Rank
    12345   2014-04-23
    570          
    822-4438      0  
    3
    12345   2014-04-28
    NULL
    658-7789      0
    2
    12345   2014-05-09
    578        
    658-8521      0 
    1
    As you can see on 23 they invlalidated the areacode and phone no and changed it to .. 578 658-8521 but on 04-28 they just changed the phone no and not the area code.. 
    I want the result set to be like this
    Date Fromvalue   
    ToValue  
    2014-04-23 
    570-822-4438      
      578 658-7789
    2014-04-28 578 658-7789 
    578 658-8521
    2014-05-09  578 658-8521
    575 
    232 4567
     I have tried this code.. 
    select 
    --'Home Phone',
    --tt.invalidationtime ,
    --Case when 
    -- tt.*,tt_prev.* --,
    'Home Phone' as PropertyName,
    tt.invalidationtime,
    case when tt.rank1 = 1 then tt.phoneareacode+'-'+tt.phoneno
    when tt.rank1 <> 1 then Isnull(tt.phoneareacode,tt_prev.phoneareacode)+'-'+ isnull(tt.phoneno,tt_prev.phoneno)
    end as FromAddress,
    case when tt.rank1 = 1 then Haddress.phoneareacode+'-'+HAddress.phoneno
    when tt.rank1 <> 1 then Isnull(tt_prev.phoneareacode,tt.phoneareacode)+'-'+isnull(tt_prev.phoneno,tt.phoneno)
    end as ToPhone
    from
     #Phone_Final  tt
    left join  #Phone_Final tt_prev on tt_prev.objectid = tt.objectid and tt.rank1-11 = tt_prev.rank1
    inner join (select * from Soarian_Clin_Prd_1.dbo.Haddress   where PP_id = 2346   and Addresstype = 0) Haddress
    Can you please tell me what is wrong here.. 

    should be this I reckon
    ;With CTE
    AS
    SELECT ROW_NUMBER() OVER (PARTITION BY ObjectID ORDER BY InvalidatedTime) AS Seq, *
    FROM
    SELECT ObjectID,InvalidatedTime,PhoneArea,Phoneno,Rank
    FROM LogTable
    UNION ALL
    SELECT ObjectID, GETDATE(),PhoneArea,Phoneno,NULL
    FROM Current
    )t
    SELECT c1.InvalidatedDate AS [Date],
    COALESCE(c1.PhoneArea,c2.PhoneArea,'') + c1.Phoneno AS FromValue,
    COALESCE(c2.PhoneArea,c1.PhoneArea,'') + c2.Phoneno AS ToValue
    FROM CTE c1
    INNER JOIN CTE c2
    ON c2.Objectid = c1.Objectid
    AND c2.Seq = c1.Seq + 1
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • SQLEXEC not able to filter extract on sql statement or function call.

    hi all,
    i'm trying to do some basic extract filtering using a stored function and am not having much success.
    i started off using a procedure call but have been unsuccessful getting that working, i've simplified
    it to use a sql statement calling a function for a value to filter on, but cannot even get that to work.
    i've read through the documentation and i cannot figure out what is going wrong.
    any help would be much appreciated.
    thx,
    daniel
    function code is very simple, just trying to get something working.
    FUNCTION f_lookup_offer_id(v_offer_id IN offer.offer_id%TYPE)
    RETURN company.name%TYPE IS
    lv_company_name company.name%TYPE;
    BEGIN
    SELECT c.name
    INTO lv_company_name
    FROM orders a, offer b, company c
    WHERE a.offer_id = b.offer_id
    AND b.company_id = c.company_id
    AND a.order_id = v_order_id;
    RETURN lv_company_name;
    END f_lookup_offer_id ;
    Oracle GoldenGate Command Interpreter for Oracle
    Version 11.1.1.0.0 Build 078
    Solaris, sparc, 64bit (optimized), Oracle 10 on Jul 28 2010 13:26:39
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    EXTRACT EATUOP1
    INCLUDE ./dirprm/GGS_LOGIN.inc
    EXTTRAIL ./dirdat/up
    DISCARDFILE ./dirout/eatuop1.dsc, append , MEGABYTES 50
    DISCARDROLLOVER ON SUNDAY AT 06:00
    -- Database and DDL Options
    -- Added to avoid errors when setting unused columns
    DBOPTIONS ALLOWUNUSEDCOLUMN
    -- Get full row for deletes
    NOCOMPRESSDELETES
    -- Get updates before
    GETUPDATEBEFORES
    -- If commit SCN that is not greater than the highest SCN already processed error
    THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 15000 IOLATENCY 6000
    -- Retains original timestamp. Currently using GMT
    NOTCPSOURCETIMER
    --TABLE DEFS
    TABLE master.OFFER,
    SQLEXEC ( ID ck_offer,
    QUERY " select master.f_lookup_offer_id(:off_id) is_company from dual ",
    PARAMS (off_id = offer_id),
    BEFOREFILTER),
    FILTER (@GETVAL (ck_offer.is_company = "Google, Inc."));
    does not give any errors, but also does not capture any data, it's filtering everything out and trail files are empty, minus a header.
    thoughts or help?
    2012-04-04 22:17:36 INFO OGG-00993 Oracle GoldenGate Capture for Oracle, eatuop1.prm: EXTRACT EATUOP1 started.
    2012-04-04 22:17:36 INFO OGG-01055 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Recovery initialization completed for target file ./dirdat/up000022, at RBA 978.
    2012-04-04 22:17:36 INFO OGG-01478 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Output file ./dirdat/up is using format RELEASE 10.4/11.1.
    2012-04-04 22:17:36 INFO OGG-01026 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Rolling over remote file ./dirdat/up000022.
    2012-04-04 22:17:36 INFO OGG-01053 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Recovery completed for target file ./dirdat/up000023, at RBA 978.
    2012-04-04 22:17:36 INFO OGG-01057 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Recovery completed for all targets.
    2012-04-04 22:17:36 INFO OGG-01517 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Position of first record processed Sequence 13469, RBA 21894160, SCN 1789.722275534, Apr 4, 2012 10:12:40 PM.
    -rw-rw-rw- 1 svc_ggs 502 978 Apr 4 22:17 up000023

    got it working, this seems to be about as simple as i could formulate it. thanks for pointing me in the right direction.
    TABLE GGS_TEST_EXT, &
    SQLEXEC ( ID co_count, &
    QUERY " select f_lookup_company_name(:P1) x from dual ", &
    PARAMS ( P1 = company_id), BEFOREFILTER), &
    FILTER ( @GETVAL (co_count.x = 0) );
    then i have a function that returns 1 or 0, depending on the company id passed in.
    thx,
    daniel

  • Using cursor function in sql statement

    hi all
    can anyone plss explain why and when we will use cursor function in a sql statement like this and what is the difference while executing this sql statement with cursor function in comparison of a simple sql statement----
    select
    department_name,
    cursor (
    select last_name
    from employees e
    where e.department_id = d.department_id
    order by last_name
    ) the_employees
    from departments d
    thnx in advance

    RTFM
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref1452
    Cheers
    Sarma.

  • Expensive SQL statements & no proper indexing INCLUDE LPSSTU03-PSST FuncGrp

    Hi there forum
    During a recent upgrade we have implemented EhP4 with relevant Support Packs.
    Our Early Watch Report nows highlights INCLUDE LPSSTU03 in Function Module Group PSST as having expensive SQL statements along with improper indexing.
    Although I have seached through OSS and Forums I can find nothing of help.
    Is there an EXPERT out there who can help because SAP tells me that is the way it works!
    Thanks.
    Carl Cavendish-Davies

    Herewith the latest results from the Early Watch report on this issue:
    Object Type     Total Executions Disk Reads     Elapsed Time     Buffer Gets     Records Processed
    TABLE     242481         1873373     12035981     36237218     34390383
    SELECT
    "MANDT" , "OBJNR" , "STAT" , "CHGNR" , "USNAM" , "UDATE" , "UTIME" , "TCODE" , "CDTCODE" , "INACT" , "CHIND"
    FROM
    "JCDS"
    WHERE
    "MANDT" = :A0 AND "OBJNR" IN ( :A1 , :A2 , :A3 , :A4 , :A5 )&
    Execution Plan
    V$SQL_PLAN addr= C000000774FF4038 hash= 3408408745 sql_id 4w93fuv5khc59
    SELECT STATEMENT Estimated Costs= 6 Estimated Rows= 0 Optimizer: ALL_ROWS
    3 INLIST ITERATOR
    2 TABLE ACCESS BY INDEX ROWID JCDS
    Estimated Costs= 5 Estimated Rows= 28 Estim. Bytes: 1,848
    Estim. CPU-Costs = 41,426 Estim. IO-Costs = 5
    1 INDEX RANGE SCAN JCDS~0
    Estimated Costs= 1 Estimated Rows= 28 Access predicates:
    "MANDT"=:A0 AND (("OBJNR"=:A1 OR "OBJNR"=:A2 OR "OBJNR"=:A3 OR "OBJNR"=:A4
    OR "OBJNR"=:A5)) Search Columns: 2 Estim. CPU-Costs = 6,777 Estim. IO-Costs = 1
    Program Data:
    Origin of ABAP coding
    Program Name Line  Created By Last Changed By Last Changed On
    LPSSTU03      44     SAP          SAP               25.03.2003
    000044 SELECT * FROM JCDS
    000045 APPENDING CORRESPONDING FIELDS OF TABLE T_JCDS
    000046 FOR ALL ENTRIES IN R_OBJNR
    000047 WHERE OBJNR = R_OBJNR-OBJNR.

  • Expensive SQL statements & no proper indexing INCLUDE LBSVAU14-BSVA FuncGrp

    Expensive SQL statements & no proper indexing INCLUDE LBSVAU14 - Function Group BSVA (Status management)
    Hi there Forum
    During a recent upgrade we have implemented EhP4 with relevant Support Packs.
    Our Early Watch Report nows highlights INCLUDE LBSVAU14 as having expensive SQL statements along with improper indexing.
    Although I have seached through OSS and Forums I can find nothing of help.
    Is there an EXPERT out there who can help because SAP tell me that is the way it works!
    Thanks.
    Carl Cavendish-Davies

    Herewith the latest results from the Early Watch report on this:
    Object Type     Total Executions         Disk Reads   Elapsed Time   Buffer Gets    Records Processed
    TABLE     457663                 3282704       21081305        28310151       20031340
    SELECT
    FROM
    "JEST"
    WHERE
    "MANDT" = :A0 AND "OBJNR" IN ( :A1 , :A2 , :A3 , :A4 , :A5 )&
    Execution Plan
    V$SQL_PLAN addr= C000000774FF4038 hash= 3408408745 sql_id 4w93fuv5khc59
    SELECT STATEMENT Estimated Costs= 3 Estimated Rows= 0 Optimizer: ALL_ROWS
    3 INLIST ITERATOR
    2 TABLE ACCESS BY INDEX ROWID JEST
    Estimated Costs= 3 Estimated Rows= 10 Estim. Bytes: 330
    Estim. CPU-Costs = 20,886 Estim. IO-Costs = 3
    1 INDEX RANGE SCAN JEST~0
    Estimated Costs= 1 Estimated Rows= 10 Access predicates:
    "MANDT"=:A0 AND (("OBJNR"=:A1 OR "OBJNR"=:A2 OR "OBJNR"=:A3 OR "OBJNR"=:A4
    OR "OBJNR"=:A5)) Search Columns: 2 Estim. CPU-Costs = 6,137 Estim. IO-Costs = 1
    Program Data:
    Origin of ABAP coding
    Program Name       Line     Created By     Last Changed By    Last Changed On
    LBSVAU14            110     SAP     SAP              08.04.2007
    000110 SELECT * FROM JEST CLIENT SPECIFIED
    000111 APPENDING TABLE JEST_BUF
    000112 FOR ALL ENTRIES IN OBJNR_TAB
    000113 WHERE MANDT EQ CLIENT
    000114 AND OBJNR = OBJNR_TAB-OBJNR.

  • Expensive SQL statements & no proper indexing INCLUDE LBSVAF14-BSVA FuncGrp

    Expensive SQL statements & no proper indexing INCLUDE LBSVAF14 - Function Group BSVA (Status management)
    Hi there Forum
    During a recent upgrade we have implemented EhP4 with relevant Support Packs.
    Our Early Watch Report nows highlights INCLUDE LBSVAF14 as having expensive SQL statements along with improper indexing.
    Although I have seached through OSS and Forums I can find nothing of help.
    Is there an EXPERT out there who can help because SAP tell me that is the way it works!
    Thanks.
    Carl Cavendish-Davies

    Herewith the latest results from the Early Watch report on this:
    Cache Statistics
    Object Type     Total Executions     Disk Reads     Elapsed Time     Buffer Gets     Records Processed
    TABLE     1716707                            1854501     13325961     25580720     19606427
    SELECT
    FROM
    "JEST"
    WHERE
    "MANDT" = :A0 AND "OBJNR" = :A1&
    Execution Plan
    V$SQL_PLAN addr= C000000774FF4038 hash= 3408408745 sql_id 4w93fuv5khc59
    SELECT STATEMENT Estimated Costs= 2 Estimated Rows= 0 Optimizer: ALL_ROWS
    2 TABLE ACCESS BY INDEX ROWID JEST
    Estimated Costs= 1 Estimated Rows= 2 Estim. Bytes: 66
    Estim. CPU-Costs = 8,804 Estim. IO-Costs = 1
    1 INDEX RANGE SCAN JEST~0
    Estimated Costs= 1 Estimated Rows= 2
    Access predicates: "MANDT"=:A0 AND "OBJNR"=:A1 Search Columns: 2
    Estim. CPU-Costs = 5,817 Estim. IO-Costs = 1
    Program Data:
    Origin of ABAP coding
    Program Name       Line     Created By     Last Changed By   Last Changed On
    LBSVAF14           81     SAP     SAP             08.04.2007
    000080 * Einzelstatus von DB lesen in interne Tabelle
    000081 SELECT * FROM JEST CLIENT SPECIFIED
    000082 APPENDING TABLE JEST_TAB
    000083 WHERE MANDT = MANDT
    000084 AND OBJNR = OBJNR.

  • SQL Expression in decode function or case statement?

    Can I put SQL expressions in decode function or case statement?
    For example,
    select le.profile, decode( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile, 0, 'N', 'Y')
    from element le;
    or
    select le.profile, case WHEN ( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile) = 0 THEN 'N'
    ELSE 'Y'
    from element le;
    None of the above work.
    Can anyone tell me how to make it work?
    Is there any workaround?
    Thanks,
    J

    You simply needed and END to your CASE statement;
    SQL> with profile_data as (
       select 'XXXX_AFTER' name, 1 object_id from dual),
         element as (
       select 1 profile from dual union all
       select 2 from dual)
    select le.profile,
       case WHEN ( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile) = 0
       THEN 'N'
       ELSE 'Y'
       END new_col
    from element le
       PROFILE N
             1 Y
             2 N

  • Which is better - SQL Statement in APEX or as a function returning a type?

    Hi
    I have a general question about best practices for APEX development.
    If we have say a report region based on a SQL statement, is it better (from a performance perspective) to have the SQL statement defined in the region in APEX OR have the actual select statement executed in the backend and have the result set returned in a type to APEX?
    As an example:
    In APEX region
    SELECT col1, col2, col3 FROM table_aOR
    In APEX region
    select col1, col2, col3 from TABLE(CAST(<my package>.<my proceduere > AS <my type >)) ;<my package>.<my proceduere > would obviously execute the statement
    SELECT col1, col2, col3 FROM table_ausing dynamic SQL and return the results to APEX in thy type <my type>.
    Apologies if this sounds to be a really stupid thing to ask.
    Kind regards
    Paul

    Denes Kubicek wrote:
    You should use a pipelined function only then when you can't use SQL. Otherwise SQL is the way to go.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    ------------------------------------------------------------------------------thanks Denes... but does it matter if:
    1. The SQL statement is actually defined in the APEX region
    or
    2: The select statement is stored in a packageD function and returned to APEX?
    I seem to recall an article I read stating that it is best for all client applications to call stored procedures and functions rather than have SQL statement embedded in the actual application?
    Kind regards
    Paul

  • Invalid state in SQL query for a function that was created with no errors.

    SQL> CREATE OR REPLACE FUNCTION overlap(in_start1 IN TIMESTAMP, in_end1 IN TIMESTAMP, in_start2 IN TIMESTAMP, in_end2 IN TIMESTAMP) RETURN NUMBER
    2 IS
    3
    4 BEGIN
    5 IF (in_start1 BETWEEN in_start2 AND in_end2 OR in_end1 BETWEEN in_start2 AND in_end2 OR in_start2 BETWEEN in_start1 AND in_end1) THEN
    6 RETURN 0;
    7 ELSE
    8 RETURN 1;
    9 END IF;
    10 END;
    11 /
    Function created.
    SQL> show errors;
    No errors.
    SQL>
    SQL> SELECT * FROM tbl where overlaps(current_time,current_time+1,current_time-1,current_time+2) = 0;
    SELECT * FROM tbl where overlaps(current_time,current_time+1,current_time-1,current_time+2) = 0
    ERROR at line 1:
    ORA-06575: Package or function OVERLAPS is in an invalid state
    I do not understand why overlaps is returned as in invalid state in the query, when it was created with no errors earlier. Could anyone help me?

    Marius
    Looking at the logic you are trying to create it looks like you are looking for overlapping time periods.
    Consider two date/time ranges:
    Range 1 : T1 - T2
    Range 2 : T3 - T4
    Do they overlap?
    1) No: T1 < T4 (TRUE)  T2 > T3 (FALSE)
    T1 --- T2
               T3 --- T4
    2) Yes: T1 < T4 (TRUE)  T2 > T3 (TRUE)
    T1 ---------- T2
               T3 --- T4
    3) Yes: T1 < T4 (TRUE)  T2 > T3 (TRUE)
    T1 -------------------- T2
               T3 --- T4
    4) Yes: T1 < T4 (TRUE)  T2 > T3 (TRUE)
                   T1 ----- T2
               T3 --- T4
    5) Yes: T1 < T4 (TRUE)  T2 > T3 (TRUE)
               T1 --- T2
           T3 ------------ T4
    5) No: T1 < T4 (FALSE) T2 > T3 (TRUE)
                    T1 --- T2
           T3 --- T4Answer: Yes they overlap if:
    T1 < T4 AND T2 > T3
    So you can code the logic in your SQL as simply:
    SELECT *
    FROM tbl
    WHERE range1_start < range2_end
    AND    range_1_end > range2_startIf you go around implementing PL/SQL functions for simple logic that can be achieved in SQL alone then you cause context switching between the SQL and PL/SQL engines which degrades performance. Wherever possible stick to just SQL and only use PL/SQL if absolutely necessary.

  • Calling a PL/SQL function in the SQL statement

    I have a PL/SQL function which i should call in a SQL statement.
    Let's say the function is func1(parameter1,parameter2),
    it should be called like this :- SELECT func1() FROM mytable ;
    Can any one help me out on this ?
    ---Thanx in advance

    you can call pl/sql functions from pl/sql using
    select fn1('param1','param2') from table;
    if you dont want to pass paramters, you have to specify default
    value while creating function like below
    create function fn1(p1 number default null,p2 varchar2 default
    null) return...
    now you can call using
    select fn1 from table;

  • Using sql function in xml sql statement

    Hello,
    I have following statement:
    select field1, field2,....,field10 from table( cast (get_mhdata(:1,:2) as mhdata))
    where mhdata is an oracle type with 10 fields.
    It works good, but I don't know how can I use this statement in xml sql statement.
    Please, can you tell me if it is really possible.
    Thanks in regards.

    Hi
    You cant pass the parameters if you are executing writing this select function from the communication channel.
    You have 3 options:
    1) Use a stored procedure and execute from the communication channel
    2) Use a stored procedure and execute via message mapping in the IR - here you can pass parameters
    3) Same as above but call the query via SQL select - you can also pass parameters.
    sincerely,
    --NM

  • Problem in Calling a function in sql statement.

    hi,
    I am having a function ops_safex_utl.EDIT_ASSC_CNTR_LOG(id number);
    when i am trying to use this inside a sql statement as shown below, it is giving error (exception part inside the function).
    SQL> select ops_safex_utl.EDIT_ASSC_CNTR_LOG(688) from dual;
    OPS_SAFEX_UTL.EDIT_ASSC_CNTR_LOG(688)
    -1 (-- exception )
    when i am trying to call this function using a PL/SQL Block then it is woking fine as shown below.
    SQL> DECLARE
    2
    3 x NUMBER(2);
    4
    5 BEGIN
    6
    7 x := ops_safex_utl.EDIT_ASSC_CNTR_LOG(688);
    8
    9 dbms_output.put_line('x '||' '||x);
    10
    11 END;
    12 /
    hi
    insert into ops_assc_cntr_log
    insert into ops_ac_ex_gratia_log
    insert into ops_ac_sls_dlvry_slab_dtls_log
    insert into ops_ac_sls_dlvry_slab_dtls_log
    insert into ops_ac_sls_dlvry_slab_dtls_log
    insert into ops_ac_sls_dlvry_slab_dtls_log
    insert into ops_ac_sls_dlvry_slab_dtls_log
    insert into ops_ac_spl_acct_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    insert into ops_ac_spl_acct_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    update ops_assc_cntr
    success
    x 0
    PL/SQL procedure successfully completed.
    when i am trying to run the SQL statement it is returning a exception from the function.
    SELECT ops_safex_utl.EDIT_ASSC_CNTR_LOG(688) from dual --it is returning -1 (i.e exception).
    My sql client version is 9.2.0.1.0. and my data base version is 10.2.0.2.0.
    Please advice.

    Could you post the exception handler within the function.
    It sounds like you return -1 if you experience an error - it would be easier to determine the cause of the problem if you return the Oracle error details, E.g:
    EXCEPTION
       WHEN OTHERS THEN
          RETURN dbms_utility.format_error_backtrace;This will then return a meaningful error, identifying exactly what is causing the error to be generated.

  • Can we give multiple select statements in one function in PL/SQL

    Hi All,
    I am new to the PL/SQL. Can you please help me with the following problem.
    I am cretaing a function in which I have to extract some fields from three tables and to handle three tables I am first extracting the primary key from one table(acting as a foreign key for other table) in a variable declared in declare section, then I am selecting the required fields from the other table by giving that variable name in Where condition. My code is attached as well.
    e.g
    Create or Replace function <function name>(arguments)
    Return return type
    AS
    a1 a%TYPE;
    b_new b%TYPE;
    n fn%TYPE
    Select a into a1 from table1 where b like b_new;
    Select fn into n from table2 where id like a1;
    return a1,n; (can we pass record like this?)
    end;

    Left's first look at the approach you use.. 2 SQL statements that can be done using a single SQL statement.
    Actually it is not as bad as some other code posted here where people go and write complex PL/SQL code to do what could have been done using a single SQL statement.
    There are a couple of golden rules in Oracle development. One of these is to 'Maximise SQL and Minimise PL/SQL'.
    Why take a value from one SQL statement into PL/SQL and then use that value in a second SQL statement?
    Rather do this:
    select
    fn into n
    from table2
    where id like (Select a from table1 where b like b_new);Also keep in mind that in PL/SQL the above SQL construct is only able to fetch a single row - look at the bold above. The variable N can only hold a single value. If that SQL SELECT returns more than one value, how is variable N suppose to hold it?
    I suggest that you read [url http://www.oracle.com/pls/db102/to_toc?pathname=appdev.102%2Fb14261%2Ftoc.htm&remark=portal+%28Books%29]Oracle® Database PL/SQL User's Guide and Reference guide.

Maybe you are looking for

  • Problem with old packages

    I am trying to recreate the web-based data mining tool as outlined here (http://www.ibm.com/developerworks/library/wa-wbdm/) way back in 2001. I am generating quite a few errors compiling XMLHelper (35 in all), and I've done a bit of research to try

  • Add a new wiki page

    hi to all i want to share my new knowledge about to view a pdf inside firefox, so the right idea is to create a new archwiki page. unfortunately i have no time to create and correct its (i'm not english), so i post here , hoping that someone can crea

  • Want to create a InDesign document that is Interactive as a PDF

    I want to create an InDesign form that is made into a PDF that can be filled out (populated with their answers) and returned via email to someone. Can I make the document in InDesign or do I have to do it in Acrobat? I am running CS2. If you can poin

  • Print problem of TO form

    Hi All, I hit a problem for the printout of Transfer order form, for the TO printout settings, i have set the print code and form(LVSTAEINZEL) for the warehouse in OMLV, the settings were fine, but the TO printout was an abap list instead of Script f

  • Help with rendering a commandlink

    Hello, I am trying to render a command link in a custom renderer that I created. Basically, I am looping through an ArrayList and rendering each element's value in the ArrayList on screen in a custom way. I want the text to show as a link. However, I