Oracle procedure help

I have table which has 4 cloums, I would like to write procedure
Type varchar2(10)
start Date date
end date date
new_news varchar2(100)
FOR START DATE
Type =A OR B . whatever start-date user type, save as the sunday before (if it is not already a suday)
but if type = C or D, use what ever date user types in
FOR END DAEE
Type =A OR B . whatever start-date user type, save as the sunday before (if it is not already a suday)
but if type = C or D, use what ever date user types in
new_news
if type = A OR B no new_news entry should be allowed
if type=C or D new_news hader can be type in
I need help on writting procedure.

SQL> SELECT sysdate today, NEXT_DAY(sysdate - 7,'Sun') last_sunday,
  2         NEXT_DAY(TO_DATE('03-Jul-2005','dd-Mon-yyyy') - 7,'Sun') keep_sun
  3  FROM dual;
TODAY                 LAST_SUNDAY           KEEP_SUN
Monday    04-Jul-2005 Sunday    03-Jul-2005 Sunday    03-Jul-2005TTFN
John

Similar Messages

  • Help in calling sql loader and an oracle procedure in a script

    Hi Guru's
    please help me in writing an unix script which will call sql loader and also an oracle procedure..
    i wrote an script which is as follows.
    !/bin/sh
    clear
    #export ORACLE_SID='HOBS2'
    sqlldr USERID=load/ps94mfo16 CONTROL=test_nica.ctl LOG=test_nica.log
    retcode=`echo $?`
    case "$retcode" in
    0) echo "SQL*Loader execution successful" ;;
    1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
    2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
    3) echo "SQL*Loader execution encountered a fatal error" ;;
    *) echo "unknown return code";;
    esac
    sqlplus USERID=load/ps94mfo16 << EOF
    EXEC DO_TEST_SHELL_SCRIPT
    it is loading the data in to an oracle table
    but the procedure is not executed..
    any valuable suggestion is highly appriciated..
    Cheers

    multiple duplicate threads:
    to call an oracle procedure and sql loader in an unix script
    Re: Can some one help he sql loader issue.

  • Please help to call oracle procedure with out paramter from shell script

    Hi
    I want to call a process with out parameter from shell script. I am calling process in shell script in below way
    function Process_loads {
    ( echo 'set serveroutput on size 1000000 arraysize 1'
    echo "set pagesize 0 term on verify off feedback off echo off"
    echo "BEGIN"
    echo " dbms_output.put_line('Before Calling The package'); "
    echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
    echo " dbms_output.put_line('After Calling The package'); "
    echo "EXCEPTION "
    echo " WHEN OTHERS THEN "
    echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
    echo " ROLLBACK;"
    echo "END;"
    echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
    Here $error_code is out paramter. All varaibles passed in process are declared with export command.
    When executing .sh it gives below error
    "sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
    Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
    Thanks in advance

    You can try this:
    From sql*plus
    SQL> ed
      1  create or replace procedure my_proc(p_id in int, p_result out int)
      2  as
      3  begin
      4  select 10 * p_id
      5  into p_result
      6  from dual;
      7* end my_proc;
    SQL> /
    Procedure created.
    SQL> set serveroutput on
    SQL> declare
      2  v_r int;
      3  begin
      4  my_proc(10,v_r);
      5  dbms_output.put_line(v_r);
      6  end;
      7  /
    100
    PL/SQL procedure successfully completed.
    from bash:
    testproc.sh:
    #!/bin/bash
    (echo 'set serveroutput on';
    echo 'declare';
    echo 'v_r int;';
    echo 'begin';
    echo 'my_proc(10,v_r);';
    echo 'dbms_output.put_line(v_r);'
    echo 'end;';
    echo '/';) | sqlplus -s u1/u1
    Console:
    oracle@mob-ubuntu:~$ chmod u+x testproc.sh
    oracle@mob-ubuntu:~$ ./testproc.sh
    100
    PL/SQL procedure successfully completed.With kind regards
    Krystian Zieja

  • Need sum help..........Regarding Oracle Procedure Builder

    hi,
    i wnt sum information abt oracle procedure builder.
    i m preparing for 1zo-047,n wnt oracle procedure builder 2 practice.
    cn ne1 plssssssssssss tel me whr shd i luk 4 it....
    i cd nt found dis s/z newhr on internet,i even dnt knw whether i hv 2 download it from internet or its already present in the sql plus.
    cn ne1 pls help me 2 resolve these queries.... its urgent....
    thnx in advance

    908759 wrote:
    its urgent....It is urgent that you learn some language skills.
    If you cannot express yourself with clarity and evidence of intelligence, then you will never get anywhere in life.
    It actually hurt my head to try to understand whatever you typed into that post.

  • Help with calling Oracle Procedure

    First, let me state that I'm new to Oracle and using it with
    ColdFusion, but I've used CF on and off for the past 6 years. So
    this might be a simple "newbie" problem with Oracle and CF.
    My boss wrote the following simple Oracle procedure to
    concatenate three variables together (I know I could do this in CF
    directly, but I need to be able to use his existing procedures in
    Oracle)
    SPEC:
    function ShowCaption(inprecaption in long,
    incaption in long,
    inpostcaption in long,
    method in varchar2,
    xcoord in number,
    ycoord in number)
    return long;
    BODY:
    function ShowCaption(
    inprecaption in long,
    incaption in long,
    inpostcaption in long,
    method in varchar2,
    xcoord in number,
    ycoord in number)
    return long
    is
    begin
    return inprecaption || incaption || inpostcaption;
    end ShowCaption;
    I'm trying to call that procedure using the attached code but
    when I run this code I receive the error "ORA-01008: not all
    variables bound" and I'm not sure why. Searching Google hasn't come
    up with anything and I've used other procedures, but can't seem to
    make this one work. I know the procedure works within Oracle as I'm
    able to run it.
    I would really appreciate any ideas.

    Since he wrote his PL/SQL as a FUNCTION instead of a
    PROCEDURE, it complicates returning the result to ColdFusion. You
    haven't provided any means of capturing the return value of your
    function call in your CFSTOREDPROC call. If he had declared this a
    procedure, then you probably would have added an OUT parameter to
    the PL/SQL and an OUT CFPROCRESULT tag, but since it is a function,
    you are going to have to capture the result differently.
    Try adding a returncode="yes" parameter to your CFSTOREDPROC
    tag, then check the cfstoredproc.statusCode variable for your
    returned result value:
    <cfoutput>#cfstoredproc.statusCode#</cfoutput>
    Normally, I avoid calling Oracle
    functions from ColdFusion because in older versions of CF,
    there was no way of capturing the return value, so I rarely ever do
    it this way. In other words, I strictly write PL/SQL
    procedures for use with ColdFusion. However, if you are
    required to work with an existing function, then the method
    mentioned above may work for you.
    Phil

  • Oracle query help

    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    Report Builder 10.1.2.0.2
    ORACLE Server Release 10.1.0.4.2
    Oracle Procedure Builder 10.1.2.0.2
    Oracle ORACLE PL/SQL V10.1.0.4.2 - Production
    Oracle CORE    10.1.0.4.0    Production
    Oracle Tools Integration Services 10.1.2.0.2
    Oracle Tools Common Area 10.1.2.0.2
    Oracle Toolkit 2 for Windows 32-bit platforms 10.1.2.0.2
    Resource Object Store 10.1.2.0.2
    Oracle Help 10.1.2.0.2
    Oracle Sqlmgr 10.1.2.0.2
    Oracle Query Builder 10.1.2.0.2 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle ZRC 10.1.2.0.2
    Oracle XML Developers Kit 10.1.0.4.2 - Production
    Oracle Virtual Graphics System 10.1.2.0.2
    Oracle Image 10.1.2.0.2
    Oracle Multimedia Widget 10.1.2.0.2
    Oracle Tools GUI Utilities 10.1.2.0.2
    I have enclosed sample data and also table structure. I need help in getting the query.
    select dept_id,proc_code,override_goal,goal_override_date
      from table2
    where goal_override_date between '02-jan-2014' and '11-jan-2014'
       and dept_id = 10
       and proc_code = 'CP'
    select DEPT_ID, PROC_CODE, DAY_SUNDAY, DAY_MONDAY,
           DAY_TUESDAY, DAY_WEDNESDAY, DAY_THURSDAY,
             DAY_FRIDAY, DAY_SATURDAY
      from table1
    where dept_id =10
    and proc_code = 'CP'; 
    Table1  is kind of maintenance table.
    In Table2 values can be overridden.
    Requirement
    Check to see if there is data in table 2 for the date range . If table2 has no value then take value from table1 for that day the date falls into. Any more clarification please ask me.
    Sundays are all zeros.
    I want this data. and the sum for the date range.
    2-jan-2014  - 3
    3-jan-2014  - 3
    4-jan-2014  - 3
    5-jan-2014  - 0
    6-jan-2014  - 1
    7-jan-2014  - 3
    8-jan-2014  - 5
    9-jan-2014  - 5
    10-jan-2014 - 3
    11-jan-2014 - 3
    Sum for the date range has to be 29
    Sample table and data
    CREATE TABLE TABLE1
      DEPT_ID NUMBER NOT NULL,
      PROC_CODE VARCHAR2(2 BYTE) NOT NULL,
      DAY_SUNDAY NUMBER(4) NOT NULL,
      DAY_MONDAY NUMBER(4) NOT NULL,
      DAY_TUESDAY NUMBER(4) NOT NULL,
      DAY_WEDNESDAY NUMBER(4) NOT NULL,
      DAY_THURSDAY NUMBER(4) NOT NULL,
      DAY_FRIDAY NUMBER(4) NOT NULL,
      DAY_SATURDAY NUMBER(4) NOT NULL
    Insert into TABLE1
      (DEPT_ID, PROC_CODE, DAY_SUNDAY, DAY_MONDAY, DAY_TUESDAY,
      DAY_WEDNESDAY, DAY_THURSDAY, DAY_FRIDAY, DAY_SATURDAY)
    Values
      (10, 'CP', 0, 3, 3,
      3, 3, 3, 3);
    COMMIT;
    CREATE TABLE TABLE2
      DEPT_ID NUMBER NOT NULL,
      PROC_CODE VARCHAR2(2 BYTE) NOT NULL,
      OVERRIDE_GOAL NUMBER(4),
      GOAL_OVERRIDE_DATE DATE NOT NULL
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 1, TO_DATE('01/06/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 3, TO_DATE('01/07/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 5, TO_DATE('01/08/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 5, TO_DATE('01/09/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 3, TO_DATE('01/10/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 3, TO_DATE('01/11/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    Help is highly appreciated.

    SELECT dates,
           override_goal,
           SUM(override_goal) OVER()
           FROM(SELECT dates,
                       CASE WHEN EXISTS(SELECT 1
                                        FROM table2 t2
                                        WHERE t2.goal_override_date = qry1.dates
                                        AND t2.dept_id = 10
                                        AND t2.proc_code = 'CP')
                            THEN (SELECT override_goal
                                  FROM table2 t2
                                  WHERE t2.goal_override_date = qry1.dates
                                  AND t2.dept_id = 10
                                  AND t2.proc_code = 'CP')
                       ELSE (SELECT DECODE(days,'SUN',day_sunday,
                                                'MON',day_monday,
                                                'TUE',day_tuesday,
                                                'WED',day_wednesday,
                                                'THU',day_thursday,
                                                'FRI',day_friday,
                                                'SAT',day_saturday )
                              FROM table1)
                       END as override_goal
                FROM (SELECT in_dt1+(LEVEL-1) dates,
                             TO_CHAR(in_dt1+(LEVEL-1),'DY') days
                      FROM(SELECT TO_DATE(&from_date,'DD-MON-YYYY') in_dt1,
                                  TO_DATE(&to_date,'DD-MON-YYYY') in_dt2
                                 FROM dual)
                      CONNECT BY LEVEL <= (in_dt2 - in_dt1)+1) qry1);
    Now run the query it will prompt you for the inputs. You can pass the date values and check the result. Otherwise replace &from_date,&to_date with user inputs

  • Convert php script to oracle procedure

    To all please help me... I wanna convert php script to oracle procedure..and the script is (exp)..
    <?php
    include("../config/koneksi.php");
    $customer=$_POST['customer'];
    $tanggal1=$_POST['theDate1'];
    $tanggal2=$_POST['theDate2'];
    $no_bulan=substr($tanggal1,0,2);
    $bulan_sajah= (substr($no_bulan,0,1)=='0')? substr($no_bulan,1,1) : $no_bulan;          
    $tahun_sajah=substr($tanggal1,3,4);
    $blnkmrn=(int)$bulan_sajah;
    $thnkmrn=(int)$tahun_sajah;
    if ($blnkmrn==1) {
         $bulan_lalu=12;
         $tahun_lalu=$thnkmrn-1;}
    else {
         $bulan_lalu=$blnkmrn-1;
         $tahun_lalu=$thnkmrn;
    $bulanlalu=strval($bulan_lalu);
    $tahunlalu=strval($tahun_lalu);
    $sql = "select nip_nas from edo_customer_master_dives where standard_name='$customer'";
         $stm = ociparse($conn,$sql);
         ociexecute($stm);
         ocifetch($stm);
         $data=ociresult($stm,1);
         $sql12 = "select PRODUCT_LINE_ID,sum(REVENUE)
    from PA_FACT_REV_BILLED_CC
    where nip_nas='$data' and year_id='$tahun_sajah' and month_id='$bulan_sajah' group by PRODUCT_LINE_ID";
         $stm12 = ociparse($conn,$sql12);
         ociexecute($stm12);
         $total_revenue=0;
         $i="0";
    while (ocifetch($stm12)){
         $rev_items=ociresult($stm12,1);
         $revenue=ociresult($stm12,2);
         $sql2 = "select * from PA_FACT_REV_BILLED_CC
    where nip_nas='$data' and PRODUCT_LINE_ID='$rev_items'";
         $stm2 = ociparse($conn,$sql2);
         ociexecute($stm2);
         ocifetch($stm2);
    $tahun=ociresult($stm2,1);
    $bulan=ociresult($stm2,2);
    $nipnas=ociresult($stm2,3);
    $prod_line=ociresult($stm2,4);
    $rev_item=ociresult($stm2,5);
    //$revenue=ociresult($stm2,6);
    $query1 = "select standard_name from edo_customer_master_dives where nip_nas='$nipnas'";
         $st1 = ociparse($conn,$query1);
         ociexecute($st1);
         ocifetch($st1);
         $nama_cust=ociresult($st1,1);
         $query2 = "select prod_line_lname from parameter.p_prod_line@dwhnas where prod_line_id='$prod_line'";
         $st2 = ociparse($conn,$query2);
         ociexecute($st2);
         ocifetch($st2);
         $nama_prod_line=ociresult($st2,1);
         $query3 = "select REV_TYPE_LNAME from parameter.p_rev_type@dwhnas where REV_TYPE_ID='$rev_item'";
         $st3 = ociparse($conn,$query3);
         ociexecute($st3);
         ocifetch($st3);
         $nama_rev_item=ociresult($st3,1);
         $query4="select sum(total_usage) from PA_FACT_TRAFFIC_CC where PRODUCT_LINE_ID='$prod_line' and nip_nas='$nipnas' and year_id='$tahun_sajah' and month_id='$bulan_sajah' group by PRODUCT_LINE_ID";
         $st4 = ociparse($conn,$query4);
         ociexecute($st4);
         ocifetch($st4);
         $total_usage=ociresult($st4,1);
         $total=$revenue + $total_usage;
         echo $tahun." ".$bulan." ".$nama_cust." ".$nama_prod_line." ".$nama_rev_item." ".$revenue." ".$total_usage." ".$total."<br>";
         $total_revenue=$total_revenue+$total;
    $i++;
    echo $total_revenue;
    //cost of product
    $query5="select * from PA_FACT_TRAFFIC_CC where nip_nas='$nipnas' and year_id='$tahunlalu' and month_id='$bulanlalu'";
    $st5 = ociparse($conn,$query5);
         ociexecute($st5);
         $total1=0;
         $total2=0;
         $total3=0;
         $total4=0;
         $total5=0;
    while (ocifetch($st5)){
         $nipnas=ociresult($st5,3);
         $lineid=ociresult($st5,4);
         $itemid=ociresult($st5,5);
         $call=ociresult($st5,6);
         $unit=ociresult($st5,7);
         $query6 = "select prod_line_lname from parameter.p_prod_line@dwhnas where prod_line_id='$lineid'";
         $st6 = ociparse($conn,$query6);
         ociexecute($st6);
         ocifetch($st6);
         $nama_prod_line=ociresult($st6,1);
         $query7 = "select REV_item_LNAME from parameter.p_rev_item@dwhnas where REV_item_ID='$itemid'";
         $st7 = ociparse($conn,$query7);
         ociexecute($st7);
         ocifetch($st7);
         $nama_rev_item=ociresult($st7,1);
    $query8 = "select * from cost_of_product where prod_line_lname='$nama_prod_line' and REV_item_LNAME='$nama_rev_item' and end_date is null";
         $st8 = ociparse($conn,$query8);
         ociexecute($st8);
         ocifetch($st8);
         $lineid_cost=ociresult($st8,1);
         $itemid_cost=ociresult($st8,2);
         $satuan=ociresult($st8,5);
         $nilai=ociresult($st8,7);
         if (strtoupper($satuan)=='MENIT') $total1=$total1+(($unit/60)*$nilai);
         if (strtoupper($satuan)=='KBPS') $total2=$total2+($unit*$nilai);
         if (strtoupper($satuan)=='SMS') $total3=$total3+($call*$nilai);
         if (strtoupper($satuan)=='SSL') $total4=$total4+($call*$nilai);
         if (strtoupper($satuan)=='SST') $total5=$total5+($call*$nilai);
    $total_cost_pots=$total1+$total2+$total3+$total4+$total5;
    echo $total_cost_pots;
    ?>
    this script just for exp.

    Please convert step by step. for example
    (1) remove inverted quotation mark ( ` )
    (2) modify constraints syntax (PRIMARY KEY,UNIQUE KEY, KEY etc.) to [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/clauses002.htm#g1053592]Oracle constraints.
    (3) modify some datatype to [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#i45441]Oracle datatype
    (4) think how to convert auto_increment ([url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_6015.htm#i2067093]Sequence, [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7004.htm#i2235611]Beffore Trigger etc. on Oracle)
    http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_packages.htm#sthref864
    http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm

  • Select multiple items from a list box as values for a parameter of crystal report and Oracle procedure

    -  I have a  Product list box (asp.net) used as multiple selected values for  a parameter. 
    - The Product ID is defined in the Oracle procedure as NUMBER data type. 
    -  In my crystal report, I have a parameter field allow multiple values as p_product_id type as Number.  This is the code in my Record Selection Formula for the report:
    ({?p_product_id}[1] = -1 OR {Procedure_name.product_id} in {p_product_id})
    -  In C#, this is my code
    List<decimal?> productUnit = new List<decimal?>();
    int counter = 0;
    decimal prod;
    for (int i = 0; i < lstProducts.Items.Count; i++)
                  if (lstProducts.Items[i].Selected)
                                if (decimal.TryParse(lstProduct.Items[i].Value, out prod))
                                    productUnit.Add((decimal?)prod);                              
                                    counter++;
           if (counter == 0)
                       productUnit.Add(-1);                      
    ReportingDAO rDataFactory = new ReportingDAO();
    retVal = rDataFactory.GetProductReport(productUnit);
    public CrystalDecisions.CrystalReports.Engine.ReportDocument GetProductReport(List<decimal?> productUnit)
              CrystalDecisions.CrystalReports.Engine.ReportDocument retVal = new rptProductDownload();
              ReportLogon rptLog = new ReportLogon();
             rptLog.Logon(retVal, "RPT_PRODUCT_DOWNLOAD");
             retVal.SetParameterValue("p_product_id", productUnit); 
    I keep having the "Value does not fall within the expected range" when I debug.  My question is, is the data type I used for procedure/Crystal report/ and C# correct ?  I always have problem with the data type.  Any help would be
    appreciated
    Thank you

    Hi progGirl,
    Thank you for your post, but Microsoft doesn't provide support for CrystalReport now. Please post your question in SAP official site here:
    http://forums.sdn.sap.com/forum.jspa?forumID=313
    Thank you for your understanding.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to call an Oracle Procedure and get a return value in Php

    Hi Everyone,
    Has anyone tried calling an Oracle procedure from Php using the ora functions and getting the return value ? I need to use the ora funtions (no oci)because of compatibility and oracle 7.x as the database.
    The reason why I post this here is because the ora_exec funtion is returning FALSE but the error code displayes is good. Is this a bug in the ora_exec funtion ?
    My code after the connection call is as follows:
    $cur = ora_open($this->conn);
    ora_commitoff($this->conn);
    $requestid = '144937';
    echo $requestid;
    $rc = ora_parse($cur, "begin p_ins_gsdata2
    (:requestid, :returnval); end;");
    if ($rc == true) {
    echo " Parse was successful ";
    $rc2 = ora_bind ($cur, "requestid", ":requestid", 32, 1);
    if ($rc2 == true) echo " Requestid Bind Successful ";
    $rc3 = ora_bind ($cur, "returnval", ":returnval", 32, 2);
    if ($rc3 == true) echo " Returnval Bind Successful ";
    $returnval = "0";
    $rc4 = ora_exec($cur);
    echo " Result = ".$returnval." ";
    if ($rc4 == false) {
    echo " Exec Returned FALSE ";
    echo " Error = ".ora_error($cur);
    echo " ";
    echo "ErrorCode = ".ora_errorcode($cur);
    echo "Error Executing";
    ora_close ($cur);
    The Oracle procedure has a select count from a table and it returns the number of records in that table. It's defined as:
    CREATE OR REPLACE procedure p_ins_gsdata2 (
    p_requestid IN varchar2 default null,
    p_retcode OUT varchar2)
    as
    BEGIN
    SELECT COUNT (*) INTO p_retcode
    FROM S_GSMRY_DATA_SURVEY
    WHERE request_id = p_requestid ;
    COMMIT;
    RETURN;
    END;
    Nothing much there. I want to do an insert into a table,
    from the procedure later, but I figured that I start with a select count since it's simpler.
    When I ran the Php code, I get the following:
    144937
    Parse was successful
    Requestid Bind Successful
    Returnval Bind Successful
    Result = 0
    Exec Returned FALSE
    Error = ORA-00000: normal, successful completion -- while
    processing OCI function OBNDRA
    ErrorCode = 0
    Error Executing
    I listed the messages on separate lines for clarity. I don't understand why it parses and binds o.k. but the exec returns false.
    Thanks again in advance for your help. Have a great day.
    Regards,
    Rudi

    retcode=`echo $?`is a bit convoluted. Just use:
    retcode=$?I see no EOF line terminating your input. Your flavour of Unix might not like that - it might ignore the command, though I'd be surprised (AIX doesn't).
    replace the EXEC line with :
    select 'hello' from dual;
    and see if you get some output - then you know if sqlplus commands are being called from your script. You didn't mentioned whether you see the banner for sqlplus. Copy/paste the output that you get, it will give us much more of an idea.

  • Problem in XML Parsing via oracle procedure...

    Hi,
    I wrote one oracle procedure for xml parsing.
    I have one valid xml file which has "encode UTF-8". The XML file contains some comments also. While we are parsing the xml file at that time it is not parse successfully and also it is not giving any error. After the following line it is skip rest of the codes(lines).
    dbms_xmlparser.parseclob(l_parser, l_clob);
    At the end of the xml file there are some comments which is like "<!-- abc --> ".
    When I am changing the "encode UTF-8 to ISO-88596-1" & removing the comments which wrote on bottom of the file then its working fine, but the files which we are getting from the system is contains the encode UTF-8 and we don't want to preprocess on that xml files. Even if we will do that via shell script or perl script then it will be overhead to the system and in a single stroke our system will parse more than 5k xml files, so if we will do some preprocess on it, it will take some more time approx 1-2 minutes extra.
    So, If someone knows any solution of this problem, then please guide & help me on this.
    My xml file structure is as follows:-
    <?xml version="1.0" encoding="UTF-8"?>
    <mcd xmlns:HTML="http://www.w3.org/TR/REC-xml">
         <child>
              <child1>32.401 V5.5</child1>
              <child2>ZoneGate</child2>
         </child>
         <mc>
              <newid>
                   <id>12</id>
              </newid>
              <mindex>
                   <date>20111102180000</date>
                   <mt>abc1</mt>
                   <mt>abc2</mt>
                   <mvalue>
                        <r>val_1</r>
                        <r>val_2</r>
                   </mvalue>
              </mindex>
         </mc>
    </mcd>
    <!--
    ALARM STATUS
    morning 10
    afternoon 14
    evening 18
    night 22
    -->
    <!--
    PARAM:EID = 1
    PARAM:GId = 3
    PARAM:GSId = 0
    --!>
    And my oracle procedure is as follows:-
    create or replace procedure loadXMLtotable(dir_name IN varchar2, xmlfile IN varchar2) AS
    -- Defining the variables
    ecode               NUMBER;
    emesg           VARCHAR2(200);
    l_bfile      BFILE;
    l_clob      CLOB;
    l_dest_offset      INTEGER:=1;
    l_src_offset      INTEGER:=1;
    l_Char_set_id      NUMBER := NLS_CHARSET_ID('UTF8');
    l_lang_context      INTEGER := dbms_lob.default_lang_ctx;
    l_warning           INTEGER;
    l_parser dbms_xmlparser.Parser;
    l_doc dbms_xmldom.DOMDocument;
    l_nl1 dbms_xmldom.DOMNodeList;
    l_nl2 dbms_xmldom.DOMNodeList;
    l_n dbms_xmldom.DOMNode;
    node1 dbms_xmldom.DOMNode;
    colid integer ; -- column id used for identifying which column it belongs.
    l_xmltype XMLTYPE;
    sub_xmltype XMLTYPE;
    num_nodes number;
    l_index PLS_INTEGER;
    l_subIndex           PLS_INTEGER;
    starttime Date;
         temp_datatime VARCHAR(25);
    columnname varchar2(300);
    columnvalue varchar2(300);
    -- creating a Type which is a type of "test_hem" table RowType, which I created in SVN server
    TYPE tab_type IS TABLE OF test_hem%ROWTYPE;
    t_tab tab_type := tab_type();
    BEGIN
    -- Passing the xmlfile and virtual directory name which we gave at the time of directory creation
    l_bfile := BFileName('MY_FILES', xmlfile);
    dbms_lob.createtemporary(l_clob, cache=>FALSE);
    dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
    --dbms_lob.loadFromFile(dest_lob => l_clob,
    -- src_lob => l_bfile,
    -- amount => dbms_lob.getLength(l_bfile));
    dbms_lob.loadclobfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile),
    l_dest_offset, l_src_offset, l_Char_set_id, l_lang_context, l_warning);
    dbms_lob.close(l_bfile);
    -- make sure implicit date conversions are performed correctly
    dbms_session.set_nls('NLS_DATE_FORMAT','''YYYY-MON-DD HH24:MI:SS''');
    dbms_output.put_line('Date format set');
    -- Create a parser.
    l_parser := dbms_xmlparser.newParser;
    dbms_output.put_line('output 1');
    -- Parse the document and create a new DOM document.
    dbms_xmlparser.parseclob(l_parser, l_clob);
    dbms_output.put_line(' passed parsing');
    l_doc := dbms_xmlparser.getDocument(l_parser);
    dbms_output.put_line(' passed getdocument');
    -- Free resources associated with the CLOB and Parser now they are no longer needed.
    dbms_lob.freetemporary(l_clob);
    dbms_xmlparser.freeParser(l_parser);
    -- Get a list of all the EMP nodes in the document using the XPATH syntax.
    l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/child');
    -- Loop through the list and create a new record in a tble collection
    FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
    l_n := dbms_xmldom.item(l_nl1, cur_sel);
    t_tab.extend;
    -- Use XPATH syntax to assign values to he elements of the collection.
    dbms_xslprocessor.valueOf(l_n,'child1/text()',t_tab(t_tab.last).country);
    -- putting the state and vendorname into the table rowtype
    dbms_xslprocessor.valueOf(l_n,'child2/text()',t_tab(t_tab.last).state);
    END LOOP;
    -- getting the version and putting into the table rowtype
    l_n := dbms_xslprocessor.selectSingleNode(dbms_xmldom.makeNode(l_doc),'//mcd/mc/newid/id');
    dbms_xslprocessor.valueOf(l_n,'id/text()',t_tab(t_tab.last).id);
    -- selecting the nodes whose starting tag is "mindex"
    l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/mc/mindex');
    -- checking the total number of nodes whose starting through "mi"
    num_nodes := dbms_xmldom.getLength(l_nl1);
    l_index := 1;
    -- For loop to iterate the nodes.
    FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
    -- whole current node is selected and storing into the node1 variable
    node1 := dbms_xmldom.item(l_nl1, cur_sel);
    -- setting the xmltype as AL32UTF8
    l_xmltype := xmltype(l_bfile, nls_charset_id('AL32UTF8'));
    -- if selecting parent node containing the mt child node then only proceed else skip that parent node.
    IF (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r') > 0) Then
    -- fetch the datatime, convert it into to_date format and store it into table rowtype
    temp_datatime := dbms_xslprocessor.valueOf(node1, 'date/text()');
    t_tab(t_tab.last).data_time := to_char(to_date(temp_datatime, 'YYYYMmcDHH24MISS'));
    l_subIndex := 1;
                                  while (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt[' || l_subIndex || ']') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r['|| l_subIndex || ']') > 0 ) LOOP
                                  -- getting mt and corresponging mvalue/r values
    dbms_xslprocessor.valueOf(node1,'mt[' || l_subIndex || ']/text()',columnname);
    dbms_xslprocessor.valueOf(node1,'mvalue/r[' || l_subIndex || ']/text()',columnvalue);
    l_subIndex := l_subIndex + 1;
    -- getting the column to which this mapping belongs.
    select columnid into colid from abc_table where columnname=name;
    CASE colid
    WHEN 1 THEN t_tab(t_tab.last).col1 := columnvalue;
                             WHEN 2 THEN t_tab(t_tab.last).col2 := columnvalue;
                             WHEN 3 THEN t_tab(t_tab.last).col3 := columnvalue;
    ELSE dbms_output.put_line('No column mapping for counter ' || columnname) ;
    END CASE; -- end of case statement.
    END LOOP;
    -- Insert data into the real table from the table collection.
    FORALL i IN t_tab.first .. t_tab.last
    INSERT INTO test_hem VALUES t_tab(i);
    END IF;
    l_index := l_index + 1;
    COMMIT;
    END LOOP;
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    ecode := SQLCODE;
    emesg := SQLERRM;
    dbms_output.put_line(TO_CHAR(ecode) || '-' || emesg);
         dbms_lob.freetemporary(l_clob);
         dbms_xmlparser.freeParser(l_parser);
         dbms_xmldom.freeDocument(l_doc);
    END;

    Sorry Odie,
    I am new to this site as well as PL/SQL. I am giving additional details which you had mentioned in your last comments.
    our Oracle Database version is "10.2.0.4.0"
    The structure of target table Instrument_Details is as follows:
    Create table Instrument_Details (
    instrument_id          Integer  Primary Key,
    provider_name          Varchar2(32),
    version_number          Varchar2(32),
    location_id                  Integer,
    installation_date             Date,
    granularity                  Integer,
    time_out                  Integer );
    Note:- Here test_hem is alias of Instrument_details.
    Here instrument_id is a primary key.
    provider_name contains the child2 xml tag value.
    version_number contains the child1 xml tag value.
    location_id contains the newid/id value which is map to other table which fetching the location name corresponding to the location_id.
    installation_date contains the date xml tag value.
    Now we have created one mapping tables where we mapped the xml tag values "mt" with table column name means "abc1 = granularity", "abc2 = time_out" in that table.
    these table column value are written under mvalue xml tag.
    _Our Database Character set is_:-
    NLS_CHARACTERSET WE8ISO8859P1
    Now as you suggest me to format your code. I am writing the xml code and procedure code again.
    My xml file structure is as follows:-
    <?xml version="1.0" encoding="UTF-8"?>
    <mcd xmlns:HTML="http://www.w3.org/TR/REC-xml">
      <child>
          <child1>32.401 V5.5</child1>
          <child2>ZoneGate</child2>
      </child>
      <mc>
          <newid>
               <id>12</id>
          </newid>
      <mindex>
           <date>20111102180000</date>
           <mt>abc1</mt>
           <mt>abc2</mt>
           <mvalue>
                 <r>val_1</r>   -- here val_1 and val_2 are numeric values
                 <r>val_2</r>
            </mvalue>
      </mindex>
      </mc>
    </mcd>
    <!--
    ALARM STATUS
    morning 10
    afternoon 14
    evening 18
    night 22
    -->
    <!--
    PARAM:EID = 1
    PARAM:GId = 3
    PARAM:GSId = 0
    --!> And my oracle procedure is as follows:-
    create or replace procedure loadXMLtotable(dir_name IN varchar2, xmlfile IN varchar2) AS
    -- Defining the variables
    ecode NUMBER;
    emesg VARCHAR2(200);
    l_bfile BFILE;
    l_clob CLOB;
    l_dest_offset INTEGER:=1;
    l_src_offset INTEGER:=1;
    l_Char_set_id NUMBER := NLS_CHARSET_ID('UTF8');
    l_lang_context INTEGER := dbms_lob.default_lang_ctx;
    l_warning INTEGER;
    l_parser dbms_xmlparser.Parser;
    l_doc dbms_xmldom.DOMDocument;
    l_nl1 dbms_xmldom.DOMNodeList;
    l_nl2 dbms_xmldom.DOMNodeList;
    l_n dbms_xmldom.DOMNode;
    node1 dbms_xmldom.DOMNode;
    colid integer ; -- column id used for identifying which column it belongs.
    l_xmltype XMLTYPE;
    sub_xmltype XMLTYPE;
    num_nodes number;
    l_index PLS_INTEGER;
    l_subIndex PLS_INTEGER;
    starttime Date;
    temp_datatime VARCHAR(25);
    columnname varchar2(300);
    columnvalue varchar2(300);
    -- creating a Type which is a type of "Instrument_Details" table RowType, which I created in SVN server
    TYPE tab_type IS TABLE OF Instrument_Details%ROWTYPE;
    t_tab tab_type := tab_type();
    BEGIN
    -- Passing the xmlfile and virtual directory name which we gave at the time of directory creation
    l_bfile := BFileName('MY_FILES', xmlfile);
    dbms_lob.createtemporary(l_clob, cache=>FALSE);
    dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
    --dbms_lob.loadFromFile(dest_lob => l_clob,
    -- src_lob => l_bfile,
    -- amount => dbms_lob.getLength(l_bfile));
    dbms_lob.loadclobfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile),
    l_dest_offset, l_src_offset, l_Char_set_id, l_lang_context, l_warning);
    dbms_lob.close(l_bfile);
    -- make sure implicit date conversions are performed correctly
    dbms_session.set_nls('NLS_DATE_FORMAT','''YYYY-MON-DD HH24:MI:SS''');
    dbms_output.put_line('Date format set');
    -- Create a parser.
    l_parser := dbms_xmlparser.newParser;
    dbms_output.put_line('output 1');
    -- Parse the document and create a new DOM document.
    dbms_xmlparser.parseclob(l_parser, l_clob);
    *-- Below lines are skipping....*
    dbms_output.put_line(' passed parsing');
    l_doc := dbms_xmlparser.getDocument(l_parser);
    dbms_output.put_line(' passed getdocument');
    -- Free resources associated with the CLOB and Parser now they are no longer needed.
    dbms_lob.freetemporary(l_clob);
    dbms_xmlparser.freeParser(l_parser);
    -- Get a list of all the EMP nodes in the document using the XPATH syntax.
    l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/child');
    -- Loop through the list and create a new record in a tble collection
    FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
    l_n := dbms_xmldom.item(l_nl1, cur_sel);
    t_tab.extend;
    -- Use XPATH syntax to assign values to he elements of the collection.
    dbms_xslprocessor.valueOf(l_n,'child1/text()',t_tab(t_tab.last).country);
    -- putting the state and vendorname into the table rowtype
       dbms_xslprocessor.valueOf(l_n,'child2/text()',t_tab(t_tab.last).state);
    END LOOP;
    -- getting the version and putting into the table rowtype
       l_n := dbms_xslprocessor.selectSingleNode(dbms_xmldom.makeNode(l_doc),'//mcd/mc/newid/id');
      dbms_xslprocessor.valueOf(l_n,'id/text()',t_tab(t_tab.last).id);
    -- selecting the nodes whose starting tag is "mindex"
      l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/mc/mindex');
    -- checking the total number of nodes whose starting through "mi"
      num_nodes := dbms_xmldom.getLength(l_nl1);
    l_index := 1;
      -- For loop to iterate the nodes.
      FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
      -- whole current node is selected and storing into the node1 variable
      node1 := dbms_xmldom.item(l_nl1, cur_sel);
      -- setting the xmltype as AL32UTF8
       l_xmltype := xmltype(l_bfile, nls_charset_id('AL32UTF8'));
      -- if selecting parent node containing the mt child node then only proceed else skip that parent node.
        IF (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r') > 0) Then
      -- fetch the datatime, convert it into to_date format and store it into table rowtype
        temp_datatime := dbms_xslprocessor.valueOf(node1, 'date/text()');
        t_tab(t_tab.last).data_time := to_char(to_date(temp_datatime, 'YYYYMmcDHH24MISS'));
        l_subIndex := 1;
       while (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt[' || l_subIndex || ']') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r['|| l_subIndex || ']') > 0 ) LOOP
    -- getting mt and corresponging mvalue/r values
       dbms_xslprocessor.valueOf(node1,'mt[' || l_subIndex || ']/text()',columnname);
      dbms_xslprocessor.valueOf(node1,'mvalue/r[' || l_subIndex || ']/text()',columnvalue);
      l_subIndex := l_subIndex + 1;
      -- getting the column to which this mapping belongs.
      select columnid into colid from abc_table where columnname=name;
      CASE colid
      WHEN 1 THEN t_tab(t_tab.last).col1 := columnvalue;
      WHEN 2 THEN t_tab(t_tab.last).col2 := columnvalue;
      WHEN 3 THEN t_tab(t_tab.last).col3 := columnvalue;
          ELSE dbms_output.put_line('No column mapping for counter ' || columnname) ;
      END CASE; -- end of case statement.
      END LOOP;
    -- Insert data into the real table from the table collection.
      FORALL i IN t_tab.first .. t_tab.last
        INSERT INTO test_hem VALUES t_tab(i);
      END IF;
      l_index := l_index + 1;
    COMMIT;
    END LOOP;
    commit;
    EXCEPTION
      WHEN OTHERS THEN
      ecode := SQLCODE;
      emesg := SQLERRM;
      dbms_output.put_line(TO_CHAR(ecode) || '-' || emesg);
      dbms_lob.freetemporary(l_clob);
      dbms_xmlparser.freeParser(l_parser);
      dbms_xmldom.freeDocument(l_doc);
    END;Thanks in advance for your help...

  • Issue with IN parameter of Oracle Procedure returning two RefCursors...

    Hi all,
    I'm having a nightmare with an Oracle procedure that takes one input parameter and returns two RefCursors as outputs. I recently got help in this forum getting a procedure to work that took no inputs but returned two refcursors and that's still working fine. So, for my current issue I have a procedure defined as follows:
    PROCEDURE getQueueInfo(domainKey char, importQueues OUT ODPNet.refcur, exportQueues OUT ODPNet.refcur) IS
      BEGIN
        OPEN importQueues FOR SELECT
        source_key, source_applid,
        import_status(source_key) as status,
        time_added, time_processed
        FROM wm_import_source_header
        WHERE source_id = domainKey
        ORDER BY source_key DESC;
        OPEN exportQueues FOR SELECT
        h.source_key, d.source_applid,
        export_status(h.source_key) as status,
        d.source_wire_code, d.destination_wire_code, h.time_added,
        h.time_transmitted
        FROM wm_export_source_header h, wm_export_source_data d
        WHERE h.source_key = d.source_key
          and d.source_id = domainKey
        ORDER BY h.source_key DESC;
      END getQueueInfo;This is defined within a package called ODPNet as with my previous procedure and all works fine (I can execute within Oracle SQL Developer and it returns the expected results). Within my .NET application my code is as follows:
                try
                    using (OracleConnection conn = new OracleConnection(connString))
                    using (OracleCommand comm = new OracleCommand())
                        comm.CommandText = "ODPNet.getQueueInfo";
                        comm.CommandType = CommandType.StoredProcedure;
                        comm.Connection = conn;
                        OracleParameter domainKey = new OracleParameter();
                        OracleParameter importQueues = new OracleParameter();
                        OracleParameter exportQueues = new OracleParameter();
                        domainKey.OracleDbType = OracleDbType.Char;
                        importQueues.OracleDbType = OracleDbType.RefCursor;
                        exportQueues.OracleDbType = OracleDbType.RefCursor;
                        domainKey.Value = "UKBD72";
                        domainKey.Direction = ParameterDirection.Input;
                        importQueues.Direction = ParameterDirection.Output;
                        exportQueues.Direction = ParameterDirection.Output;
                        comm.Parameters.Add(domainKey);
                        comm.Parameters.Add(importQueues);
                        comm.Parameters.Add(exportQueues);
                        conn.Open();
                        comm.ExecuteNonQuery();
                        OracleDataReader dr1 = ((OracleRefCursor)importQueues.Value).GetDataReader();
                        OracleDataReader dr2 = ((OracleRefCursor)exportQueues.Value).GetDataReader();
                        if (dr1.HasRows)
                            while (dr1.Read())
                                result6 += dr1["source_applid"].ToString() + "<br>";
                        else
                            result6 += "No Rows";
                        if (dr2.HasRows)
                            while (dr2.Read())
                                result7 += dr2["source_applid"].ToString() + "<br>";
                        else
                            result7 += "No Rows";
                catch (Exception ex)
                    result6 = ex.ToString();
                }The value I want to submit as the IN parameter of the procedure is "UKBD72". but I'm really not sure how to apply this and then return my two refcursors into separate datareaders (except for the input parameter stuff the code above is exactly what I did with the other procedure that returned two ref cursors and still works fine). When I run this code I get no errors, I just get told that each DataReader has no rows returned, which shouldn't be right.
    Any help with this would be hugely appreciated.
    Cheers,
    Seb

    Sorry folks, after staring at this over and over, eventually going to sleep and coming back to it with some fresh eyes I realised I was just being a complete idiot - I was feeding the procedure different data in the .NET app than I was when testing in Oracle SQL Developer. Low and behold once I gave it the right data it worked!
    Silly me...

  • Problem in calling oracle procedure from java

    Oracle procedure with the following parameters.
    CREATE OR REPLACE PROCEDURE CREDITED_TO_STORE_INSERT (P_CUST# IN NUMBER,
    P_INV_DATE IN DATE,
    P_MEMO# IN NUMBER,
    P_SESS_ID IN VARCHAR2 ) IS
    BEGIN
    /*.........Procedure Body with select and insert statements there no OUT or return variable/value......*/
    END;
    Now i am calling this procedure with the java code in java.
    public boolean execProcedure(String storeNo, String invoiceDate, String claimNo, String sessionID) throws SQLException {
         CallableStatement cstmt = null;
         java.sql.Date invicDate = this.StringToDate(invoiceDate);
         try
         cstmt = conn.prepareCall("{call WEBUSER.CREDITED_TO_STORE_INSERT(?,?,?,?,?,?)}");
         cstmt.setInt(1, Integer.parseInt(storeNo));
         cstmt.setDate(2, invicDate);
         cstmt.setInt(3, Integer.parseInt(claimNo));
         cstmt.setString(4, sessionID);
         cstmt.execute();
         catch (Exception e)
         System.out.println (e);
         } // catch (Exception e)
         finally
         try
         cstmt.close();
         catch (Exception ex)
         } // catch (Exception ex)
         } // finally
         return true;
    But it will return the following exception.
    [STDOUT] java.sql.SQLException: Missing IN or OUT parameter at index:: 5
    i don't know why :( please help me ...

    your procedure has 4 parameters but in the prepared statement you define 6 placeholders

  • How to zip a csv file in a oracle procedure

    Hi
    i've just created an oracle procedure to put a 120 MB csv file in a shared folder but i need a way to zip this file...is it possible inside a procedure with a command??
    My only alternative is to use toad after a SELECT...but it isn't my goal?
    Please help me

    Hi,
    You can create a stored procedure that will contain a PL/SQL code that will "create" a scheduled job. Take a look at example below:
    -- I created a bash file that will be executed in order to create the zipped file
    oracle@legatti:/tmp> cat zipfile.sh
    #!/bin/sh
    /usr/bin/zip /tmp/test.zip /tmp/test.dmp
    -- This is the file that will be zipped
    oracle@legatti:/tmp> ls -lh test.dmp
    -rwxrwxrwx  1 oracle oinstall 193M 2007-12-27 10:10 test.dmp
    -- I will connect to Oracle in order to create the stored procedure
    oracle@legatti:/tmp> sqlplus / as sysdba
    SQL*Plus: Release 10.1.0.2.0 - Production on Thu Dec 27 10:18:39 2007
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    -- Let's create the stored procedure
    SQL> create or replace procedure zip is
      2  begin
      3    dbms_scheduler.create_job(job_name    => 'zipfile',
      4                              job_type    => 'executable',
      5                              job_action  => '/tmp/zipfile.sh',
      6                              enabled     => true,
      7                              auto_drop   => true);
      8  end;
      9  /
    Procedure created.
    -- Now, run the procedure created above
    SQL> exec zip;
    PL/SQL procedure successfully completed.
    -- Just certify that job was executed successfully
    SQL> select job_name,status,log_date,run_duration
      2  from dba_scheduler_job_run_details
      3  where job_name='ZIPFILE';
    JOB_NAME     STATUS        LOG_DATE                                 RUN_DURATION
    ZIPFILE      SUCCEEDED     27/12/07 10:19:18,883833 -02:00          +000 00:00:17
    -- Now you can take a look at zipped file below
    SQL> !ls -lh test.*
    -rwxrwxrwx  1 oracle oinstall 193M 2007-12-27 10:10 test.dmp
    -rw-r--r-- 1 oracle oinstall 32M 2007-12-27 10:19 test.zipHave a lot of fun ... ;-)
    Cheers
    Legatti

  • OCI 22303 exception - Pass object to type Record in oracle procedure

    Recently i had my first encounter with ODP.NET and Oracle. I'm developing a a datalayer that can access a stored procedure on an Oracle database.
    The problem i'm having is the following:
    I'm using this method to pass my parameters to the procedure: http://www.codeproject.com/KB/cs/CustomObject_Oracle.aspx
    I have also attempted this approach:
    http://developergeeks.com/article/48/3-steps-to-implement-oracle-udt-in-odpnet
    I always get the message (litteraly):
    Oracle.DataAccess.Client.OracleException: OCI-22303: type &quote;PAC$WEBSHOP_PROCS&quot;.&quot;CUSTOMER_IN_RECTYPE&quot; not found.
    It sounds weird to me, but what are the &quotes doing here in the error message I see?
    Some code i use:
    OracleParameter objParam = new OracleParameter
    OracleDbType = OracleDbType.Object,
    Direction = ParameterDirection.Input,
    ParameterName = "PAC$WEBSHOP_PROCS.P_CUSTOMER_IN",
    UdtTypeName = "PAC$WEBSHOP_PROCS.WEBSHOP_PROCS.CUSTOMER_IN_RECTYPE",
    Value = card
    The information i have about the Oracle procedure:
    CREATE OR REPLACE PACKAGE PAC$WEBSHOP_PROCS IS
    TYPE CUSTOMER_IN_RECTYPE IS RECORD
    (CUS_STO_IDENTIFIER NUMBER(2)
    ,CUS_IDENTIFIER NUMBER(6)
    ,CH_IDENTIFIER NUMBER(2)
    ,CH_CARD_VERSION NUMBER(1)
    PROCEDURE PRC$WS_VALIDATE_CARD
    (P_CUSTOMER_IN IN PAC$WEBSHOP_PROCS.CUSTOMER_IN_RECTYPE
    ,P_RETURN_CODE IN OUT NUMBER
    Any help to cover my problem would be greatly appreciated.
    Thx
    Edited by: 836497 on 14-feb-2011 4:36

    The only way to call it as is would be via an anonymous plsql block, where you create the record type inside the block. Interacting with the block via ODP would be limited to scalar values.
    Here's a PLSQL example just to demonstrate. Here, v1 and v2 are bind variables of scalar type, which you'd setup/bind via ODP instead of the SQL prompt as I did, but I thought this might keep things simpler for the example.
    The other choice would be to write a wrapper procedure that takes type OBJECT that you can call from ODP, and inside that procedure convert them to/from RECORD and call the original procedure.
    Hope it helps,
    Greg
    SQL> drop package somepack;
    Package dropped.
    SQL> create package somepack as
      2  type somerectype is record(n1 number);
      3  function somefunc (v1 somerectype) return somerectype;
      4  end;
      5  /
    Package created.
    SQL>
    SQL> create package body somepack as
      2  function somefunc (v1 somerectype) return somerectype is
      3   begin
      4    return v1;
      5   end;
      6  end;
      7  /
    Package body created.
    SQL>
    SQL>
    SQL> var v1 number;
    SQL> exec :v1 := 5;
    PL/SQL procedure successfully completed.
    SQL> var v2 number;
    SQL>
    SQL>
    SQL> declare
      2   localvar1 somepack.somerectype;
      3   localvar2 somepack.somerectype;
      4  begin
      5     localvar1.n1 := :v1;
      6     localvar2 := somepack.somefunc(localvar1);
      7     :v2 := localvar2.n1;
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL>  print v2;
            V2
             5
    SQL>

  • Problem with Oracle procedure

    Hi,
    We have a problem with a Oracle procedure call using the Sql Execute
    Procedure statement.
    The call gives us this error :
    SYSTEM ERROR: (This error was converted)
    (This error was converted)
    OpenCursor failed for SQL statement in project LFB010, class
    ClsDemarreLFB010,
    method Demarre, methodId 4, line 32, error from database is:
    ORA-01036: illegal variable name/num
    Class: qqdb_ResourceException
    Distributed method called: qqdb_SessionProxy.OpenCursor!22 (object
    name
    instance/d4745a10-c8e4-11d1-97fd-90cad1e7aa77:0x196:0x4/lfb010_cl0/lfb010_cl
    0-fonctiondbservice0x196:0x2)
    from partition "LFB010_CL0_Client", (partitionId =
    D4745A10-C8E4-11D1-97FD-90CAD1E7AA77:0x196:0x4, taskId =
    [D4745A10-C8E4-11D1-97FD-90CAD1E7AA77:0x196.3]) in application
    "FTLaunch_cl0", pid 4290975297 on node LAXOU146 in environment
    CentralEnv
    Oracle error: 1036, Server: sipre_tcp, UserName: forte
    Database Statement: begin
    :qqReturnValue := AID_CUMUL_ELTVAL;
    end;
    Class: qqdb_ResourceException ..........
    And this is the TOOL code :
    BEGIN TRANSACTION
    TmpEtat : IntegerData = new;
    TmpEtat.SetValue (( SQL EXECUTE PROCEDURE AID_CUMUL_ELTVAL ON SESSION
    FonctionDBService ));
    Etat = TmpEtat.Value;
    END TRANSACTION;
    Our procedure has no parameter and when we put a dummy parameter to the
    procedure and pass it in the TOOL SQL statement, it works fine althoug the
    Fort&eacute; help says the parameter list is optionnal !
    We tried to execute the procedure in a "SQL Select OurProdecure Into ..."
    statement, but it does'nt work because there is a SQL update in the
    procedure and it is forbidden by Oracle.
    Has anyone seen this error before ?
    Any ideas would be greatly appreciated.
    Many thanks and regards,
    Manuel DEVEAUX
    Previade, France
    e-mail : deveauxpreviade.fr

    Hi,
    We have a problem with a Oracle procedure call using the Sql Execute
    Procedure statement.
    The call gives us this error :
    SYSTEM ERROR: (This error was converted)
    (This error was converted)
    OpenCursor failed for SQL statement in project LFB010, class
    ClsDemarreLFB010,
    method Demarre, methodId 4, line 32, error from database is:
    ORA-01036: illegal variable name/num
    Class: qqdb_ResourceException
    Distributed method called: qqdb_SessionProxy.OpenCursor!22 (object
    name
    instance/d4745a10-c8e4-11d1-97fd-90cad1e7aa77:0x196:0x4/lfb010_cl0/lfb010_cl
    0-fonctiondbservice0x196:0x2)
    from partition "LFB010_CL0_Client", (partitionId =
    D4745A10-C8E4-11D1-97FD-90CAD1E7AA77:0x196:0x4, taskId =
    [D4745A10-C8E4-11D1-97FD-90CAD1E7AA77:0x196.3]) in application
    "FTLaunch_cl0", pid 4290975297 on node LAXOU146 in environment
    CentralEnv
    Oracle error: 1036, Server: sipre_tcp, UserName: forte
    Database Statement: begin
    :qqReturnValue := AID_CUMUL_ELTVAL;
    end;
    Class: qqdb_ResourceException ..........
    And this is the TOOL code :
    BEGIN TRANSACTION
    TmpEtat : IntegerData = new;
    TmpEtat.SetValue (( SQL EXECUTE PROCEDURE AID_CUMUL_ELTVAL ON SESSION
    FonctionDBService ));
    Etat = TmpEtat.Value;
    END TRANSACTION;
    Our procedure has no parameter and when we put a dummy parameter to the
    procedure and pass it in the TOOL SQL statement, it works fine althoug the
    Fort&eacute; help says the parameter list is optionnal !
    We tried to execute the procedure in a "SQL Select OurProdecure Into ..."
    statement, but it does'nt work because there is a SQL update in the
    procedure and it is forbidden by Oracle.
    Has anyone seen this error before ?
    Any ideas would be greatly appreciated.
    Many thanks and regards,
    Manuel DEVEAUX
    Previade, France
    e-mail : deveauxpreviade.fr

Maybe you are looking for