PL/SQL with PHP4

How to run stored procedure through PHP4 OCIExecute?
When I use:
$conn = OCILogon( $usr, $pas, $db );
$data = OCIParse( $conn,"EXECUTE schema.stored_proc" );
OCIExecute( $data );
OCIFetch ( $data );
the effect is:
Warning: OCIStmtExecute: ORA-00900: .....
How can I fix it?

Hi
see http://www.php.net/manual/en/ref.oci8.php
for an excellent reference. By the way you've made a good choice with PHP,
I've had very good experience with PHP Apache Oracle RDMS,
Oracle should include it in future IAS distributions.
Good luck!!

Similar Messages

  • If..then..else statement in SQL with 'generalized' conditions in the if sta

    it is possible to write something approaching an if..then..else statement in SQL with 'generalized' conditions in the if statement.
    Attached is the query for the payment register, in which I've written a series of decode statements, one for each possible value of the payment code. The query works OK - however, its specific and as the number of paycodes expand (and they do), the report won't pick up the new paycode until the code is changed. More importantly, the report won't be correct until someone 'discovers' that a paycode is missing, which might take months.
    If I were writing the equivalent of this series of decode statements in Focus, it would be something like this:
    DEFINE.......
    PAYMED/D12.2 = IF PAYMENT_CD LE 18
                   THEN PAYMENT_AMT
                   ELSE 0 ;
    PAYIND/D12.2 = IF PAYMENT_CD GE 19 AND PAYMENT_CD LE 49
                   THEN PAYMENT_AMT
                   ELSE 0 ;
    PAYEXP/D12.2 = IF PAYMENT_CD GE 70
                   THEN PAYMENT_AMT
                   ELSE 0 ;
    PAYREC/D12.2 = IF PAYMENT_CD GE 50 AND PAYMENT_CD LE 69
                   THEN PAYMENT_AMT
                   ELSE 0;
    END
    IN SQL/PLUS:
    SELECT ACCOUNT_NAME,
    LOCATION_1,
    CLMNT_LAST_NAME,
    CLAIM_NBR,
    DATE_OF_INJURY,
    DATE_CHECK_REGISTER,
    PAYEE_NAME_1,
    PAYMENT_CD,
    SERV_OFC,
    CPO_CHECK_NBR,
    PAYMENT_FORM,
    DECODE(PAYMENT_CD, 20, PAYMENT_AMT, 21, PAYMENT_AMT,
    22, PAYMENT_AMT, 23, PAYMENT_AMT, 25, PAYMENT_AMT,
    26, PAYMENT_AMT, 27, PAYMENT_AMT, 28, PAYMENT_AMT,
    29, PAYMENT_AMT, 30, PAYMENT_AMT, 31, PAYMENT_AMT,
    32, PAYMENT_AMT, 33, PAYMENT_AMT, 34, PAYMENT_AMT,
    35, PAYMENT_AMT, 36, PAYMENT_AMT, 37, PAYMENT_AMT,
    39, PAYMENT_AMT, 40, PAYMENT_AMT, 41, PAYMENT_AMT,
    42, PAYMENT_AMT, 43, PAYMENT_AMT, 44, PAYMENT_AMT,
    45, PAYMENT_AMT, 46, PAYMENT_AMT, 47, PAYMENT_AMT,
    48, PAYMENT_AMT, 49, PAYMENT_AMT, NULL) INDEMNITY,
    DECODE(PAYMENT_CD, 0, PAYMENT_AMT, 1, PAYMENT_AMT,
    2, PAYMENT_AMT, 3, PAYMENT_AMT, 4, PAYMENT_AMT,
    5, PAYMENT_AMT, 6, PAYMENT_AMT, 7, PAYMENT_AMT,
    8, PAYMENT_AMT, 9, PAYMENT_AMT, 10, PAYMENT_AMT,
    11, PAYMENT_AMT, 12, PAYMENT_AMT, 13, PAYMENT_AMT,
    14, PAYMENT_AMT, 15, PAYMENT_AMT, 18, PAYMENT_AMT,
    17, PAYMENT_AMT, NULL) MEDICAL,
    DECODE(PAYMENT_CD, 70, PAYMENT_AMT, 71, PAYMENT_AMT,
    72, PAYMENT_AMT, 73, PAYMENT_AMT, 74, PAYMENT_AMT,
    75, PAYMENT_AMT, 76, PAYMENT_AMT, 77, PAYMENT_AMT,
    78, PAYMENT_AMT, 79, PAYMENT_AMT, 80, PAYMENT_AMT,
    81, PAYMENT_AMT, 82, PAYMENT_AMT, 83, PAYMENT_AMT,
    84, PAYMENT_AMT, 85, PAYMENT_AMT, 86, PAYMENT_AMT,
    87, PAYMENT_AMT, 88, PAYMENT_AMT, 89, PAYMENT_AMT,
    90, PAYMENT_AMT, NULL) EXPENSES,
    DECODE(PAYMENT_CD, 50, PAYMENT_AMT, 51, PAYMENT_AMT,
    52, PAYMENT_AMT, 53, PAYMENT_AMT, 54, PAYMENT_AMT,
    55, PAYMENT_AMT, 56, PAYMENT_AMT, 57, PAYMENT_AMT,
    58, PAYMENT_AMT, NULL) RECOVERIES,
    DECODE(PAYMENT_FORM, 'N', PAYMENT_AMT, NULL) NONCASH,
    DATE_FROM_SERVICE,
    DATE_THRU_SERVICE
    FROM &INPUT_TABLES
    WHERE &SECURITYCOND
    DATE_OF_PAYMENT BETWEEN :START_DATE AND :END_DATE
    ORDER BY LOCATION_1, CPO_CHECK_NBR
    As you can see, this is both much easier to write and covers the possibility of expansion of paycodes (expansions always fit in these defined ranges).
    My question is, then, is it possible to write something like this in SQL and, if so, could you give me some sample code? (I'm one of those people who learn best from looking at the code as opposed to a set of instructions)

    Here is one way you could do it.
    Create a table that has columns like:
    Payment_code varchar2(2),
    Effective_Date Date,
    Payment_type varchar2(20),
    Expiration_Date Date)
    Payment type for example could be
    I- indemnity
    M- medical
    R- recovery
    E- expenses
    Let the table name for example be PAYMENT_CODE.
    The select query would look like
    SELECT ACCOUNT_NAME,
    LOCATION_1,
    CLMNT_LAST_NAME,
    CLAIM_NBR,
    DATE_OF_INJURY,
    DATE_CHECK_REGISTER,
    PAYEE_NAME_1,
    PAYMENT_CD,
    SERV_OFC,
    CPO_CHECK_NBR,
    PAYMENT_FORM,
    DECODE(p.payment_type,'E',PAYMENT_AMOUNT,0) expenses,
    DECODE(p.payment_type,'I',PAYMENT_AMOUNT,0) indemnity,
    DECODE(p.payment_type,'M',PAYMENT_AMOUNT,0) Medical,
    DECODE(p.payment_type,'R',PAYMENT_AMOUNT,0) recoveries,
    DECODE(PAYMENT_FORM, 'N', PAYMENT_AMT, NULL) NONCASH
    FROM &INPUT_TABLES,
    PAYMENT_CODE P
    WHERE P.PAYMENT_CODE = SOMEINPUT_TABLE.PAYMENT_CODE
    and other conditions
    The idea is to group all the payment codes into a few groups to reduce the clutter. If there is ever a change to the payment code, you could modify the table and it will be reflected in your select query.

  • Problem in SQL with CURSOR( ) ,Why the CURSOR did not work?

    hi All:
    I have a problem in SQL with CURSOR.
    The data is as the attachments.
    Here is the SQL statement as follow:
    SELECT A.WADCTO,A.WADOCO,B.IGCOST,CURSOR (SELECT X.IGLITM
    FROM F3102 X
    WHERE X.IGDOCO=A.WADOCO
    AND X.IGCOST IN ('B1','D1','C3')) AS DETAIL
    FROM F4801 A INNER JOIN F3102 B ON A.WADOCO=B.IGDOCO AND A.WADCTO=B.IGDCTO AND B.IGCOST>' '
    WHERE A.WADOCO='10004'
    The statement above returns records as follow:
    WADC WADOCO IGCOST DETAIL
    WO 10004 A1 CURSOR STATEMENT : 4
    CURSOR STATEMENT : 4
    IGLITM
    1KV90CPG2
    1KV90CPG2
    1KV90CPG2
    But, after I add one statement in the subquery, there is no record returned from CURSOR.
    Here is the SQL statement:
    SELECT A.WADCTO,A.WADOCO,B.IGCOST,CURSOR (SELECT X.IGLITM
    FROM F3102 X
    WHERE X.IGDOCO=A.WADOCO
    AND X.IGCOST=B.IGCOST
    AND X.IGCOST IN ('B1','D1','C3')) AS DETAIL
    FROM F4801 A INNER JOIN F3102 B ON A.WADOCO=B.IGDOCO AND A.WADCTO=B.IGDCTO AND B.IGCOST>' '
    WHERE A.WADOCO='10004'
    The statement above returns records as follow:
    WADC WADOCO IGCOST DETAIL
    WO 10004 A1 CURSOR STATEMENT : 4
    CURSOR STATEMENT : 4
    no rows selected
    Why the CURSOR did not work?
    The database version is Oracle Database 10g Release 10.2.0.4.0 - 64bit Production.
    F3102 DATA:
    IGDOCO     IGDCTO     IGLITM     IGCOST
    10004     WO     1KV90CPG2      A1
    10004     WO     1KV90CPG2      B1
    10004     WO     1KV90CPG2      C3
    10004     WO     1KV90CPG2      D1
    F4801 DATA:
    WADCTO     WADOCO
    WO     10004
    Edited by: user2319139 on 2010/3/2 上午 1:17
    Edited by: user2319139 on 2010/3/2 上午 1:20

    Why this structure and not a join?
    The cursor() function returns a cursor handle that needs to be processed - in other words, the client needs to fetch data from it. The Oracle® Database SQL Reference+ (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/expressions005.htm#i1035107) describes it as being equivalent to a ref cursor handle.
    Thus why are you creating ref cursor handles as a column in a SQL projection - where each row will have a "+nested+" ref cursor handle to process. What problem are you attempting to hack solve this way?

  • How to reduce different versions of SQL with bind variables

    There is an application, developed on Java.
    Application executes SQL following types:
    select * from t where id in (:1)
    select * from t where id in (:1, :2)
    select * from t where id in (:1, :2, :3)
    select * from t where id in (:1, :2, :3, :4)
    ...And as a result very many versions (thousands) of similar SQL.
    Do you know a method to reduce number of such SQLs?
    I see one method: use one form of SQL with large number of prepared bid variables.
    Like as
    select * from t where id in (:1, :2, :3, :4, :5, :6, :7, :8, ...);And if query will be executed with one variable, the others will be equal to null.
    Is there another method?

    Cannot you insert those values into a temporary table and work within a subquery against that table ? That will make the code more secure, especially if the number of values is high.
    Nicolas.

  • Integrating PL/SQL with Perl

    Hello All,
    I have just started learning PL/SQL and this my first R&D stuff with PL/SQL :)
    I have a very basic beginner question.
    Suppose I want to insert 1 lakh rows in a table through Perl. One and easiest way to do is to prepare and execute insert queries using Perl module - 'DBI' module in a loop
    But I guess this will send lot of traffic over the LAN. What I rather feel is that if I execute these 1 lakh SQL queries using PL/SQL it will be comparatively more network efficient and fast.
    So I have following questions:
    1. Is it possible to integrate PL/SQL with Perl using 'DBI' module
    2. Is there a way in PL/SQL that it will return status of all the 1 Lakh SQL queries after execution that will let me know which SQL queries were successfully executed and which failed.

    1. Is it possible to integrate PL/SQL with Perl using 'DBI' moduleyes, just use a PL/SQL statement instead of a sql one
    2. Is there a way in PL/SQL that it will return status of all the 1 Lakh SQL queries after execution that will let me know which SQL queries were successfully executed and which failed.yes, you have to manage an exception block for each row and store the single row result in a cumulative variable:
    The following code is an incomplete and not testet example:
    my $STM = "
    declare
    ret varchar2(10);
    begin
      begin
        insert into mytab values(1);
        ret := ret||'0';
      exception
        when others then
          ret:=ret||'1';
      end;
      begin
        insert into mytab values(2);
        ret := ret||'0';
      exception
        when others then
          ret:=ret||'1';
      end;
    ... and so on ...
      select ret into :OUTRES from dual;
    end;";
    my $outres;
    my $hnd = $db->prepare($STM);
    $hnd->bind_param_inout( ":OUTRES", \$outres, 10);  -- 10 is the variable length, e.g. the number of inserts
    $hnd->execute();
    print "inserts output: $outres\n";At the end of the script you should hava a string of bits. A 0 for each successful insert an 1 for each unsuccessful...
    Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/10/crittografia-in-plsql-utilizzando-dbms_crypto/]

  • Learning PL/SQL with SQL plus

    I'm looking to teach myself PL/SQL with SQL Plus, it's a works pc so I can not use any other software than SQL plus.
    When starting SQL plus I'm asked for a username, password and host string.
    I'm taking it the host string is the db I want to connect to and obviously supply the username and password for level of access?
    Also what I ideally need is a sample db on my local machine to connect to with SQL plus to learn that way.
    Can anyone point me in the right direction please. Any help is greatly appreciated.

    Use the net8 configuration assistant preferably as it'll get the syntax correct.
    Otherwise you copy the sample one up one folder and edit that.
    Connection information (SID, Server/IP, port number) you'll have to get off your DBA.
    The name at the start of a tnsnames entry is the name that you want to reference the database as, so you can call it FRED if you like.
    e.g.
    FRED =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS =
            (PROTOCOL = TCP)
            (HOST = <server name or ip address>)
            (PORT = <port>) -- usually 1521 but can differ if more than one instance on the server
        (CONNECT_DATA =
          (SID = <database SID>) -- the name of the database on the server.
      )Once that's set up you can then log onto the database in the following way:
    sqlplus <user>/<password>@fred
    What happens is that the TNS Listener service (that should be running on your PC) will look up "fred" in the tnsnames.ora file and then use the information from that to make the connection to the server on the correct port and connect you to the actual database on there.
    After that.... it's up to you.
    :)

  • NATIVE PL SQL with OWB9i

    Can we use NATIVE PL-SQL with OWB ?
    Is there a performance advantage to use it with OWB.
    We work with owb9.0.2. We are going to migrate to owb10g soon.

    You may be able to, however I have never done so. I would expect that you can just call native PL/SQL from something like SQL Plus? In that case you may be able to use it in custom functions...
    Jean-Pierre

  • Tuning sql with analytic function

    Dear friends I've developed one sql :
    with REP as
    (select /*+ MATERIALIZE */ branch_code,
       row_number() over(partition by branch_code, account order by bkg_date desc  ) R,
             account,
             bkg_date,
             lcy_closing_bal
        from history t
    select REP1.branch_code,
           REP1.account,
           REP1.bkg_date,
           REP1.lcy_closing_bal,
             NULL  AS second,
           REP2.bkg_date        bkg_date2,
           REP2.lcy_closing_bal lcy_closing_bal2,
            NULL  AS third,
           REP3.bkg_date        bkg_date3,
           REP3.lcy_closing_bal lcy_closing_bal3
      from (SELECT * FROM REP WHERE R=1) REP1, (SELECT * FROM REP WHERE R=2) REP2, (SELECT * FROM REP WHERE R=3) REP3
    where
           (REP1.BRANCH_CODE = REP2.BRANCH_CODE(+) AND REP1.ACCOUNT = REP2.ACCOUNT(+)) AND
           (REP1.BRANCH_CODE = REP3.BRANCH_CODE(+) AND REP1.ACCOUNT = REP3.ACCOUNT(+))The point is I want to restrict (tune) REP before it used ,because , as you can see I need maximum three value from REP (where R=1,R=2,R=3) . Which analytic function and with wich options I have to use to receive only 3 values in each branch_code,account groups at the materializing time ?

    Radrigez wrote:
    Dear friends I've developed one sql :
    with REP as
    from (SELECT * FROM REP WHERE R=1) REP1,
    (SELECT * FROM REP WHERE R=2) REP2,
    (SELECT * FROM REP WHERE R=3) REP3
    where
    (REP1.BRANCH_CODE = REP2.BRANCH_CODE(+) AND REP1.ACCOUNT = REP2.ACCOUNT(+)) AND
    (REP1.BRANCH_CODE = REP3.BRANCH_CODE(+) AND REP1.ACCOUNT = REP3.ACCOUNT(+))
    The first step is to put your subquery (which doesn't need to be materialized) into an inline view and restrict the result set on r in (1,2,3) as suggested by thtsang - you don't need to query the same result set three times.
    Then you're looking at a simple pivot operation (assuming the number of rows you want per branch and account is fixed). If you're on 11g search the manuals for PIVOT, on earlier versions you can do this with a decode() or case() operator.
    Step 1 (which could go into another factored subquery) would be something like:
    select
            branch_code, account,
            case r = 1 then bkg_date end bkg_date,
            case r = 1 then lcy_closing_bal end lcy_closing_bal,
            case r = 2 then bkg_date end bkg_date2,
            case r = 2 then lcy_closing_bal end lcy_closing_bal2,
            case r = 3 then bkg_date end bkg_date3,
            case r = 3 then lcy_closing_bal end lcy_closing_bal3
    from
            repThis gives you the eight necessary columns, but still (up to) three rows per branch/account.
    Then you aggregate this (call it rep1) on branch and account.
    select
            branch_code, account,
            max(bkg_date),
            max(lcy_closing_bal),
            max(bkg_date2),
            max(lcy_closing_bal2),
            max(bkg_date3),
            max(lcy_closing_bal3)
    from
            rep1
    group by
            branch_code, account
    order by
            branch_code, accountRegards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    Author: <b><em>Oracle Core</em></b>

  • Can a SQL WITH Clause be used in Materialized View

    Hello,
    Can we use SQL WITH clause in Materialized View.
    Thanks

    Hello,
    Here is an example
    CREATE MATERIALIZED VIEW MV_TEST
    BUILD IMMEDIATE
    REFRESH FORCE ON DEMAND
    AS
    WITH t AS (SELECT owner, object_type, COUNT ( * )
               FROM my_objects
               GROUP BY object_type, owner)
    SELECT *
    FROM t
    WHERE owner IN ('SYS', 'SYSTEM');Regards

  • [1.1.2.25.79] Program hangs after starting long runnin SQL with parameters

    Hello Forum,
    I'm currently tuning some SQLs with parameters that run some minutes. When I enter the SQL in the worksheet and press F9, SQL Developer asks for the parameters. But after clicking "Apply" (or whatever it is called in the english version, I'm using german ;-)
    I get the elapsed time of 0.018 seconds displayed and the whole program hangs until the SQL is completed. The elapsed time is not updated so I don't get the real elapsed time.
    I run SQL Developer against an Oracle 9.2 Database on Win2k. The client runs WinXP.
    I hope this is not a double post but searching the forum for "parameters" gave too many hits to check. ;-)
    Regards,
    dhalek

    Sqldev hangs when issuing an action that requires the previous action to be completed first.
    Sqldev could open a new connection for this, or at least display a message telling the action isn't possible until the previous one completes, instead of just hanging. Vote for the requests for this on the SQL Developer Exchange if you want this getting addressed sooner.
    Thanks,
    K.

  • Tuning a sql with :1, :2...

    SQL was generated by Peoplesoft application:
    SELECT DISTINCT COMPANY, PAYGROUP, PAY_END_DT, TO_CHAR(PAY_END_DT, 'YYYY-MM-DD'),
         OFF_CYCLE, PAGE_NUM, LINE_NUM, SEPCHK, FORM_ID, PAYCHECK_NBR, EMPLID,
         NAME FROM PS_ZZ_PAY_CHK_VW
    WHERE COMPANY LIKE 'DCG%'
         AND PAYGROUP LIKE 'G9E%'
         AND PAY_END_DT=TO_DATE(:1, 'YYYY-MM-DD')
         AND OFF_CYCLE=:2 AND PAGE_NUM=:3
         AND LINE_NUM=:4 AND SEPCHK=:5
         AND ROWSECCLASS=:6
    ORDER BY COMPANY, PAYGROUP, PAY_END_DT, OFF_CYCLE, PAGE_NUM, LINE_NUM, SEPCHK;
    Bind variables are :1, :2, etc.
    Tried to assign some values to :1 and got the follwowing error:
    SQL> variable 1 varchar2(20)
    exec :1 := '2007-05-01'
    'SP2-0553: Illegal variable name "1".
    My question is: why the bind variables don't have a name? How to tune it if I can not touch the original code? Thanks.
    Michael

    I think it should work. But again, I can not test it because I can not get the sql to run.
    I thought changing the bind variable name may work for a moment but it turned out it doesn't work. Here is the test I did:
    create outline for the bad sql:
    INSERT INTO PS_WRK_GRP3_TAO4 (PROCESS_INSTANCE,OPRID , RUN_CNTL_ID , GROUP_ID ,EMPLID , EMPL_RCD , TEMP_FLD)
         SELECT 232596 ,'jennifer.landis' ,'jen' , 'DCALL',JOB.EMPLID ,JOB.EMPL_RCD , 'A'
         FROM PS_JOB JOB, PS_PERSONAL_DT_FST PERSONAL_DT_FST, PS_EMPLOYMENT EMPLOYMENT, PS_TL_EMPL_DATA TL_EMPL_DATA
         WHERE JOB.EMPLID =PERSONAL_DT_FST.EMPLID
         AND JOB.EMPLID = EMPLOYMENT.EMPLID
         AND JOB.EMPL_RCD = EMPLOYMENT.EMPL_RCD
         AND JOB.EFFDT= ( SELECT MAX(JOB1.EFFDT)
              FROM PS_JOB JOB1
              WHERE JOB1.EMPLID=JOB.EMPLID
              AND JOB1.EMPL_RCD=JOB.EMPL_RCD
              AND JOB1.EFFDT <= TO_DATE(:x1,'YYYY-MM-DD'))
         AND JOB.EFFSEQ= ( SELECT MAX(JOB2.EFFSEQ)
              FROM PS_JOB JOB2
              WHERE JOB2.EMPLID=JOB.EMPLID
              AND JOB2.EMPL_RCD=JOB.EMPL_RCD
              AND JOB2.EFFDT=JOB.EFFDT)
         AND JOB.EMPLID = TL_EMPL_DATA.EMPLID
         AND JOB.EMPL_RCD = TL_EMPL_DATA.EMPL_RCD
         AND TL_EMPL_DATA.EFFDT = ( SELECT MAX(TL_EMPL_DATA1.EFFDT)
              FROM PS_TL_EMPL_DATA TL_EMPL_DATA1
              WHERE TL_EMPL_DATA1.EMPLID = TL_EMPL_DATA.EMPLID
              AND TL_EMPL_DATA1.EMPL_RCD = TL_EMPL_DATA.EMPL_RCD
              AND TL_EMPL_DATA1.EFFDT <= TO_DATE(:x2,'YYYY-MM-DD'))
         AND ( TL_EMPL_DATA.TIME_RPTG_STATUS <> 'I');
    create outline for tuned sql with hint and changed variable:
    INSERT INTO PS_WRK_GRP3_TAO4 (PROCESS_INSTANCE,OPRID , RUN_CNTL_ID , GROUP_ID ,EMPLID , EMPL_RCD , TEMP_FLD)
         SELECT /*+ rule */ 232596 ,'jennifer.landis' ,'jen' , 'DCALL',JOB.EMPLID ,JOB.EMPL_RCD , 'A'
         FROM PS_JOB JOB, PS_PERSONAL_DT_FST PERSONAL_DT_FST, PS_EMPLOYMENT EMPLOYMENT, PS_TL_EMPL_DATA TL_EMPL_DATA
         WHERE JOB.EMPLID =PERSONAL_DT_FST.EMPLID
         AND JOB.EMPLID = EMPLOYMENT.EMPLID
         AND JOB.EMPL_RCD = EMPLOYMENT.EMPL_RCD
         AND JOB.EFFDT= ( SELECT MAX(JOB1.EFFDT)
              FROM PS_JOB JOB1
              WHERE JOB1.EMPLID=JOB.EMPLID
              AND JOB1.EMPL_RCD=JOB.EMPL_RCD
              AND JOB1.EFFDT <= TO_DATE(:y1,'YYYY-MM-DD'))
         AND JOB.EFFSEQ= ( SELECT MAX(JOB2.EFFSEQ)
              FROM PS_JOB JOB2
              WHERE JOB2.EMPLID=JOB.EMPLID
              AND JOB2.EMPL_RCD=JOB.EMPL_RCD
              AND JOB2.EFFDT=JOB.EFFDT)
         AND JOB.EMPLID = TL_EMPL_DATA.EMPLID
         AND JOB.EMPL_RCD = TL_EMPL_DATA.EMPL_RCD
         AND TL_EMPL_DATA.EFFDT = ( SELECT MAX(TL_EMPL_DATA1.EFFDT)
              FROM PS_TL_EMPL_DATA TL_EMPL_DATA1
              WHERE TL_EMPL_DATA1.EMPLID = TL_EMPL_DATA.EMPLID
              AND TL_EMPL_DATA1.EMPL_RCD = TL_EMPL_DATA.EMPL_RCD
              AND TL_EMPL_DATA1.EFFDT <= TO_DATE(:y2,'YYYY-MM-DD'))
         AND ( TL_EMPL_DATA.TIME_RPTG_STATUS <> 'I');
    swap outlines
    run the bad sql but it doesn't work.
    SQL> select name, category, used from dba_outlines;
    NAME CATEGORY USED
    TIME_ADM SYSADM UNUSED
    TIME_ADM1 SYSADM UNUSED

  • Generate ANSI SQL with Oracle IKM

    Is it possible for ODI to generate ANSI SQL with the Oracle IKM?
    I have used ANSI joins in a filter in an interface, now when I run the interface I get the error: ORA-25156: old style outer join (+) cannot be used with ANSI joins.
    I would prefer to use ANSI joins in my filters instead of the old style (+) syntax. Is this possible?

    Sure,
    Go to topology, edit your Oracle technology , on SQL tab change it over to ordered joins - clause location - From , you can specify the keywords left join, right join, full outer join etc to get rid of your '(+)'

  • Retrieve SQL with filters applied from an Interactive Report

    I want to use an Interactive report as interface for providing parameters to a base report query.
    I would like to capture the full SQL code from the filtered interactive report and then run the sql to create a collection.
    I have found this tread
    Re: Using Data from filtered Interactive Report
    which says that you can use APEX_APPLICATION_PAGE_IR to access the reports SQL. This holds the information about the interactive report when the user saves it. The sql code from the interactive report (after the user has added filters) is stored in the field sql_query.I can only retrieve the base query and not the filtered version even after saving.
    Any ideas how this can be done would be appreciated.
    regards
    PP

    OK Darren I think I've got it working. My solution is an adaption that follows the steps of a blog I found here: http://stewstools.wordpress.com/2009/02/19/get-ir-where-clause/
    My solution allows you to click on a button and the records that are currently displayed in the IR report are saved to an APEX collection. You can then use the collection to save records to a table or run a report on another page. (I haven't included code for this last step but it's easy to find on the forum)
    First a bit of background knowledge. The following APEX views hold all the information on IRs that you access via PLSQL code in the package you need to download. Run an IR report, save a version of the report, then in SQL Workshop have a look at:
    select * from APEX_APPLICATION_PAGE_IR
    select * from APEX_APPLICATION_PAGE_IR_COND
    select * from APEX_APPLICATION_PAGE_IR_COL
    select * from APEX_APPLICATION_PAGE_IR_RPT
    When you run an IR report it has an internal ID that you can access and also a Base Id for each Saved report that is currently in context.
    Here are the steps:
    1) Download the following package and install it in the workspace schema
    http://www.mediafire.com/?nj118x9vmc9
    click on the link "click here to download"
    2)In the HTML header Attribute of the page where your IR runs, put the following Javascript:
    <!--===================================================================-->
    <!--FUNCTION TO RETRIEVE IR REPORTS SQL WITH WHERE CLAUSE
    <!--===================================================================-->
    <script language="JavaScript" type="text/javascript">
    function SaveAndRunReport() {
    document.location='f?p=&APP_ID.:3:&SESSION.:CONSTRUCT_IR_QUERY:NO::'+
    'P3_BASE_REPORT_ID:'+$v('apexir_REPORT_ID');
    </script>
    <!--===================================================================-->
    Notes: You will need to obviously change the URL above to reflect your Page No. (3) and the name of a HIDDEN Item (P3_BASE_REPORT_ID) that you will populate with the base ID of the report.
    Setting :P3_BASE_REPORT_ID to +$v('apexir_REPORT_ID') is an internal thing and works out of the box. It returns the Id of the Base report.
    3) Create a button called SELECT_SPECIMENS (in region position - top of region) in the IR region that will initiate the execution of the IR background SQL to create a collection with the current selected records.
    TARGET= URL
    URL Target = javascript:SaveAndRunReport();
    You might also want to create a condition that only shows the button when there are records selected
    CONDITION TYPE=Exists(SQL returns at least one row)
    EXPRESSION 1 - put the SQL of the IR report here.
    4)Create a branch back to the same page (3) and with the REQUEST attribute set to the value in the Javascript URL above e.g. CONSTRUCT_IR_QUERY. Create a condition on the branch that uses this branch WHEN BUTTON PRESSED= SELECT_SPECIMENS
    5) Create an AFTER HEADER PROCESS with the following code:
    declare
    v_base_query clob;
    v_where clob;
    v_query clob;
    v_base_where varchar2(12):=' where 1=1 '; -- incase there is no where clause in the base query
    begin
    if apex_collection.collection_exists('IR_COLLECTION') THEN
    htmldb_collection.delete_collection( p_collection_name => 'IR_COLLECTION');
    end if;
    --GET THE BASE QUERY OF THE IR REPORT
    select sql_query
    into v_base_query
    from APEX_APPLICATION_PAGE_IR
    where application_id=:APP_ID
    and page_id=:APP_PAGE_ID; -- you can only have one IR report per page
    --UNCOMMENT TO VIEW THE PARAMETERS TO THE PACKAGED FUNCTION
    --raise_application_error(-20001, :APP_ID||'-'||:APP_PAGE_ID||'-'||:SESSION||'-'||:P3_BASE_REPORT_ID);
    --GET THE SQL FILTER CODE
    select apex_ir_query.ir_query_where(:APP_ID,:APP_PAGE_ID,:SESSION,:P3_BASE_REPORT_ID)
    into v_where
    from dual;
    --CHECK TO SEE THAT THERE IS A "WHERE" CLAUSE IN THE BASE QUERY
    if instr(upper(v_base_query),'WHERE ') > 0 then
    v_query:=v_base_query||' '||v_where;
    else
    v_query:=v_base_query||' '||v_base_where||' '||v_where;
    end if;
    --UNCOMMENT TO SEE THE FULL QUERY SYNTAX
    --raise_application_error(-20001,v_query);
    --CREATE COLLECTION FROM IR RECORDS
    apex_collection.create_collection_from_query(P_collection_name=>'IR_COLLECTION',p_query=>v_query);
    exception
    when others then
    raise_application_error(-20001, 'Interactive report not found. Contact Administrator. Could not create collection of records.');
    end;
    remember to update P3_BASE_REPORT_ID above to your HIDDEN ITEM name.
    Set the following attributes for the process above
    CONDITIONAL PROCESSING
    CONDITION TYPE = Request=Expression 1
    EXPRESSION 1 --> CONSTRUCT_IR_QUERY (Note: this was set on the branch in step 4 above)
    6) Run the IR report, click on the "SELECT SPECIMENS" button then click on the Session link on the Developer's Toolbar and select VIEW COLLECTIONS from the popup list then click GO. You should now see the IR records.
    By the way I've been testing in IE not Firefox.
    ...and that's it!
    enjoy
    Paul P

  • Send mail from PL/SQL with an attachment

    Hi,
    Can any body help me on how to send a mail from PL/SQL with an attachment which is located on a unix system path.
    This is an urgent requirement in my current project. Any quick reply would be greatly appreciated.
    Thanks
    Kumar.

    Quick reply (too bad you didn't mention your DB-version):
    Check the docs @ http://tahiti.oracle.com regarding packages UTL_SMTP and UTL_MAIL
    Check http://asktom.oracle.com/pls/asktom/asktom.search?p_string=%22mail+attachment%22
    Check http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
    Check http://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#UTL_MAIL

  • From ASCII txt file to MS SQL with UTF-8 Korean

    I am trying to convert korean text
    ([Àç¹Ì] ¿·Áý
    ºÎÀÎÀÌ
    ¾Æ³»º¸´Ù
    ÁÁÀºÀÌÀ¯? ) which is saved
    in a tab delimited text file into MS SQL with UTF-8/Unicode
    characters ([생각] 인생을
    즐길 수 있는 좋은
    나이는? ).
    I have tried ascii_utf8 and CF_charsetConvert 1.1 and it
    didn't work.
    Is there any other CF tags that can do the jobs?

    atomic wrote:
    > I have tried it but im getting CFMX error when using
    > <cffile action = "read" file = "myPath\myPath.txt"
    variable = "myVar" charset
    > = "euc-kr">
    not sure about cf6, get the charset cfc from here:
    http://www.sustainablegis.com/projects/i18n/charsetTB.cfm
    and see what your system supports. also try one of the others
    like
    x-windows-949, etc.
    >
    > sun.io.ByteToCharEUC_KR.getIndex1()[S
    >
    > Did I miss out on any ColdFusion Administration
    settings? Maybe JVM?
    no, either that JRE doesn't support EUC-KR (kind of unlikely)
    or the JRE isn't
    the international one with the "extra" charsets (my guess).
    if you can update
    the JRE (for cf6-7, it has to be 1.4.x family), try that.
    make sure you get the
    server version & international one (though i think that's
    all they d/l these days).

Maybe you are looking for

  • Error message when I try to open the "help" files.

    When I try to open the help files in Elements Photoshop 10, I get the following error message in a pop up box.  At the top, the box is labeled "Adobe AIR"  The message:  "Application descriptor could not be found for this application.  Try re-install

  • Error while attaching document in cv01n

    Hi, We are attaching document in transaction cv01n,at the time of saving it gives error  massege change is not allowed,but still system is saving saving that documet.can anybody suggest solution to avoid error massege. Thanks, Vikas warke

  • Mass creation of materials

    Hi gurus, I need to create about 200 materials with reference to dummy material through MASS, I selected the table MARA ,data records to be created and entered the ref material and all the material nos to be created in the top boxes, After execution

  • I decided to remote lock my Macbook Pro from Find My iPhone. It's been three weeks and still no lock.

    About three weeks ago, I was sitting in class, got bored, and decided that I'd try and see what would happen if I locked my Macbook Pro (17-inch 2.66 GHz on 10.8.2, early 2009) from Find My iPhone. I'm concerned because my Mac has never locked, despi

  • Can't access some websites from XP machines on the network, but Win7 PC's ok

    Hi, We have a SBS installation with both XP and 7 PCs on it. Within the last couple of weeks the XP units have become unable to access certain websites, although others are ok. Windows 7 PC's are fine. Pings to the affected sites are also ok from eit