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.

Similar Messages

  • How can I open a cursor for dynamic sql statement

    Hi,
    I'm facing issues opening a cursor for dynamic sql statement : PLS-00455: cursor 'RESULT1' cannot be used in dynamic SQL OPEN statement.
    CREATE OR REPLACE FUNCTION DEMO
    (MN_I in VARCHAR)
    return AB_OWNER.ABC_Type.NonCurTyp is
    RESULT1 AB_OWNER.ABC_Type.NonCurTyp;
    sql_stmt VARCHAR2(4000);
    BEGIN
    sql_stmt := 'SELECT * FROM AB_OWNER.DUN WHERE JZ_I in ('||mn_i||') ORDER BY app.ACC_I';
    OPEN RESULT1 FOR sql_stmt;
    END IF;
    return RESULT1;
    END DEMO;
    What changes should I make in the code so that it doesn't fail? I can't change the definition of RESULT1 cursor though.

    Gangadhar Reddy wrote:
    I used SYS REFCURSOR and was able to implement successfully.How many times did you run this successful implementation that does not use bind variables?
    Because this is what will happen when it runs a lot.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17766/e2100.htm#sthref1874
    http://forums.oracle.com/forums/search.jspa?q=%2BORA-04031%20%2Bbind&objID=c84&dateRange=all&rankBy=10001&start=30
    And you will have to regularly restart the server, or possibly slightly less invasive, flush the shared pool.
    Flushing Shared Pool regularly
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1516005546092
    >
    Ok, this is an easy one to diagnose.
    You are not using bind variables. This is terrible. Flushing the shared pool is a bad
    solution -- you are literally killing the performance on your box by not using them.
    If I was to write a book on how to build “non scalable applications in Oracle”, this
    would be the first and last chapter. This is a major cause of performance issues and a
    major inhibitor of scalability in Oracle. The way the Oracle shared pool (a very
    important shared memory data structure) operates is predicated on developers using bind
    variables. If you want to make Oracle run slowly, even grind to a total halt – just
    refuse to use them.
    >
    But, please feel free to go ahead with this successful implementation.
    I just hope anyone else who reads this doesn't make the same mistake.

  • 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.

  • Using Collection in a sql statement.

    Hi I want to perform the following statement:
    DELETE FROM ALLOCATION_ELEC_MATRIX
    WHERE dgo_ean_id in (lt_inter_dgos);
    The collection lt_inter_dgos holds my dgo_ean_id's(varchars).
    I can't find a way to get it to work.
    The collection is declared as follows:
    TYPE Interface_param_dgos IS TABLE OF VARCHAR2(20);
    lt_inter_dgos Interface_param_dgos := Interface_param_dgos();
    then later on the collection gets filled. But how can i get it to work to use it in my sql statement?
    I don't won't to use a for loop around it since it would give me problems if I use more collections with a different amount of values in it.

    The standard approach is to use SQL collection type and table function,
    for example
    SQL> create TYPE Interface_param_dgos IS TABLE OF VARCHAR2(20);
      2  /
    Type created.
    SQL> create or replace package my_pkg
      2  is
      3   lt_inter_dgos Interface_param_dgos := Interface_param_dgos();
      4   function get_coll return Interface_param_dgos;
      5  end;
      6  /
    Package created.
    SQL> create or replace package body my_pkg
      2  is
      3   function get_coll return Interface_param_dgos
      4   is
      5   begin
      6    return lt_inter_dgos;
      7   end;
      8  end;
      9  /
    Package body created.
    SQL> begin
      2   my_pkg.lt_inter_dgos.extend(3);
      3   my_pkg.lt_inter_dgos(1) := 'SMITH';
      4   my_pkg.lt_inter_dgos(2) := 'KING';
      5   my_pkg.lt_inter_dgos(3) := 'ALLEN';
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    SQL> select ename from emp;
    ENAME
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    14 rows selected.
    SQL> delete from emp where ename in (select column_value from table(my_pkg.get_coll));
    3 rows deleted.
    SQL> select ename from emp;
    ENAME
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    11 rows selected.Rgds.

  • Problem in using aggregate functions inside case statement

    Hi All,
    I am facing problem while using aggregate functions inside case statement.
    CASE WHEN PSTYPE='S' THEN MAX(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ELSE SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) END,
    how can I achieve above requirement ? Con anyone help me.
    Thanks and Regards
    DG

    Hi All,
    Below is my query:
            SELECT
            CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT
            ELSE POS.PACCT || '-' || DECODE(POS.SYSTEMCODE,'GMI1','1', 'GMI2','2', 'GMI3','4', 'GMI4','3', '0') ||POS.PFIRM|| NVL(POS.POFFIC,'000') END,
            CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-')
            ELSE POS.PFIRM||POS.POFFIC||POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-') END,POS.SYSTEMCODE,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,POS.PEXCH||DECODE(POS.PSUBEX,'<NULL>',''),
            POS.PCURSY,
            CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) END ,
            NVL(POS.PSUBTY,'F') ,POS.PSTRIK,*SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ,SUM(DECODE(POS.PBS,2,ABS(POS.PPRTQ),0))* ,
            POS.PCLOSE,SUM(POS.PMKVAL) ,
            TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
            POS.UBS_ID,POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER ,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,TO_CHAR(POS.BUSINESS_DATE,'YYYYMMDD'),
            POS.SOURCE_GMI_LIB,
            --DECODE(POS.SYSTEMCODE,'GMI1','euro','GMI2','namr','GMI3','aust','GMI4','asia','POWERBASE','aust','SINACOR','namr',POS.SYSTEMCODE),
            DECODE(p_reportid,'RVPOS_SING','euro','RVPOS_AUSTDOM','aust','RVPOS_AUSTEOD','euro','RVPOS_GLBLAPAC','asia','POS_RV_SN','namr','POS_PB','aust',POS.SYSTEMCODE),
            POS.RIC,
            CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
            DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
            CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
            CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
            NVL(C.SSECID,POS.PCUSIP),
            NULL,
            POS.PYSTMV,
            POS.PMINIT,
            POS.PEXPDT,
            CASE WHEN POS.PSUBTY='S' THEN  SUBSTR(C.ZDATA2,77,1) ELSE NULL END,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL
            FROM POSITIONS_WRK POS LEFT OUTER JOIN
            (SELECT * FROM CDS_PRODUCTS CP INNER JOIN FUTURE_MASTER FM ON
            (CP.STRXCH=FM.ZEXCH AND CP.SFC=FM.ZFC AND CP.BUSINESS_DATE = FM.BUSINESS_DATE )) C ON POS.PCUSIP = C.SCUSIP
            AND NVL(POS.PCUSP2,'X') = NVL(C.SCUSP2,'X')
            WHERE
            POS.PEXCH NOT IN ('A1','A2','A3','B1','B3','C2','D1','H1','K1','L1','M1','M3','P1','S1')
            AND (POS.PSBCUS IS NOT NULL OR POS.PCTYM IS NOT NULL OR POS.PSTYPE ='S')
            AND POS.BUSINESS_DATE = run_date_char
            GROUP BY
            POS.UBS_ID,POS.SYSTEMCODE,POS.RECIPIENTCODE,POS.BUSINESS_DATE,POS.PACCT,POS.PFIRM,POS.POFFIC,POS.PCUSIP,POS.PBS,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,
            POS.PEXCH,POS.PSUBEX,POS.PCURSY,
            CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2)  || SUBSTR(POS.PCTYM,1,4) END,
            NVL(POS.PSUBTY,'F') ,POS.PSTRIK,POS.PCLOSE,TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
            POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,POS.PSUBTY,POS.SOURCE_GMI_LIB,RIC,
            CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
            DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
            CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
            CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
            NVL(C.SSECID,POS.PCUSIP),
            POS.PYSTMV,
            POS.PMINIT,
            POS.PEXPDT,
            CASE WHEN PSUBTY = 'S'  THEN  SUBSTR(C.ZDATA2,77,1) ELSE NULL END;Now, could you plz help me in replacing the bold text in the query with the requirement.
    Thanks and Rgds
    DG
    Edited by: BluShadow on 16-May-2011 09:39
    added {noformat}{noformat} tags.  Please read: {message:id=9360002} for details on how to post code/data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Using java function in select statement

    Hi,
    I am trying to use java function in select statement.
    public class ClassA{
         private static String MyConst = "foo";
         public static String functionA(){
              return MyConst;
    in my query I have:
    select
         ClassA.functionA() AS id,
         groupId AS newID,
    from
         myChannel[now]
    ClassA is part of the application (no need to import).
    I get and error of Invalid Expression on ClassA.functionA().
    I also tried to declare the function in the processor element:
    <wlevs:processor id="proc">
         <wlevs:function function-name="A" exec-methode="functionA">
              <bean class="mtPackage.ClassA"/>
         </wlevs:function>
    <wlevs:processor>
    but then I get a different error in the processor XML file:  "An InvocationTargetException was encoutered while attemting to register the user defind function A. The message was null"
    What am I missing here?

    Hi,
    From the above description, you have tried two manners to call method functionA() in the user defined  class ClassA. One uses java cartridge manner directly and the other try to use user defined function manner.
    For the java cartridge manner, the following CQL query should work if the ClassA is really included in the OEP app. I have done similar test before, it works.
    select
         ClassA.functionA() AS id,
         groupId AS newID,
    from
         myChannel[now]
    For user defined function manner, I think two things you need to change:
    1. Need to declare the function in the EPN assembly file(under META-INF/spring/), not component configuration file(under META-INF/wlevs/). The following is an example:
    <wlevs:processor id="proc">
         <wlevs:function function-name="A" exec-methode="functionA">
              <bean class="mtPackage.ClassA"/>
         </wlevs:function>
    </wlevs:processor>
    2. Call the user defined function in the CQL query in the component configuration file under processor. For example:
    select A() from myChannel
    Regards,
    XiYing

  • Call C function in SQL statement

    dear all
    I want to know how i can call C function in SQL statement where clause

    http://asktom.oracle.com/pls/ask/f?p=4950:8:80100593788949622::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:934029542973

  • How to retreive out parameters from function in sql statement

    hi dear,
    Suppose i have a fuction with two "out" parameters, i want to show the values of these paramenters in sql stm.
    like
    select my_function() from dual;
    Thanx

    Can't be done. To use a function in SQL it can only have a single return value.
    Try something like this changing the data types appropriately.
    var x number
    var y number
    var z number
    exec :x := my_function(:y, :z)
    print

  • Problem using extract function (PL/SQL) with "&#34"

    Hi,
    When I use extract function (PL/SQL), it does not transform well "&#34". Insted of returning ' " ' , it returns ' &quot '.
    I know this works changing the code replacing xml.extract for SELECT extractvalue(xml,'//A/text()') into v from dual;
    But Is there another way to do this using PL/SQL? any patch, option..?
    Regards

    Had to use my website to demonstrate the code...
    As said, whatever I try here the code gets automatically converted...
    See for answer on your question: http://www.liberidu.com/blog/?p=635

  • Passing date to another form and use the date in sql statement

    hello! to all programmers
    i have some small problem that need some help.
    i want to use date value parameter from the first page in the second page sql statement but i get invalid cursor state error so if anyone can solve this problem or give me a better solution to do this process.
    thanks in advance
    p/s
    EBDATE is define as date data type in my database.
    this is part of my jsp code...
    <---------------------------------------------------------------------->
    SimpleDateFormat sdfInput = new SimpleDateFormat( "yyyy-MM-dd" );
    SimpleDateFormat sdfOutput = new SimpleDateFormat ( "dd/MM/yyyy" );
    String date= request.getParameter("date");
    Date date1 = sdfInput.parse(date);
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:wtmis_db","","");
    Statement stmt=con.createStatement();
    ResultSet set=stmt.executeQuery("select * from ELECTRICBIL where EBDATE="+sdfOutput.format(date1));
    if (set!=null)
    set.next();
         Date bildate =set.getDate ("EBDATE");
         Date sdate =set.getDate ("EBSTARTDATE");
         Date edate =set.getDate ("EBENDDATE");
         int kw =set.getInt ("EBKILOWATT");
         int maxdemand =set.getInt ("EBMAXIMUMDEMAND");
         int days =set.getInt ("EBDAYS");     
    <---------------------------------------------------------------------->

    Try this
    <%
    while(set.next())
    Date bildate =set.getDate ("EBDATE");
    Date sdate =set.getDate ("EBSTARTDATE");
    Date edate =set.getDate ("EBENDDATE");
    int kw =set.getInt ("EBKILOWATT");
    int maxdemand =set.getInt ("EBMAXIMUMDEMAND");
    int days =set.getInt ("EBDAYS");
    %>
    <tr>
    <td width="211"><div align="left"><b>Bill Date :</b></div></td>
    <td width="573"><%=sdfOutput.format(date1)%></td>
    </tr>
    <tr>
    <td width="211"><div align="left"><b>Bill From :</b></div></td>
    <td width="573"> <input type="text" name="textfield" value="<%=sdate%>"></td>
    </tr>
    <tr>
    <td width="211"><div align="left"><b>Bill To :</b></div></td>
    <td width="573"> <input type="text" name="textfield2" value="<%=edate%>"></td>
    </tr>
    <tr>
    <td width="211"><div align="left"><b><b>kiloWatt Use (Rm)</b>: </b></div></td>
    <td width="573"> <input type="text" name="textfield2" value="<%=kw%>"></td>
    </tr>
    <tr>
    <td width="211"><div align="left"><b>Max Demand kiloWatt (Rm):</b></div></td>
    <td width="573"> <input type="text" name="textfield2" value="<%=maxdemand%>"></td>
    </tr>
    <tr>
    <td width="211"><div align="left"><b>Days In Billing :</b></div></td>
    <td width="573"> <input type="text" name="textfield2" value="<%=days%>"></td>
    </tr>
    <%
    %>
    i hope. Now u wouldn't get any error message...but...u wouldn't get results as well...Check ur date format with access date format....
    Revert back

  • Can we use if/else in sql statement?

    Hi,
    Is it possible to write a sql statement like the one below (not plsql)?
    if (select 'True' from dual) = 'True' -- 1
    then
    select 'True' from dual;  -- 2
    else
      select 'False' from dual; -- 3
    endBasically, I want to execute either sql 2 or 3 based on the result of sql 1. I'm not sure if this is possible using only sql and not having to write a stored proc.
    What are the different ways I can implement this?
    Thanks for the help.

    Billy  Verreynne  wrote:
    The case syntax is a bit funny though as there's not a single condition evaluation (like a DECODE or case structs from some other languages).
    This is what I would expect a typical case struct to look like - evaluating a single condition:
    case <condition>
    when <value-1> then return <result-1>
    when <value-n> then return <result-n>
    else
    return <return-z>
    end
    ?:| You mean like this...?
    SQL> ed
    Wrote file afiedt.buf
      1  select empno, ename, deptno
      2        ,case deptno
      3           when 10 then 'This is Department 10'
      4           when 20 then 'And department 20'
      5           when 30 then 'And of course department 30'
      6         else
      7           'Blimey it is something else!'
      8         end as dept_desc
      9* from emp
    SQL> /
         EMPNO ENAME          DEPTNO DEPT_DESC
          7369 SMITH              20 And department 20
          7499 ALLEN              30 And of course department 30
          7521 WARD               30 And of course department 30
          7566 JONES              20 And department 20
          7654 MARTIN             30 And of course department 30
          7698 BLAKE              30 And of course department 30
          7782 CLARK              10 This is Department 10
          7788 SCOTT              20 And department 20
          7839 KING               10 This is Department 10
          7844 TURNER             30 And of course department 30
          7876 ADAMS              20 And department 20
          7900 JAMES              30 And of course department 30
          7902 FORD               20 And department 20
          7934 MILLER             10 This is Department 10
    14 rows selected.

  • Using Date objects in SQL statements

    Hi, I am wondering if it is possible to use Date objects while trying to retrieve entries from an access database with fields set as "Date/Time" fields, as opposed to "Text"? If so, do I need to reformat it before inserting it into the SQL statement, or can I just leave it as a Date object, and call up the variable name?
    For example - "SELECT * FROM database WHERE startDate = ' " + dateObject + ' ". And do i need quotes round this value?
    Thanks in advance.

    I had some problems by just fetching a date and pushing it back to a MS SQL Database.
    I used the following reformating step to fix it:
    if (o instanceof Timestamp)
    String time = o.toString().substring(8,10)+"."+o.toString().substring(5,7)+"."+o.toString().substring(0,4)+" "+o.toString().substring(11,19);
    ht.put(columnName, time);
    o is the object i receve from the select statement and ht is a Hashtable where i put my data.
    To write the data back i now can use:
    UPDATE table SET columnname = 'valueOfColumn'
    This means i use the value i created above in Quotes to write it back.
    Format of Timestamp.toString() is something like yyyy-mm-dd hh:mm:ss.xx
    Format used by MS SQL (and i think by Access to) 'dd.mm.yyyy hh:mm:ss'

  • Using User function in SQL*Loader

    Hi, I have created the following control file. I am using DIRECT path insert. I am using a function to retrieve the column system_date. However, when I am running sql*loader, the fields system_date and load_date are loaded with null value.
    OPTIONS (ERRORS=999999999, DIRECT=TRUE, ROWS=100000, SKIP=1)
    LOAD DATA
    INFILE 'Z:\xx.csv'
    APPEND
    PRESERVE BLANKS
    INTO TABLE TB_RAW_DATA
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    REFERENCE_NUMBER,     
    SYSTEM_DATE "pkg_ken_utility.Fn_ken_get_param_value('SYSTEM_DATE','SYSTEM_DATE')",
    LOAD_DATE "SYSDATE"
    )

    No,
    You can not call PL/SQL functions in DIRECT PATH mode, also this is documented, so you should not need to ask.
    Sybrand Bakker
    Senior Oracle DBA

  • Using 1 = 1 in SQL Statements

    I have just been told by our DBA that we have to go through
    our code and remove the "WHERE 1 = 1" in our SQL statements on a
    SQL 2000 database. He said it is a performance issue when nothing
    else follows it (no AND's).
    For example (the wrong way):
    SELECT this_ID FROM thistable WHERE 1 = 1
    Versus...
    SELECT this_ID FROM thistable WHERE 1 = 1 AND this_ID = 1001
    He said Microsoft said that this is causing a performance hit
    when there is no AND clauses after the WHERE.
    Some of these SQL statements are pretty big and there is no
    practical way to do a CFIF beforehand.
    Has anyone heard of a performance hit like this? If so, how
    much of a hit? The main table in the DB has about 2 million records
    with full text indexes.
    Thanks,
    Rob in Tampa

    Phil,
    Thanks for the speedy response. I forgot to mention.. there
    are TOP 200 clauses in all the big SQL statements.
    And, like I said before... some of the queries are too big to
    test to see if at least 1 of the condidtions exsist. More often
    than not, the WHERE 1 = 1 clause will not be alone. I personally
    think it is a pet peeve of the DBA where he doesn't see any use of
    the 1 = 1. He said.. it's always going to be true. Kinda the point
    of having it.
    This was taught to me years ago.. but, this is the biggest
    application I have worked on where SQL performance could be an
    issue. It was mentioned that the hit comes when SQL Server is
    building its execution plan and has to include the WHERE 1 = 1
    clause. How much of a hit can it cause? Most of the empty clauses
    with no AND's are most likely in a JOIN clause or something.
    The WHERE placeholder is in almost all of our queries in one
    way or another. Not a small project.
    Thanks,
    Rob

  • Using Variables in a SQL Statement

    I know, I know, this is written in VB..I'm doing a VB Project right now for my Instructor (While in an Intermediate Java Class)
    But VB (I feel) doesnt have very good support Forums.
    Anyway, this is the problem:
    I want to use String Variables to hold the place of field names in
    a SQL Statement and the change the ORDER according to intCount's Loop:
    The key word(s) here is "ORDER BY"
    Private Sub DataGrid1_Click()
    Dim intCount As Integer
    Dim strColHead(11) As String
    strColHead(0) = "RES__PUR_DT"
    strColHead(1) = "VENDOR"
    strColHead(2) = "VEN_LOC"
    strColHead(3) = "RES_TYPE"
    strColHead(4) = "RES_FROM_DT"
    strColHead(5) = "RES_TO_DT"
    strColHead(6) = "MISC_ADJ"
    strColHead(7) = "STATE_TAX"
    strColHead(8) = "LOC_CHARGE"
    strColHead(9) = "RES_ID"
    strColHead(10) = "RES_OP"
    For intCount = 0 To 10
    If DataGrid1.SelStartCol = intCount Then
    Adodc1.RecordSource = "Select * from tblReservation order by 'strColHead(intCount)'"
    End If
    Adodc1.Refresh
    Next intCount
    End Sub

    I'm just wondering if anyone knows a work around so that I might be able to store a Table's FIELD name in a variable or an array[] so that I can do a query based on the decision of a loop without having to code 10 IF/ELSE statements.For instance, although the above code will not work, this code, although quite lengthy, does:
    If DataGrid1.SelStartCol = 0 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES__PUR_DT"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 1 Then
    Adodc1.RecordSource = "Select * from tblReservation order by VENDOR"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 2 Then
    Adodc1.RecordSource = "Select * from tblReservation order by VEN_LOC"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 3 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES_TYPE"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 4 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES_FROM_DT"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 5 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES_TO_DT"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 6 Then
    Adodc1.RecordSource = "Select * from tblReservation order by MISC_ADJ"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 7 Then
    Adodc1.RecordSource = "Select * from tblReservation order by STATE_TAX"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 8 Then
    Adodc1.RecordSource = "Select * from tblReservation order by LOC_CHARGE"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 9 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES_ID"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 10 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES_OP"
    Adodc1.Refresh
    End If
    Do you see where i'm going with this?
    I simple want to use a variable in the "select * from <Table> Order by <Field>"

Maybe you are looking for

  • Dunning letters edition

    hi gurus, is it possible to edit manually in system before going to print the dunning letters? pl anyone advice ? my client wants to edit the dunning in the preview? points will be allotted if any one answers immediately. regds, raman

  • Using OS 9.2 on external drive

    Hallo, everyone, this is an SOS from Jack, a newcomer to the world of iMac and Tiger. Can anyone help me find a way of using 9.2 and Quark 4 for certain work I have to do? Could I use a bootable FireWire drive such as the LaCie Mini or Triple Extreme

  • Opening RAW files in CS5

    CS5 won't open RAW (NEF) files from camera on list (Nikon D3000).  My updates are current.  What next?

  • 11.3.1 tuning JVM and tomcat

    I will shortly be upgrading my 7 primary servers to 32gig of ram each. Currently they have 8 gig and with the new diag screen (just upgraded to 11.3a) we easily can see this is woefully inadequate. Currently the schools are shutdown and easily 95% of

  • Doc Splitting in ECC 6.0

    Hi All, I would like to post an entry for Balance Upload. The entry would be like  (eg) Prepaid Expense Dr. Bank Account     Dr. To GL Balance Upload Cr. The above two line items have different Profit Center. I am using the Doc Type SA with unspecifi