How to call a procedure from a job

I have Oracle StorProc called Regular_jobs. I have existing job code where we have already 3 steps running and 4th step should be ours.
4 - CustPayMetod table archiving
Can anybody help me incorporate code to call storproc in this job.
#!/usr/bin/sh
# Job Name: Regular_jobs
# Application Name:CSP
# Job description: Clean up of tables
# Schedule: nightly on business days
# Parameter description:
# CSP_Regular_jobs.sh lv_stepstartnum lv_stependnum
# lv_stepstartnum - Step start number --- Always use step start number as 1st parameter
# lv_stependnum - step end number --- Always use step end number as 2nd parameter
# Step description:
# number of steps: 2
# step start and end number - indicates step number to start process from
# any step and to end process to any step
# greater or equal to start number
# Steps:
# 1 - calls the cleanup.sh script
# 2 - Recreate all SEQ sequences to reset them to 1
# 3 - Purge Response Image
# ((4 - CustPayMetod table archiving --- is our step))
# Execute to setup global variables
. ${APPS}/db_batch/common/.batchenv
. ${APPS}/app_batch/common/.P_env
. ${APPS}/app_batch/common/.P_env
ORAENV_ASK=NO
. oraenv
# Initialization of local variables
# Initialize maximum number of steps
lv_maxstep_num=3
# Initialize number of parameters need to specify to execute
lv_maxpara_num=1
# Initialize return code
lv_retcode=0
# Setup parameter variables
lv_stepstartnum=$1
lv_stependnum=$2
# keep the following lines if there are more parameters to specify
# Initialize job name
lv_job_name="Regular_jobs"
# Initialize local job variables for directory path
lv_job_path="${APPBATCH}/SP"
lv_patrol_log_path="${APPPATROL_LOG}"
lv_common_path="${DBBATCH}/common"
lv_shell_path="${lv_job_path}/shell"
lv_sql_path="${lv_job_path}/sql"
lv_log_path="${lv_job_path}/log"
# Initialize local job variables for log files
lv_job_log_file="${lv_log_path}/${lv_job_name}_`date +%y%m%d`.log"
lv_patrol_log_file="${lv_patrol_log_path}/${lv_job_name}_patrol.log"
lv_err_ctl_file="${lv_common_path}/ERR.ctl"
# Addtional email address list to send
lv_mail_recipient_list="${EMAIL_LIST} ${SUPPORT_EMAIL_LIST}"
lv_hot_email_id="${HOT_EMAIL_ID}"
# Additional local variables to be added here --- REMOVE THIS COMMENT LINE IF THERE IS NO ADDITIAL LOCAL VARIABLE ---
# Environment !!!
lv_env=CSP
# Function - Display parameter usage messages and terminate the job
display_usage()
echo "================================================="
echo "${lv_job_name}"
echo "${lv_job_name}.sh stepstartnum stependnum"
echo "lv_stepstartnum - Step start number, must provided"
echo "lv_stependnum - step end number, must provided"
echo "step start and end number - indicates step number to start process from"
echo " any step and end process to any step greater"
echo " or equal to start number and less than or"
echo " equal to ${lv_maxstep_num}"
echo "Steps:"
echo " 1 - calls the cleanup_printmgrDI.sh script"
echo " 2 - Recreate all SEQ sequences to reset them to 1"
echo "=================================================="
exit 1
# Function - Check script file existence
check_file_exist()
test -f ${lv_shell_script}
lv_retcode=$?
if [ ${lv_retcode} != 0 ]
then
echo "FAILURE - File ${lv_shell_script} does not exist, the job has been terminated." >> ${lv_step_eml_file}
echo "FAILURE - File ${lv_shell_script} does not exist, the job has been terminated." >> ${lv_job_log_file}
echo "FAILURE - File ${lv_shell_script} does not exist, the job has been terminated." >> ${lv_patrol_log_file}
${NOTIFY_SCRIPT} ${lv_step_eml_file} "${lv_mail_recipient_list}" "${ENV}${lv_job_name}" ${lv_retcode}
exit 1
fi
# Function - Check log file for error messages
check_log()
${VERIFY_SCRIPT} ${lv_step_log_file} ${lv_err_ctl_file}
lv_retcode=$?
${STATUS_SCRIPT} -s ${lv_retcode} -l ${lv_step_log_file} >> ${lv_job_log_file}
${STATUS_SCRIPT} -s ${lv_retcode} -l ${lv_step_log_file} >> ${lv_patrol_log_file}
if [ ${lv_retcode} != 0 ]
then
${NOTIFY_SCRIPT} ${lv_step_eml_file} "${lv_mail_recipient_list}" "${ENV}${lv_job_name}" ${lv_retcode}
exit 1
fi
# Validate input parameter values
if [ $# -ge ${lv_maxpara_num} ]
then
if [ ${lv_stepstartnum} -lt 1 ] || [ ${lv_stepstartnum} -gt ${lv_maxstep_num} ]
then
echo "Invalid step start number: must be between 1 - ${lv_maxstep_num}"
echo ""
display_usage
fi
if [ ${lv_stependnum} -lt ${lv_stepstartnum} ] || [ ${lv_stependnum} -gt ${lv_maxstep_num} ]
then
echo "Invalid step end number: must be between ${lv_stepstartnum} - ${lv_maxstep_num}"
echo ""
display_usage
fi
else
echo "All ${lv_maxpara_num} parameters must be specified"
echo ""
display_usage
fi
# Initiate job and patrol log files if job starts from beginning - step 1
if [ ${lv_stepstartnum} -eq 1 ]
then
echo "${lv_job_name} on ${SERVERNAME} started at `date`" > ${lv_job_log_file}
echo "${lv_job_name} on ${SERVERNAME} started at `date`" > ${lv_patrol_log_file}
# update permission on patrol log file otherwise Patrol agent won't be able to monitor
chmod o+r ${lv_patrol_log_file}
fi
# Step 1: calls the cleanup.sh script
if [ ${lv_stepstartnum} -le 1 ] && [ ${lv_stependnum} -ge 1 ]
then
# Setup local step variables
lv_step_name=cleanup_printmgrDI
lv_step_log_file=${lv_log_path}/${lv_step_name}.log
lv_step_eml_file=${lv_log_path}/${lv_step_name}.eml
lv_shell_script="${lv_shell_path}/${lv_step_name}.sh"
# Verify script file existence
check_file_exist
# Execute command
${lv_shell_script}
# Append step log output to job log file
cat ${lv_step_log_file} >> ${lv_job_log_file}
# Execute varification function
check_log
fi
# Step 2: Recreate all SEQ sequences to reset them to 1
if [ ${lv_stepstartnum} -le 2 ] && [ ${lv_stependnum} -ge 2 ]
then
# Setup local step variables
lv_step_name=reset_SEQ_LRO_ALTERNATIVE
lv_step_log_file=${lv_log_path}/${lv_step_name}.log
lv_step_eml_file=${lv_log_path}/${lv_step_name}.eml
lv_shell_script="${lv_shell_path}/${lv_step_name}.sh"
# Verify script file existence
echo "@${lv_sql_path}/gen_SEQ_per_LRO.sql ${lv_env} ${lv_log_path}"
sqlplus -S /nolog << EOF > ${lv_step_log_file} 2>&1
connect / as sysdba
@${lv_sql_path}/gen_SEQ_per_LRO.sql ${lv_env} ${lv_log_path}
set echo on termout on feedback on
@${lv_log_path}/drop_SEQ_LRO_ALTERNATIVE.sql
@${lv_log_path}/cre_SEQ_LRO_ALTERNATIVE.sql
EOF
# Append step log output to job log file
cat ${lv_step_log_file} >> ${lv_job_log_file}
# Execute varification function
check_log
fi
# Step 3: Purge Response Image
if [ ${lv_stepstartnum} -le 3 ] && [ ${lv_stependnum} -ge 3 ]
then
# Setup local step variables
lv_step_name="purge_response_image"
lv_step_log_file=${lv_log_path}/${lv_step_name}.log
lv_step_eml_file=${lv_log_path}/${lv_step_name}.eml
lv_shell_script="${lv_shell_path}/${lv_step_name}.ksh"
# Verify script file existence
check_file_exist
# Execute command
${lv_shell_script} 30 10000
# Append step log output to job log file
cat ${lv_step_log_file} >> ${lv_job_log_file}
# Execute varification function
check_log
fi
# Final: Following are executed only all the previous steps are executed successfully
# to update successful status in log files and notify recipient through email.
echo "${lv_job_name} on ${SERVERNAME} finished at `date`" >> ${lv_job_log_file}
echo "${lv_job_name} on ${SERVERNAME} finished at `date`" >> ${lv_patrol_log_file}
${STATUS_SCRIPT} -s ${lv_retcode} -l ${lv_job_log_file} >> ${lv_job_log_file}
${STATUS_SCRIPT} -s ${lv_retcode} -l ${lv_job_log_file} >> ${lv_patrol_log_file}
${NOTIFY_SCRIPT} ${lv_patrol_log_file} "${lv_mail_recipient_list}" "${ENV}${lv_job_name}" ${lv_retcode}
exit 0
# ********************************** COMPLETED ************************************

Perhaps the following will get you started:
# Step 4: calls the regular_jobs.sh script
iif [ ${lv_stepstartnum} -le 4 ] && [ ${lv_stependnum} -ge 4 ]; then
    # Setup local step variables
    lv_step_name="regular_jobs"
    lv_step_log_file=${lv_log_path}/${lv_step_name}.log
    lv_step_eml_file=${lv_log_path}/${lv_step_name}.eml
    lv_shell_script="${lv_shell_path}/${lv_step_name}.sh"
    # Verify script file existence
    check_file_exist
    # Execute command
    ${lv_shell_script} "${lv_step_log_file}"
   # Append step log output to job log file
   cat ${lv_step_log_file} >> ${lv_job_log_file}
   # Execute varification function
   check_log
fi
The shell script could look like:
#!/bin/bash
sqlplus -s /nolog > "$1" 2>&1 <<EOT
set pages 0 feed off
whenever sqlerror exit failure;
connect username/password
exec Regular_jobs;
commit;
exit;
EOTYou might want to check other scripts to see if you need to set any environment variables like ORACLE_SID.

Similar Messages

  • How to call stored procedure from Pro*C

    How to call stored procedure from Pro*C ?
    my system spec is SuSE Linux 9.1, gcc version : 3.3.3, oracle : 10g
    my Pro*C code is the following..
    EXEC SQL EXECUTE
    begin
    test_procedure();
    end;
    END-EXEC;
    the test_procedure() has a simple update statement. and it works well in SQL Plus consol. but in Pro*C, there is a precompile error.
    will anybody help me what is the problem ??

    I'm in the process of moving C files (with embedded SQL, .PC files) from Unix to Linux. One program I was trying to compile had this piece of code that called an Oracle function (a standalone), which compiled on Unix, but gives errors on Linux:
    EXEC SQL EXECUTE
    BEGIN
    :r_stat := TESTSPEC.WEATHER_CHECK();
    END;
    END-EXEC;
    A call similar to this is in another .PC file which compiled on Linux with no problem. Here is what the ".lis" file had:
    Pro*C/C++: Release 10.2.0.1.0 - Production on Mon Jun 12 09:26:08 2006
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Error at line 193, column 5 in file weather_check.pc
    193 BEGIN
    193 ....1
    193 PCC-S-02346, PL/SQL found semantic errors
    Error at line 194, column 8 in file weather_check.pc
    194 :r_stat := TESTSPEC.WEATHER_CHECK();
    194 .......1
    194 PLS-S-00000, Statement ignored
    Error at line 194, column 18 in file weather_check.pc
    194 :r_stat := TESTSPEC.WEATHER_CHECK();
    194 .................1
    194 PLS-S-00201, identifier 'TESTSPEC.WEATHER_CHECK' must be declared
    Pro*C/C++: Release 10.2.0.1.0 - Production on Mon Jun 12 09:26:08 2006
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    System default option values taken from: /oracle_client/product/v10r2/precomp/ad
    min/pcscfg.cfg
    Error at line 194, column 18 in file weather_check.pc
    :r_stat := TESTSPEC.WEATHER_CHECK();
    .................1
    PLS-S-00201, identifier 'TESTSPEC.WEATHER_CHECK' must be declared
    Error at line 194, column 8 in file weather_check.pc
    :r_stat := TESTSPEC.WEATHER_CHECK();
    .......1
    PLS-S-00000, Statement ignored
    Semantic error at line 193, column 5, file weather_check.pc:
    BEGIN
    ....1
    PCC-S-02346, PL/SQL found semantic errors

  • How to call one procedure from another procedure

    Hi all,
    Could anyone give me clue how to call a procedure contains out parameters
    from another procedure.
    I had following procedures.
    1)
    create or replace procedure INS_PUR_ORDER
    p_poamt in number,
    p_podate in date,
    p_poid out number
    is
    begin
    select pkseq.nextval into p_poid from dual;
    insert into pur_order(poamt,podate,poid)
    values (p_poamt,p_podate,p_poid);
    end;
    2)
    create or replace procedure INS_PUR_ORDER_DETAIL
    p_pounits in number,
    p_poddate in date,
    p_poid in number)
    is
    begin
    Insert into pur_order_detail(podid,pounits,poddate,poid)
    values(pdseq.nextval,p_pounits,p_poddate,p_poid);
    end;
    I need to write a 3rd procedure which calls above two procedures.
    like
    call first procedure ,basing on the return value
    i.e if p_poid != 0 then
    we need to call second procedure
    in the loop.
    thanks in advance.
    rampa.

    Not sure what are you doing, you can not assign cursor to another cursor, may be you are looking for this?
    SQL> create or replace procedure proc1 ( result out sys_refcursor)
      2  is
      3  
      4  begin
      5     open result for
      6       select 'HELLO WORLD' from dual ;
      7  end proc1 ;
      8  /
    Procedure created.
    Elapsed: 00:00:00.01
    SQL> create or replace procedure proc2
      2  is
      3     l_cursor sys_refcursor ;
      4  begin
      5     l_cursor := proc1 ;
      6   
      7  
      8     open l_cursor;
      9     fetch l_cursor into l_text;
    10     dbms_output.put_line(l_text);
    11     close l_cursor;
    12  
    13  
    14  end proc2 ;
    15  /
    Warning: Procedure created with compilation errors.
    Elapsed: 00:00:00.01
    SQL> show error;
    Errors for PROCEDURE PROC2:
    LINE/COL ERROR
    5/4      PL/SQL: Statement ignored
    5/16     PLS-00306: wrong number or types of arguments
             in call to 'PROC1'
    6/4      PLS-00201: identifier 'L_TEXT' must be
             declared
    6/4      PL/SQL: Statement ignored
    8/4      PLS-00382: expression is of wrong type
    8/4      PL/SQL: SQL Statement ignored
    9/4      PL/SQL: SQL Statement ignored
    9/24     PLS-00201: identifier 'L_TEXT' must be
             declared
    10/4     PL/SQL: Statement ignored
    10/25    PLS-00201: identifier 'L_TEXT' must be
             declared
    ---- this is the correct waySQL>ed
      1  create or replace procedure proc2
      2  is
      3     l_cursor sys_refcursor ;
      4     l_text varchar2(100);
      5  begin
    ---- procedure call
      6     proc1(l_cursor); 
    7    -- open l_cursor;
      8     fetch l_cursor into l_text;
      9     dbms_output.put_line(l_text);
    10     close l_cursor;
    11* end proc2 ;
    SQL> /
    Procedure created.
    Elapsed: 00:00:00.01
    SQL> set serveroutput on
    SQL> execute proc2;
    HELLO WORLD
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL>

  • How to call a procedure from  Shell Script

    Friends,
    How can i call a procedure from a shell script ? If any one know the answer , let me know immediately .
    Thanks in advance .
    Chakks

    We connect using SQLPlus commands on the Unix server:-
    Our code block is below:- We've got DBMS_OUTPUT in the procedure, hence the spooling. You don't need all this, but you do need the sqlplus directory, etc... in your profile.
    sqlplus -s <<EOF > ${CREATE_LOG_FLE}
    $UserName/$Password@$SID
    SET SERVEROUTPUT ON SIZE 1000000;
    spool ${CREATE_LOG_FLE}
    EXECUTE $STORED_PROC(${Months}, ${DeleteRecords});
    EOF
    Hope that helps

  • How to call a procedure from within another procedure?

    What's the syntax to call a procedure from within a procedure.
    I have a procedure z(user_id IN number, ....)
    then
    procedure a (user_id IN number, ....)
    procedure b (user_id IN number, ....)
    procedure c (user_id IN number, ....)
    I want to call procedure a, b, c from inside procedure z.
    How would I do that?

    Same way :
    SCOTT@db102 SQL> create or replace procedure a (p1 in varchar2) is
      2  begin
      3     dbms_output.put_line (p1);
      4* end;
    SCOTT@db102 SQL> /
    Procedure created.
    SCOTT@db102 SQL> create or replace procedure z (par1 in number) is
      2  begin
      3     if par1 != 0 then
      4             a ('This is proc a');
      5     end if;
      6* end;
    SCOTT@db102 SQL> /
    Procedure created.
    SCOTT@db102 SQL> set serveroutput on
    SCOTT@db102 SQL> exec z (1);
    This is proc a
    PL/SQL procedure successfully completed.
    SCOTT@db102 SQL>                                                    

  • How to call stored procedures from EF 6.1.3

    Hi
    I need to create many reports and I wanna use SPs, with parameters, the question is how to use it from ntity Framework CodeFirst ? I am using EF 6.1.3
    I 've found examples using EF but not EF CF, any sample please ?
    thanks in advance
    Salu2 Sergio T

    You create a type to return and pass it as a type...
    Like this:
    http://stackoverflow.com/questions/20901419/how-to-call-stored-procedure-in-entity-framework-6-code-first
    context.Database.SqlQuery<YourEntityType>("storedProcedureName",params);
    ps
    That was pretty easy to google, by the way.
    And... it's not really wpf.
    Shrug.
    Hope that helps.
    Recent Technet articles: Property List Editing;
    Dynamic XAML

  • How to call a procedure from url

    hello,
    I'd like to call a procedure from the url. <br>
    I've tryed several ways to call that procedure, but none of it worked. <br><br>
    so can someone please tell me the correct syntax of such a call?<br>
    thanks in advance.

    Hi ,
    I have implemented this in one of my apps in the following way:
    - Created a database procedure (called download_file that accepts a parameter). This procedure opens a document stored in the database.
    - In a report region, in the Column Link attributes, I set the Link Text to "Download", set Target to "URL" and set URL to "#OWNER#.download_file?p_file=#MYFIELD#"
    Hope this helps.

  • How to call stored procedure from postgresql to jsp

    i'm using a jdeveloper.. and i'm a newbie of jsp.. i just wanna know how to call a stored procedure in jsp?... This is my function in postgres and i don't know how to call it in jsp...
    SELECT * from SP_1('2006-01-11') as ( company_code char(5), branch_category char(5), branch_code char(15), day_sales numeric(19,2), month_to_date numeric(19,2), no_of_transaction int8, month_to_date_py numeric(19,2), year_to_date numeric(19,2), year_to_date_py numeric(19,2), remarks text, time_reported text );

    hi again.. i'm using jsp in jdeveloper, i just wanna know how to declare double in jsp because my module is report and i need to get the average daily sales = 4500/ no. of transaction = 3. This is my code.. Where will i put the code in declaring the double and the average daily sales? Thanks in advance..
    <%@ page contentType="text/html;charset=windows-1252" import="java.sql.*,Connect.CRMCon"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>untitled</title>
    </head>
    <body>
    <%
    String ave = request.getParameter("ave_daily_sales");
    double cashsales = Double.parseDouble(ave);
    %>
    <%
    logparameters data = new logparameters();
    data.txtbox = request.getParameter("txtbox");
    %>
    <table cellspacing="3" cellpadding="2" border="1" width="100%">
    <tr>
    <td width="5%" bgcolor="#cccccc" height="29">
    <DIV align="center">Company Code</DIV>
    </td>
    <td width="4%" bgcolor="#cccccc" height="29">
    <DIV align="center">Branch Category</DIV>
    </td>
    <td width="6%" bgcolor="#cccccc" height="29">
    <DIV align="center">Branch Code</DIV>
    </td>
    <td width="8%" bgcolor="#cccccc" height="29">
    <DIV align="center">Day Sales</DIV>
    </td>
    <td width="9%" bgcolor="#cccccc" height="29">
    <DIV align="center">Month to Date</DIV>
    </td>
    <td width="5%" bgcolor="#cccccc" height="29">
    <DIV align="center">No.of Transaction</DIV>
    </td>
    <td width="9%" bgcolor="#cccccc" height="29">
    <DIV align="center">Month to Date(PY)</DIV>
    </td>
    <td width="9%" bgcolor="#cccccc" height="29">
    <DIV align="center">Ave.Daily Sales to Date</DIV>
    </td>
    <td width="9%" bgcolor="#cccccc" height="29">
    <DIV align="center">Year to Date</DIV>
    </td>
    <td width="9%" bgcolor="#cccccc" height="29">
    <DIV align="center">Year to Date(PY)</DIV>
    </td>
    <td width="9%" bgcolor="#cccccc" height="29">
    <DIV align="center">Remarks</DIV>
    </td>
    <td width="5%" bgcolor="#cccccc" height="29">
    <DIV align="center">Time Reported</DIV>
    </td>
    </tr>
    <%
    try
    CRMCon ccon = new CRMCon();
    Connection con = ccon.getConnection();
    String sql = "select * from sp_1('"+data.txtbox+"')";
    // String sql = "SELECT * from SP_1('"+ request.getParameter("data.txtbox")+"')" ;
    sql += " as (company_code char(5), branch_category char(5) ," ;
    sql += "branch_code char(15) , day_sales numeric(19,2)," ;
    sql += "month_to_date numeric(19,2), no_of_transaction int8," ;
    sql += "month_to_date_py numeric(19,2), year_to_date numeric(19,2)," ;
    sql += "year_to_date_py numeric(19,2), remarks text, time_reported text) " ;
    //out.println(sql);
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery(sql);
    while (rs.next())
    %>
    <tr>
    <td width="13%"> <%= rs.getString("company_code") %> </td>
    <td width="63%"> <%= rs.getString("branch_category") %> </td>
    <td width="24%"> <%= rs.getString("branch_code") %> </td>
    <td width="24%"> <%= rs.getString("day_sales") %> </td>
    <td width="24%"> <%= rs.getString("month_to_date") %> </td>
    <td width="24%"> <%= rs.getString("no_of_transaction") %> </td>
    <td width="24%"> <%= rs.getString("month_to_date_py") %> </td>
    <td width="24%"> <%= rs.getString("year_to_date") %> </td>
    <td width="24%"> <%= rs.getString("year_to_date_py") %> </td>
    <td width="24%"> <%= rs.getString("remarks") %> </td>
    <td width="24%"> <%= rs.getString("time_reported") %> </td>
    </tr>
    <%
    catch (Exception ex)
    out.println("Error:"+ex.getMessage());
    %>
    </table>
    </body>
    </html>
    <%!
    class logparameters
    public String txtbox;
    %>

  • How to call stored procedures from java program?

    I have tried to run a program that calls a stored procedure on MySQL
    server version 5.0.17 by using connector/j 5.0, but it always fails on the
    statement: con.preparecall() ,
    have looked on the internet and found out that people can all mysql
    stored procedure all right in their programs, really dont know what's
    wrong with this small peiece of code:
    import java.sql.*;
    public class TestDB {
          // procedure being called is:
         CREATE PROCEDURE `dbsaystorm`.`getsite` ()
         BEGIN
            select  name  from tblsite;
         END
         public static void main(String[] args) {
              try  {
                  //Class.forName("org.gjt.mm.mysql.Driver");
                  Class.forName("com.mysql.jdbc.Driver");
                  Connection con = DriverManager.getConnection("jdbc:mysql://localhost/dbname",
                            "user", "pwd");
           * executing SQL statement here gives perfect correct results:
            // PreparedStatement ps = con.prepareStatement("select name from tblsite");      
            // ResultSet rs =ps.executeQuery();
                  // but in stored procedure way...
                  //it fails here on this prepare call statement:             
                  CallableStatement proc = con.prepareCall("call getsite()");
                  ResultSet rs =proc.executeQuery();                      
                  if (rs == null) return;                                      
                  while (rs.next()){                 
                      System.out.println("site name is: "+ rs.getString(1));                                
                  rs.close();
              } catch (SQLException e) {e.printStackTrace();}
               catch (Exception e) {e.printStackTrace();}         
    }it always gives this exception:
    java.lang.NullPointerException
         at com.mysql.jdbc.StringUtils.indexOfIgnoreCaseRespectQuotes(StringUtils.java:959)
         at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1280)
         at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:3668)
         at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:638)
         at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:453)
         at com.mysql.jdbc.Connection.parseCallableStatement(Connection.java:4365)
         at com.mysql.jdbc.Connection.prepareCall(Connection.java:4439)
         at com.mysql.jdbc.Connection.prepareCall(Connection.java:4413)
         at saystorm.server.data.database.TestDB.main(TestDB.java:29)
    where have I gone wrong?
    when I commented out the statement that makes the procedure call and call preparedstatement to execute SQL select statement, it gave perfectly correct result.
    it looks like there is no problem with java prog accessing MYSQL server database, but the it seems that it's just java can't call stored procedure stored on the mysql server version 5.
    can it or can't it? if it can, how is that accomplished?

    It is a bug in the driver because it shouldn't be
    returning that exception (null pointer) even if you
    are doing something wrong.
    Are you using the latest version of the driver?
    The stored procedure runs when you run it from the
    gui/command line using a MySQL tool - correct?
    As suggested you should be using the brackets. What
    is the data type of the 'name' field?
    You could try returning another value like one of the
    following
    select 1, name from tblsite;
    select name, 1 from tblsite;
    That might get around the bug
    Additionally try just the following...
    select 'test' from tblsite;yes, the driver used is in connector/j 5.0--the lastest one, and the
    procedure can run correctedly at either command line or GUI mode
    with no problem whatsoever, the returned data type is string type,
    I have not got the chance to test it again with those values you
    suggested, as I have abandoned the laptop I used to write that code
    initately. There have been some other really weird cases happened on
    that computer. I guess that must be something wrong with the JVM
    installed on it, it was upgraded from jre5.0.04 to 06, and to 09.
    something within hte JVM must have been messed up(the only reasonable
    explanation). Because the same code runs correctly on my new laptop,
    using the same environment: jvm 5.0_09, mysql 5.0.18, connector/J 5.0.
    that old laptop really was a nightmare.

  • Need urgent help - how to call a procedure from sql returning a rowset

    Hello,
    I need to send a SQL Query from a VB application to let it execute on the oracle DB. This query needs to call a procedure/function, which returns a resultsets, so that i can to a (Where x in ( <call procedure> )). Would result in Where x in (50,100,3094).
    Is this possible in oracle, and how?
    Thanks.
    Daniel Meyer

    Hi Daniel,
    I had a similiar problem yesterday.
    Thanks to the nice people in this forum I was able to figured that out.
    So here is a PL/SQL Oracle 9i code for your reference.
    You can create and test it using the SQL Plus console.
    I used this stored procedure in my VB .NET and worked fine!
    I am enclosing the VB code in this reply as well.
    One last note: in order to test it in the VS .NET, don't forget to download the Oracle ODP driver for .NET
    Good luck!
    Amintas
    create or replace package pkg_emp
    AS
    type rc_emp is ref cursor;
    end;
    create or replace
    procedure SP_GetEmpData(v_empno IN emp.empno%Type,
    v_ename IN emp.ename%Type,
    emp_cur OUT pkg_emp.rc_emp)
    is
    begin
    if v_empno is not null and v_ename is null then
    OPEN emp_cur for
    select empno,ename,sal
    from emp
    where empno=v_empno;
    elsif v_ename is not null and v_empno is null then
    OPEN emp_cur for
    select empno,ename,sal
    from emp
    where ename like v_ename ||'%';
    end if;
    end;
    /* Testing the stored procedure */
    /*#1 */
    var myresultset refcursor;
    execute SP_GetEmpData(7900,null,:myresultset);
    print myresultset;
    /*#2 */
    var myresultset refcursor;
    execute SP_GetEmpData(null,'A',:myresultset);
    print myresultset;
    -x-x-x-x-x-x-x-x-x VB .NET CODE x-x-x-x-x-x-x-xx-x-
    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcurar.Click
    Dim dr As Oracle.DataAccess.Client.OracleDataReader
    Try
    If txtEmpNo.Text <> "" Then
    dr = GetData(CInt(Val(txtEmpNo.Text)), "")
    Else
    dr = GetData(0, UCase(txtEname.Text))
    End If
    txtEmpNo.Text = ""
    txtEname.Text = ""
    Catch ex As Exception
    Response.Write(ex)
    End Try
    drgTest.DataSource = dr
    drgTest.DataBind()
    End Sub
    Private Function GetData(ByVal v_empno As Integer, ByVal v_ename As String) As Oracle.DataAccess.Client.OracleDataReader
    Dim cn As New Oracle.DataAccess.Client.OracleConnection(ConfigurationSettings.AppSettings("ConnectionString"))
    Dim cmd As New Oracle.DataAccess.Client.OracleCommand
    Dim dr As Oracle.DataAccess.Client.OracleDataReader
    cmd.Connection = cn
    cmd.CommandType = CommandType.StoredProcedure
    cmd.CommandText = "SP_GetEmpData"
    cmd.Parameters.Add("v_empno", Oracle.DataAccess.Client.OracleDbType.Int32).Value = IIf(v_empno = 0, System.DBNull.Value, v_empno)
    cmd.Parameters.Add("v_ename", Oracle.DataAccess.Client.OracleDbType.Varchar2, 40).Value = IIf(v_ename = "", System.DBNull.Value, v_ename)
    cmd.Parameters.Add("rc_emp", Oracle.DataAccess.Client.OracleDbType.RefCursor).Direction = ParameterDirection.Output
    Try
    cn.Open()
    dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
    Catch ex As Exception
    Throw ex
    Exit Function
    End Try
    Return dr
    End Function

  • How to call store procedure from an oci program

    Hello,
    I work on Oracle 8.1.7 under AIX.
    I must call from an OCI C++ program a store procedure that have an result set as param out.
    I'm not sure how can I call the procedure/function. I want to execute this statement and fetch the results.:
    " CALL Department.get_all (:1) " is this OK?
    " Call department.GetAll() into :1 "
    I have seen some example from an PL/SQL block but that's not ok for me.
    what i have done:
    i have created an package
    create or replace package department as
    type cursor_type is ref cursor;
    procedure get_emp( i_deptno in number, rs out cursor_type );
    procedure get_all( rs out cursor_type );
    function GetAll return cursor_type;
    end department;
    create or replace package body department as
    procedure get_emp ( i_deptno in number, rs out cursor_type )
    as
    begin
    open rs for
    select empno, ename
    from emp
    where deptno = i_deptno;
    end;
    procedure get_all ( rs out cursor_type )
    as
    begin
    open rs for
    select empno, ename
    from emp;
    end;
    function GetAll return cursor_type
    as
    l_cursor cursor_type;
    begin
    open l_cursor for select ename, empno from emp;
    return l_cursor;
    end;
    end;

    Hi,
    I am new to OCI facing the same problem you have mentioned, If you have found out how to solve it , can you post the answer for the same.
    Thanks
    Mani

  • How to call a procedure from database executing commandButton...

    Hello.
    I´m using Jdev 10.1.3.2, I´d like to know how can I execute a procedure from database when I click a command button..??
    is that possible?
    thanks again.

    Yes, it's possible.
    Since you don't say anything about technologies you are using, I will assume ADF Business Components and JSF.
    You can write a service method in your application module - see Section 25.5 of the ADF Developer's Guide for Forms/4GL Developers
    Then, you can drag-and-drop the service method from the data control palette on to your JSF page and select ADF Command Button when you drop.
    You will, in all likelyhood, find numerous examples when you search the forum as well.
    John

  • How to call stored procedure from javascript? (about Google Suggest, AJAX)

    Hi I want to implement a text field so that it behaves like [Google Suggest|http://www.google.com/webhp?complete=1&hl=en] .
    I read this post .
    Now I've setup everything according to that document. But it just doesn't work. And I don't know why.
    I think problems may fall into the following three categories:
    1. Does the text field and the page invoke the proper javascript?
    2. Does the javascript successfully call the stored procedure?
    3. Can the stored procedure correctly return the formatted result?
    I am affirmative for 1 and 3, but I'm not sure about 2. Because I don't know how to tell if a stored procedure has been called? Is there a PL/SQL statement that I can query in SQL*Plus?
    Also, I would to know how to debug AJAX in APEX. It involves many things.
    Last, I used APEX 3.2 and Oracle XE. I cannot find either dads.conf or marvel.conf file. Is "/apex/" the virtual directory for APEX?
    Thanks a lot!

    Hello,
    I recently also ran into problems with this and I will post my solution here:
    1) if you need to pass parameters to your procedure, create it using "Flexible Parameter Passing". Then parse the parameters out of the array and put them in local variables inside your PL/SQL procedure.
    Example:
    CREATE OR REPLACE PROCEDURE MATTHIASH.incsearch(name_array IN owa.vc_arr,
         value_array IN owa.vc_arr) as
      l_List1 varchar2(4000);
      l_List2 varchar2(4000);
      l_query varchar2(255);
      l_separator varchar2(10) default '';
      qu varchar2(4000) default '';
      hl varchar2(4000) default '';
    BEGIN
      FOR i IN 1 .. name_array.COUNT 
      LOOP
           IF name_array(i) = 'qu' THEN
                qu := value_array(i);
           ELSIF name_array(i) = 'hl' THEN
                hl := value_array(i);
           END IF;
      END LOOP;
      l_query := qu||'%';
      FOR x IN (
      select object_name, object_id from user_objects
      where upper(object_name) like upper(l_query) and upper(object_type) = upper(hl) order by 1 asc)
      LOOP
        l_list1 := l_List1 || l_separator || '"' || x.object_name || '"';
        l_list2 := l_List2 || l_separator || '"' || x.object_id || '"';
        l_separator := ',';
      END LOOP;
      owa_util.mime_header('text/html', false);
      owa_util.http_header_close;
      --htp.p('sendRPCDone(frameElement, "'|| qu ||'", new Array(' || l_List1 || '), new Array(' || l_List2 || '), new Array(""));');
      htp.p('sendRPCDone(frameElement, "' || qu || '", new Array(' || l_List1 || '), new Array(' || l_List2 || '), new Array(""));');
    END;
    /2) grant EXECUTE rights to APEX_PUBLIC_USER (the user APEX uses to connect to the database) on the procedure
    grant execute on incsearch to apex_public_user;3) upload the ac.js file as static file to your application
    4) put the following javascript code in the HTML Header of your APEX page:
    <script src="#WORKSPACE_IMAGES#ac.js" type="text/javascript"></script>
    <script language="JavaScript" type="text/javascript">
    function iac()
    InstallAC(document.wwv_flow,document.getElementById('P1_X'),"","!MATTHIASH.incsearch","&P1_OBJECT_TYPE.");
    </script>In my example, P1_X is a text field and P1_OBJECT_TYPE is a dropdown list with all user object types.
    Good luck,
    Matthias Hoys

  • How to Call a Procedure from SQL ?

    Hi All,
    I've a procedure defined like the below taking IN/OUT parameters as table type.
    PROCEDURE "SAP_HANA_DEMO"."usersCreateMethod" (IN row "SAP_HANA_DEMO"."User.Details",
    OUT error "SAP_HANA_DEMO"."EPM.Procedures.tt_errors")
    Now, how do i call it from SQL ?
    I'm trying to call it like
    CALL "SAP_HANA_DEMO"."usersCreateMethod"('my_global_table','?');
    It says
    Could not execute 'CALL "SAP_HANA_DEMO"."sap.hana.democontent.epm.Procedures::usersCreateMethod"('my_global_table','?')'
    SAP DBTech JDBC: [1288]: expression cannot be used as an assignment target: '?': line 1 col 97 (at pos 96)
    Thanks & Regards
    Sakthivel

    Hi ,
    You should call like this
    Define a variable of your table type.
    Define ErrorMessage SAP_HANA_DEMO"."EPM.Procedures.tt_errors"
    CALL "SAP_HANA_DEMO"."usersCreateMethod"('my_global_table',ErrorMessage);
    Regards,
    Krishna Tangudu

  • How to call oracle procedure from vb

    i created a procedure in oracle8.1.7 to return on value,look the following script:
    Procedure P_COUNT (r out number)
    IS
    BEGIN
    select count(*) into r from demo;
    END;
    but i can get the value from VB,i display some errors:
    ORA-06502 PL/SQL: numeric or value errorstring
    ORA-06512 at stringline string
    what can i do now?
    null

    Hei Zhang,
    Thank You. You can return Cursor in many ways. You can write either a function to return cursor (return type is %ROWTYPE) or a package. Writing a Package seems laborious but I like it as it has lot of flexibility.
    I will give you the example for the second type:
    -- 1) Create a Package first:
    CREATE OR REPLACE PACKAGE pk_MyPackage AS Type RT1 IS RECORD (
    sp_ename emp.ename%TYPE,
    sp_job emp.job%TYPE,
    sp_mgr emp.mgr%TYPE
    TYPE RCT1 IS REF CURSOR RETURN RT1;
    END;
    sho err
    -- 2) Create a Procedure:
    CREATE OR REPLACE PROCEDURE sp_MyProcedure (
    in_empno emp.empno%TYPE,
    RC1 IN OUT pk_MyPackage.RCT1
    ) AS
    BEGIN
    OPEN RC1 FOR
    SELECT ename,
    job,
    mgr
    FROM emp
    WHERE empno = in_empno;
    RETURN;
    END;
    sho err
    --Testing
    SQL> var cr refcursor
    SQL> exec sp_MyProcedure (7934, :cr)
    PL/SQL procedure successfully completed.
    SQL> print cr
    ENAME JOB MGR
    MILLER CLERK 7782
    Hope this is clear and helps you to complete your task.
    Cheers!
    r@m@

Maybe you are looking for

  • Ipod touch 3rd Gen Still Making G4 Crash

    I thought we had corrected this issue but it has not been corrected. Have a G4 Mac 733 Mhz running 10.4.11 When Ipod Touch 3rd Gen is plugged into usb hub that is separately powered by its own brick the computer locks up. Everything just freezes up..

  • Music is silent in iMovie but not in clip trimmer

    In two of my iMovie projects the music is silent. The project music plays when clip trimmer is open, however, and the audio skimming bar flash green. When I close clip trimmer, the audio skimming bars go black. I may have hit keys for a command - how

  • No CD, can't change admin login and password???

    Hi...Please help. I do not have a startup disk and cannot change the aministrator login and password...what do I do?

  • How to get Activities in order ?

    I want to display all the activities associated with an item type to the user. I can get it from wf_activities_vl view. All these activities, I want to display in the same order, which they were defined in the process model. How can I get the order f

  • Exporting an already-rendered Sequence causes serious error.

    Several times, I have tried clicking File->Export->Media, and suddenly adobe premiere pro would tell me that a serious error has occurred and then the program closes. This was during a 1280 x 1024 square pixel resolution video. I have not tested any