How to use hints in PL/SQL

Hi,
If I want to use hints in PL/SQL procedure, it is valid to write it this way:
begin
update /*+  INDEX(opp DIM_OPP_REFDB_IDX) */
        scott.rec_dim_opportunity opp
        set opp.mp_opportunity_re ....
endI doubt when I tried it that the optimizer didn't actually use the index.
Thanks in advance.
Oracle 10g R1
Windows 2003 32-bit

the table is of 90MB and when the UPDATE statement is used in SQL, the explain plan output shows that the index is used.
When I execute it from a procedure, the Current Statement show in TOAD doesn't show that the index is used and the update takes forever. Explain plan of the statement (as show in TOAD) shows that full table scan is being used.

Similar Messages

  • How to use OEM to moniter sql server 2000

    Hi,
    I need to learn How to use OEM to moniter sql server 2000.
    Can anyone help me and give me some website or documents
    to read?
    So I can learn to do this job.
    Thanks.

    See Note 115302.1 in Metalink.oracle.com
    in how to use OEM Diagnostic pack addon for SQL Server
    Or search for
    oem "user events"
    to build your own monitor script.

  • How to use hint on with clause query

    Hi all,
    I have a query and it consits full of tabs with WITH clause. Top level I am just selecting all the tabs (queries with WITH clause) by saying select * from tab1,tab2,.....so on .
    Now my question is If I want to use hint on my SQL can I use the same by using tab1,tab2...
    tab1, tab2 are not actually tables ....each tab represents one SQL with WITH clause.
    Please let me know if there is any confusion on my post.

    What's stopping you from trying it yourself?
    Post your results here to help others.

  • How to use Java with PL/SQL commands to send an email with attachment

    Apologizes in advance if this is the wrong place to ask the question.
    I need to use Java with PL/SQL commands to send an email with attachment. My java application runs from the command line and does some magic to gather info from an Oracle 11g db. If the DB has sendmail configured, I'd like to send the results of the data gathering as an attachment to the email addresses. I'm not sure how to do this. I've been reading up on on PL/SQL can send email with UTL_SMTP - with attachments. I'm just not sure how to translate that into being triggered by my Java application. Any suggestions or pointers on what I should read would be appreciated.
    Background - I've been programming in Java for 10+ years, but this is my first time using databases. I also have been on these forums for a long time, but lost my profile when it was switched to Oracle.
    Thanks for all help.

    user13726880 wrote:
    The original requirements were put together and given to me, an Oracle newbie. They expected the Java app to use something intrinsic to Oracle and Unix sendmail. To solve my problem, I use a JDBC connection to run some SQL commands. I take that data, format it and send the results by email to the user. By default the requirement is to send it as an HTML attachment using Unix 'sendmail'. So I do that using Runtime exec. I have also added JavaMail functionality as an alternative to sendmail. It works great and as expected.Sounds like a reasonable solution.
    Note however that PL/SQL itself can send email. And PL/SQL can call unix sendmail too.
    However myself I would have done it in java with JavaMail.

  • How to use Image field in SQL-7 for curvs

    I sampling data from a NI-card. There will be a lot of data so I thought I should use Image-field in SQL-7 to save the hole curve. How do you do that?

    I would suggest looking into the Database Connectivity Toolset. It has complete SQL functionality and uses ADO to connect to many types of databases. I have it and it comes with example programs which demonstrate how to write to and read from databases using SQL.
    J.R. Allen

  • How to use INSERT in EXEC SQL ...... ENDEXEC ?

    Hi,
    The following code;
    DATA: BEGIN OF str_insert,
            a(3) TYPE c,
            b(3) TYPE c,
          END OF str_insert.
    EXEC SQL.
      SET CONNECTION DEFAULT
    ENDEXEC.
    str_insert-a = 'a'.
    str_insert-b = 'b'.
    EXEC SQL.
    INSERT INTO ZSAP  VALUES :str_insert
    ENDEXEC.
    The Structure of the ZSAP table (There is no data in ZSAP);
    A CHAR 3 (Primary Key)
    B CHAR 3
    I cannot instert a record to this table it throughs the following error;
    Runtime Errors         DBIF_DSQL2_SQL_ERROR  
    Exceptn                CX_SY_NATIVE_SQL_ERROR
    How could use a structure to insert values into ZSAP?
    Thanks,
    Kishan

    Hello..
      loop at T_PC.
        loop at T_PCD .
          at new NUMREFERENCIA.
            exec sql.
             INSERT INTO tblPolizaContableR3
                (LibroMayor, PeriodoContable, Prefijo, NumReferencia,
                Fecha, FuenteDiario, ComentarioPoliza, Moneda,
                TipoCambio, RefExternaID1, RefExternaID2, RefExterna1,
                RefExterna2, DescRefExterna)
             VALUES (:T_PC-LIBROMAYOR, :T_PC-PERIODOCONTABLE,
              :T_PC-PREFIJO, :T_PC-NUMREFERENCIA, :T_PC-FECHA,
              :T_PC-FUENTEDIARIO, :T_PC-COMENTARIOPLIZA, :T_PC-MONEDA,
              :T_PC-TIPOCAMBIO, :T_PC-REFEXTARNAID1, :T_PC-REFEXTERNAID2,
              :T_PC-REFEXTERNA1, :T_PC-REFEXTERNA2, :T_PC-DESCREFEXTERNA)
            endexec.
          endat.
            exec sql.
             INSERT INTO tblPolizaContableDetR3
                (LibroMayor, PeriodoContable, Prefijo, NumReferencia,
                Partida, Cuenta, CuentaIMSA, CCostoIMSA,
                Cargo, Abono, ComentarioPartida)
             VALUES (:T_PCD-LIBROMAYOR, :T_PCD-PERIODOCONTABLE,
              :T_PCD-PREFIJO, :T_PCD-NUMREFERENCIA, :T_PCD-PARTIDA,
              :T_PCD-CUENTA, :T_PCD-CUENTAIMSA, :T_PCD-CCOSTOIMSA,
              :T_PCD-CARGO, :T_PCD-ABONO, :T_PCD-COMENPARTIDA)
            endexec.   
        endloop.
    Hope this help you.
    Regards, Gustavo Estrada

  • How to use parameters in oracle SQL script????

    Right now I am writing a SQL script to create a schema and build the objects of this schema....
    I use a .net winform program to run sqlplus to parse this sql script ...
    The problem is that the schema name and the tablespace's location and the sys password must be input by the user, so my SQL script should use these runtime input parameters instead of const parameters....
    So, how to use parameter in SQL script ...........
    Are there some example scripts in oracle home directory for me to refer to????

    Hi,
    UNISTD wrote:
    thanks .....
    what's the difference between variable , define, accept in sqlplus ???VARIABLE declares (but does not assign a value to) a bind variable. Unlike substitution variables, bind variables are passed to the back end to be compiled, and they can only be values in certain data types. You can not use a bind vaiable in place of an identifier, so to do something like
    CREATE USER  &1 ...a bind variable won't work.
    "DEFINE x = y" sets the substitution variable &x to have the value y. There is no user interaction (unless x or y happen to contain undefined substtiution variables).
    "DEFINE x" shiows the value of the substitution variable &x, or, if it is undefined, raises a SQL*Plus error. I use this feature below.
    ACCEPT sets a substitution variable with user interaction.
    And if the user miss some parameters in “sqlplus /nolog ssss.sql par1 par2 par5 par6”, how to use default value of the miss parameters??Don't you need a @ befiore the script name, e.g.
    sqlplus /nolog @ssss.sql par1 par2 par5 par6Sorry, I don't know of any good way to use default values.
    The foloowing works, but, as you can see, it's ugly.
    "DEFINE 1" display a message like
    DEFINE 1            = "par1" (CHAR)if &1 is defined; otherwise,it will display a SQL*Plus error message like
    SP2-035: symbol 1 is UNDEFINEDNotice that the former contains an '=' sign, but the latter does not.
    The best way I know to use default values is to run the DEFINE command, save the output to a filee, read the file, and see if it's an error message or not.
    So you can use a script like this:
    --     This is  DEFINE_DEFAULT.SQL
    SPOOL     got_define_txt.sql
    DEFINE     &dd_old
    SPOOL     OFF
    COLUMN     dd_new_col     NEW_VALUE     &dd_new
    WITH     got_define_txt     AS
         SELECT  q'[
              @got_define_txt
    ]'               AS define_txt
         FROM    dual
    SELECT     CASE
             WHEN  define_txt LIKE '%=%'
             THEN  REGEXP_REPLACE ( define_txt
                               , '.+"
    ([^"]*)
                         , '\1'
             ELSE  '&dd_default'
         END        AS dd_new_col
    FROM     got_define_txt
    {code}
    and start your real script, ssss.sql, something like this:
    {code}
    DEFINE          dd_new     = sv1
    DEFINE          dd_old     = 1
    DEFINE          dd_default     = FOO
    @DEFINE_DEFAULT
    DEFINE          dd_new     = sv2
    DEFINE          dd_old     = 2
    DEFINE          dd_default     = "Testing spaces in value"
    @DEFINE_DEFAULT
    {code}
    when this finishes running, the substitution variable &sv1 will either have the value you passed in &1 or, if you didn't pass anything, the default value you specified, that is FOO.
    Likewise, &sw2 will have the value you passed, or, if you didn't pass anything, the 23-character string 'Testing spaces in value'.
    Here's how it works:
    Define_default.sql puts the output of the "DEFINE x" command into a column, define_txt, in a query.  That query displays either the existing value of the substitution variable indicated by &dd_old or, if it is undefined, the default value you want to use, which is stored in the substitution variable &dd_default.  The substitution variable named in &dd_new is always set to something, but that something may be its existing value.
    Notice that the paramerters to define_default.sql must be passed as global varibales.
    Why didn't I just use arguments, so that we could simply say:
    {code}
    @DEFINE_DEFAULT  sv1  1  FOO
    {code}
    ?  Because that would set the substitution variables &1, &2 and &3, which are miost likely the very ones in which you're interested.
    I repeat: there must be a better way, but I'm sorry, I don't know what it is.
    I usually don't do the method above.  Instead, I always pass the required number of parameters, but I pass dummy or plce-holder values.
    For example, if I wanted to call ssss.sql, but use defulat vlaues for &1 and &3, then I would say something like:
    {code}
    @ssss  ?  par2  ?
    {code}
    and, inside ssss.sql, test to see if the values are the place holder '?', and, if so, replace them with some real default value.  The use has  to remember what the special place holder-value is, but does not need to know anything more, and only ssss.sql itself needs to change if the default values change.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to use hints in Obiee to increase performance

    Anybody please tell me how can we use hints to increase performance of ad hoc and dashboard reports in obiee

    Hi,
    Check this,
    http://www.howtoexam.com/index.php?option=com_content&view=article&id=75%3Ausing-hints-in-obiee-rpd-and-answers&catid=790%3Acomputers-and-software&Itemid=166
    Rgds,
    Dpka

  • How to use substitution variable in sql

    Hai All
    I have two tables Rgpmain and Rgpitem the fields are
    Rgpmain
    unitid,periodid, docno, vendcode ,vendname, part_taken_by and .....
    Rgpitem
    unitid, periodid, docno, partno, partname .... And i need to give some values in runtime using sub variable
    i need to to four values in sub function and i will give one value and i need the result of one variable
    The qurey will like this
    Select * from rgpmain m, rgpitem i where unitid=1 and periodid=14 and m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and vendcode ='&p_vendcode'
    Or
    m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and vendname like '&p_vendname%'
    Or
    m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and partname like '&p_partname%'
    or
    m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and partno ='&p_partno'
    This is my query
    And while i am executing there are four options showing to enter..
    My need is i need enter only one field Ie vendcode and execute the vendcode like ABC01 then i need the only
    the result that belong to vendcode ABC01 but my query giving all the rows
    Pls tell me what is wrong with my query
    Thanks In Advance
    Srikkanth.M

    Hai
    Thanks Man i under stood that nv2 if 1 col is null then it will return 2 col or els 1 col but i working with large
    database and i need four or five column using sub. Pls tell whats went wrong with my query when i am executing
    one by one at the first time its works fine but next time it returns 1000 rows. pls tell me how to use four or five columns
    Regards
    srikkanth.M

  • [DW 8.02 + PHP] how to use variables in advanced SQL queries

    Hi all,
    I can't find a way to use variables in an SQL query after
    updating
    dreamweaver 8.02.
    I always get error messages that says: 'missing variable
    type:myvariablename', undefined#myvariablename... and so on.
    What is the correct way to use variables?
    I usually set a variable in a PHP statement (example: <?
    $today=date('Y-m-d'); ?>)
    and then I compare this variable in the SQL query.
    What is the correct syntax for variable in DW 8.02 in
    advanced SQL
    queries?
    TIA
    tony

    sweetman wrote:
    > I'm editing a website created with DW 8.01 and MX
    Kollection.
    >
    > I updated DW to 8.02 and now I can't edit an existing
    SQL query.
    > I always get an error message 'Missing variable type'
    and I can't go
    > on.
    InterAKT released a new version of Kollection to cope with
    the 8.0.2
    changes. AFAIK, you should be able to download the updated
    version from
    your InterAKT account area.
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • How to use sets in PL/SQL

    Hi all,
    I want to know how to implement algebraic sets in PL/SQl.
    I mean for example if there is a table R(A,B) where A is aprimary key having the data :-
    {(1,2),(2,1),(2,3),(3,1)}
    i want to have a data type that represents sets of data corresponding to attribute B.
    i.e the data type should have the value {1,2,3}
    Thanks.

    Not sure that I understand correctly.. and how you want to fit PL/SQL into this.
    Sets are best handles as Oracle tables. The best language to deal with sets are SQL. So to get the results you want should be a simple:
    SELECT DISTINCT b FROM table_r ORDER BY 1
    The results of this can be a cursor that needs to be stepped (fetch) through.
    The results can be bulk collected into a dynamic array, e.g.
    create or replace type TArray is table of number;
    And then in PL/SQL:declare
      array TArray;
    begin
      SELECT DISTINCT b BULK COLLECT INTO array FROM table_r ORDER BY 1;
    end;The array object will now contain TArray(1,2,3).

  • How To Use Reporting Services On SQL Server 2000 ?

    Hi all .
    Today , I has a issue .
    Normal , if the customer use SQl Server 2005 , it is no proplem , so if use SQL Server 2000 ,  Now , I want to use Reporting services on SQL Server 2000 , but , I am searching  on Internet , so I know , if I want to use SQL 2000 reporting server , I must have license of SQL server 2000 .
    is Every body  idea for this issue  ? .
    Please help me .
    Thanks alot .

    Ok ,anyway thanks alot ,.

  • How to use nvl() function in SQL Loader

    I am trying to use nvl() funtion in my SQL Loader control file and I keep geting errors. Would someone please tell me where I can find the syntax reference to this?
    Thanks a lot!

    I just answered a similar question like this last Thursday.
    SQL*LOADER how to load blanks when data is null

  • How to use Conditional statements in SQL Loader control file

    Hi,
    I am using sql loader to load a flat file to the table. I am using control file for this purpose as show below:
    LOAD
    INTO TABLE store_shrink
    TRUNCATE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    SITE_ID char,
    ST_SHRINK char,
    ST_REVENUE char,
    SHRINK_PR char ":ST_SHRINK/:ST_REVENUE"
    My question is this. If in the flat file the value of 'ST_REVENUE' is '0', then I want 'SHRINK_PR' to be '0' as well, and skip the calculation (:st_shrink/:st_revenue).
    How to achieve this with the conditional statement or using any Oracle function?
    Any help or suggestion is greatly appreciated.
    Thanks in advance.

    Hi there,
    I tried the following in my above query and it doesn't work somehow. Anyone has an idea? I have been on internet throughout but to no avail. Please help:
    LOAD
    INTO TABLE store_shrink
    TRUNCATE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    SITE_ID char,
    ST_SHRINK char,
    ST_REVENUE char,
    SHRINK_PR char "case (when :st_revenue<>'0.00' then :SHRINK_PR=:ST_SHRINK/:ST_REVENUE else :SHRINK_PR='0.00') end"
    )

  • How to use 'IN' expression for SQL in DB adapter

    Hi,
    I am working on BPEL PM 10.1.3.3 and need to configure db adapter to get multiple values for one parameter similar to " where deptid in ('1,2,3)".
    While configuring the adapter I am not able to find any such option. Also I need to use custom SQL. I have already tried SQL given below
    select deptname from dept where dept in (#deptID)
    This type of SQL generates an error. I am sure there should be a way to achieve this but donot know how to :(
    -AAg

    This is not possible. You should program on advance the amount of IN paramaters
    IN (#p1, #p2, #p3, #p4)
    or
    IN (#p1, NVL(#p2, #p1), NVL(#p3, #p1), NVL(#p4, #p1))

Maybe you are looking for