Set Null as Default  for input parameter to a stored procedure

hi ,
How can we set default values as NULL to an input parameter in a stored Procedure.
create or replace procedure emp_proc ( p_test_input in varchar2
                                                    p_emp_id in number,
                                                    p_emp_name in varchar2,
                                                   p_manager_id in number )
as
  begin
   if ( upper ( p_test_input ) = 'I' )
   then
      insert into emp
      values      ( p_emp_id  ,p_emp_name ,p_Manager_id,sysdate );
   elsif ( upper ( p_test_input ) = 'D' )
   then
      delete from emp
      where       emp_id  = p_emp_id;
   else
      dbms_output.put_line
         ( 'Please input ''A'' for ADD or ''D'' Delete  EMPLOYEE'
   end if;
end;As Shown above if i want to do only delete operation
i want to call this procedure like without passing extra parameters .
EXECUTE  emp_proc('D',1010);Edited by: Rede on May 28, 2010 12:21 PM
Edited by: Rede on May 28, 2010 12:22 PM

create or replace procedure emp_proc ( p_test_input in varchar2,
                                                    p_emp_id in number,
                                                    p_emp_name in varchar2 default null,
                                                   p_manager_id in number default null )

Similar Messages

  • Multiple values as default for input parameter

    Hi,
    As per one requirement, I have to create a input parameter with default values (having multiple default values).
    Any suggestions are much appreciated.
    Regards,
    Saurabh

    create or replace procedure emp_proc ( p_test_input in varchar2,
                                                        p_emp_id in number,
                                                        p_emp_name in varchar2 default null,
                                                       p_manager_id in number default null )

  • Pass a datarow as input parameter in a stored procedure

    Hi everyone!
    I wonder if anyone know how to pass a datarow (better if tipized like "tablenameRow") as input parameter for a stored procedure.
    links or suggestions are welcome! (i'm newbie in .net programming, so if you can post some code i'll be really grateful!)
    Thank you!

    Hi,
    YES!! its possible you can pass a datarow to a SP from your Dot net application.
    Here below i'm going to give you an example for Desktop Application.
    For Passing a datarow as Input Parameters, your SP need to support for all these parameters.
    I mean, if a data row has 03 Columns. Then your procedure should be able to take 03 arguments/parameters.
    --Adjust code according to your need.
    --Its for C# Desktop application.
    --Visual Studio Professional, Framework (2.0)
    //Setting connections.
    OracleConnection con=new OracleConnection("Data Source=orcl9i; user id=scott; password=tiger");
    OracleComand cmd=new OracleCommand(con);
    cmd.Type=CommandType.StoredProcedure; //you are useing SP
    cmd.Text="my_stored_procedure"; //Mention SP name.
    --if DataRow has Three columns. You need three parameters.
    OracleParameter p1=new OracleParameter ();//By default parameters are input parameters.
    OracleParameter p2=new OracleParameter ();
    OracleParameter p3=new OracleParameter ();
    //We assume that Datarow already has data in it.
    p1.ParametersName="sp_var1 ";
    p1.OracleDbType=OracleDbType.Varchar;
    p1.Value=tablenameRow[1]; //Here DataRow object's Column1 is input.
    p2.ParametersName="sp_var2 ";
    p2.OracleDbType=OracleDbType.Varchar;
    p2.Value=tablenameRow[2]; //Here DataRow object's Column2 is input.
    p3.ParametersName="sp_var3 ";
    p3.OracleDbType=OracleDbType.Varchar;
    p3.Value=tablenameRow[3]; //Here DataRow object's Column3 is input.
    cmd.OracleParameter.Add(p1); //Add parameters.
    cmd.OracleParameter.Add(p2); //Add parameters.
    cmd.OracleParameter.Add(p3); //Add parameters.
    cmd.ExecuteNonQuery(); //Execute Procedure here.
    Feel free to ask if still found problem.
    ....

  • Ignoring blank input parameter in a stored procedure

    I'm trying to write a SP that ignores a blank parameter in a
    where clause like this.
    create procedure blah @myvar int AS
    select * from companies
    where 1 = 1
    if @myvar is <> ''
    and id = @myvar
    This seems like a simple task but it doesn't work. Thanks in
    advance

    Assuming SQL Server, you might try something like this:
    SELECT *
    FROM companies
    WHERE id = ISNULL(@myvar, id)
    If your @myvar parameter is NULL, then your WHERE clause is
    basically
    id = id, which makes it a "don't care" condition and returns
    all rows as if there was no where clause. You can add other
    parameters to your where clause, and they would not be affected, as
    this condition would only restrict the selection if @myvar was not
    null, otherwise it is "ignored".
    Phil

  • BIP & trying to auto-set the current date for a parameter

    I'm trying to allow for a date selector as a parameter for one of my reports. This is BIP 11.1.1.5.
    I've set up a field for the parameter and can pass it into the report but want to see if I can auto-fill this field with today's date, and then set the Date From to today and the Date To to 3 days from now. Is this possible? Is there a way to do something like "format-date:sysdate('MM/dd/YYYY');" in these fields? I've attached an image of my fields in my Data Model.
    My image - http://goo.gl/mcXS7
    Thanks.
    Edited by: thejame on Jun 7, 2011 9:38 AM

    Thank You! I came across this before but never saw you have to use the {$ to get to the value.
    {$SYSDATE()$} gets me today's date.
    So can I use these in the BIP's Query Builder or other areas where I want to populate fields?
    Example: I want to use it in the actual report's parameters but it just comes across as "{$SYSDATE()$}"

  • How to pass parameter from 1 stored procedure to another stored procedure inside crystal report

    Hi
    I have several stored procedure in my Crystal Report. I am wondering if it is possible for me to pass a parameter to one of the stored procedure and to use the result of that stored procedure E.g. CustomerCode. To another 2 stored procedure to generate the report dynamically?
    I have 3 stored procedure
    The 1st one is used to gather information and process the calculation
    another 2 stored procedure is used for generate the graph and both of them required to take 2 parameters. The 1st stored procedure will require 1 parameter (E.G. Reference Code) and will return a set of information including the data that could be use on the other 2 stored procedures.
    After I added these 2 stored procedure, it requires me to pass 3 parameters to the report. I would like to know if I could only pass the Reference Code for stored procedure 1 and use it to retrieve the information for the other 2 parameter?
    Thanks in advance
    Chi

    Hi Chi
    To pass parameter from 1 stored procedure to another stored procedure, you will have to create sub report. In your case you will have to create 2 sub reports for 2nd and 3rd stored procedure and link those sub reports with the main report using Reference Code field in order to pass the values.
    After creating the report when you will refresh the report, it will ask 4 parameters, one parameter for main report, one for the first subreport and two for second subreport to fetch the data correctly.
    Regards
    Poonam Thorat.

  • How to pass a table as parameter on a stored procedure

    Hello all,
    I want to pass the name of a table as parameter into a stored procedure, that will be used for cursors etc.
    But when i pass the parameter and i compile the S.P. it give me error (error: table not existing...)
    Any Help?
    Thanks in advance, Marco

    Marco wrote:
    As i've written above, i'm using stored procedures like 'batch' programs which will be executed with oracle scheduler (passing to s.p. the name of the 'input' tables)
    These input tables are 'external' tables which have got the same structure; for example i've got TABLEX_001, TABLEX_002, XXTAB etc. with the same structure.
    This is the the reason... what do you think?An external table definition can reference multiple files via the LOCATION definition or you can user "ALTER TABLE" to alter the location and change the file that the external table points to.
    Thus you only need one static External Table and use an alter table (via execute immediate) to change the file location it points to, or if you want all the data together, just specify all the files in the location.
    That would be clean design, using one fixed table, without the need to pass any table names, just dynamically altering the file names if necessary at run time.

  • How to pass the parameter of a stored procedure to iReport

    Hi... i don't know how to pass the parameter of the stored procedure to the iReport.
    In the Report Query, i tried
    1. sp_storedprocedure ' value'
    2. sp_storedprocedure +''''+$P{parameter}+''''+
    3. sp_storedprocedure +$V+$P{parameter}++$F($F is a variable having a value of ' (a single quote))may you enlighten us please? thank you

    For M$ SQL server I find that it only works when U use the fully qualified name...
    e.g. catalod.dbo.my_procedure_name 'variable'
    My full query in the Report Query window is something like this:
    EXEC arc.dbo.jasper_Invoice 1000
    Note that you may find that selecting from VIEWS / TABLES fails for no apparent reason and iReport will prompt you with the usual very unhelpful (we have what we "pay" for) prompt, stating that "The document is empty".
    To work around this issue, where a statement like "SELECT * FROM arc.dbo.acc_invoices WHERE Invoice_id=1000" does not work, simply create a PROC, something like:
    CREATE PROC jasper_MyProc (@my_rec_id integer) AS
    SELECT * FROM arc.dbo.acc_invoices WHERE Invoice_id= @my_rec_id integer
    ...to wrap your SELECT statement, then call the PROC
    Edited by: Sylinsr on Apr 22, 2008 4:23 PM

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • Would like to pass multi-value parameter to a stored procedure

    Hi,
    Is it possible to pass a multi-value parameter to a stored procedure using crystal reports.
    Is there is a way to do so??/
    Thanks,
    Brian.

    Hi,
    Is it that you want to pass 2 or more parameters to a stored proc. it is possible
    go to database expert
    select your connection and click on add command their you will have to create parameters and pass to a proc
    for ref..
    {CALL `menagerie`.`sp_timer`({?delay time},{?delay time2})}
    where `menagerie`.`sp_timer` is a stored proc.
    and delay time and delay time2 are  parameters.
    but if it is like you have to pass multiple values to stored proc using single parameter as per my experience its
    not possible.

  • Problem in OUT Parameter in the stored procedure

    Hi,
    I have a problem in the OUT parameter of the stored procedure under the package. I encountered the error PLS-00306. Below are the codes.
    Package
    CREATE OR REPLACE package body test as
         procedure sp_countries(rst OUT country_typ) as
         sql_stmt VARCHAR2(300);
         begin
         sql_stmt := 'SELECT * FROM countries WHERE region_id = 1';
         OPEN rst FOR sql_stmt;     
         end;
    end test;
    by the way. i declared the country_typ as this:
    TYPE country_typ IS REF CURSOR;
    Here is the code that will call this package:
    declare
    tst countries%ROWTYPE;
    begin
    test.sp_countries(tst);
    dbms_output.put_line(tst.country_name);
    end;

    Works for me. Although I had to use emp instead of your table:
    SQL> create or replace
      2  package test as
      3     TYPE country_typ IS REF CURSOR;
      4     procedure sp_countries(rst OUT country_typ);
      5  end;
      6  /
    Package created.
    SQL> CREATE OR REPLACE
      2  package body test as
      3     procedure sp_countries(rst OUT country_typ) as
      4        sql_stmt VARCHAR2(300);
      5     begin
      6        sql_stmt := 'SELECT * FROM emp WHERE deptno = 20';
      7        OPEN rst FOR sql_stmt;
      8     end;
      9  end test;
    10  /
    Package body created.
    SQL> var tcur refcursor
    SQL> exec test.sp_countries(:tcur);
    PL/SQL procedure successfully completed.
    SQL> print tcur
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    SQL>

  • Passing Multi-Value Parameter to a Stored Procedure

    Has anyone experienced passing a Parameter (MultiValue) to a Stored Procedure? I am aware that Crystal Passes the Param as an Array. How would you go about handling this within a Stored Procedure???

    Hi Daniel
    Try as below:
    1. Create a Crystal report, and add a multi-value parameter.
    2. Since the multi-value parameter is treated as an array, create a formula that uses the JOIN function. Create a formula as below:
    //Formula: @JoinFormula
    Join ({?Multi-value parameter array},";")
    ====================
    NOTE:
    In the formula above, a semi-colon (";") is the delimiter.
    ====================
    3. Within the main report, create a subreport based on the stored procedure, and include the parameter to be populated with the multi-value list.
    4. Link the Join formula in the main report to the stored procedure parameter in the subreport.
    Doing so passes a multi-value parameter to the stored procedure.
    Hope this helps!!!!
    Regards
    Sourashree

  • Set max length for input parameter in SSRS

    I have an input parameter (@year)   to display a simple report. This input parameter taken Year from user (ex: 2015) manually. Here my problem is to restrict the user to max length of
    4. It should allow only (ex:2015) not (ex:20155) like that. Can any one please suggest me how to do this. 

    Hi SaikumarN,
    According to your description, you want to restrict the length of values which user type in the parameter box.
    In Reporting Services, it’s not supported to limit the length of the typed value in the parameter box currently. For your requirement, you could provide Microsoft a feature request at
    https://connect.microsoft.com/SQLServer, so that we can try to modify and expand the product features based on your needs.
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • Is it possible to pass a null Input Oracle parameter to a stored procedure

    I have a stored procedure that take 3 inputs and gives 1 output.I'm using Oracle parameter to add all 3 input parameters as follows :
    OracleParameter inobj = cmd.Parameters.Add("wid", OracleDbType.Int32,50);
    inobj.Direction = ParameterDirection.Input;
    inobj.Value = _employeeID;
    and added the output parameter as follows:
    OracleParameter outobj = _cmd.Parameters.Add("w_first", OracleDbType.Varchar2, 50);
    outobj.Direction = ParameterDirection.Output;
    On the UI end , the user has a choice to provide 1 input or all inputs or any 2 inputs based on his interest. Stored Proc looks as follows:
    SP( inp1 in parameter, inp2 in parameter, inp3 in parameter, output1 out parameter)
    If i just get 1 input or 2 inputs from the user, is it fine to query the data for output using same stored procedure or should i have individual stored procedures for each scenario(combination of different inputs)?
    Will i get any pl/sql error that says invalid number of arguements?

    This means if i have 1 input , i need to have a different method to pass 1 parameter value and other input parameters as null and if there are 2 inputs will need different method to handle. So 5 different methods all together?
    What if the stored procedure is as follows ,will its make things easier so that only one method is used for all scenarios?(optional parameters is set default value as null in the stored proc)
    Create or Replace
    Procedure GetFoo
    (cur_z OUT sys_refcursor,
    pub_date IN varchar2,
    fname IN varchar2 default null,
    lname IN varchar2 default null,
    phone IN varchar2 default null
    IS
    BEGIN
    ---get some data
    END;
    *actually i can test this but, all the database servers are down today. So, i need to have idea if this thing works before i confirm with someone. Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Custom UI or editor for input-parameter

    I think I need to implement a custom UI editor for an input-paramenter.  My input parameter is really a HashTable. I'd like to present a dialog that allows the user to enter any number of key value pairs.  The optional "editor" element  looks promising because it allows you to specify a ui-component.  I have searched and searched for sample code, but haven't found any.  Would some kind soul please point me to a resource that shows how to implement such as custom UI (whether it involves the "editor" element or not)?
    Here's a link to the ui-component element in the reference:
    http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/wwhelp/wwhimpl/js/html/w whelp.htm?href=000959.html#1548965&accessible=true
    Thanks,
    Halynn

    I appreciate the reply.
    I was actually trying to point to another page, although that page may be applicable.  Apparently the URL in my browser window was not sufficient to recreate my state in livedocs.  I was looking at the reference for component.xml, specifically where it describes an optional <editor> element of <input-parameter>.  This <editor> component also has a child called <ui-component>.  I haven't found any sample code that uses these two elements.
    I need to call my component with a Map or Hashtable (an arbitrary set of Key/Value String pairs).  This Map needs to be easily configurable in LiveCycle Workbench.  I've seen numerous operations that popup dialogs for input-parameters and serialize their data.  I was thinking that I will have to implement my own dialog.
    It sounds like you are suggesting I can achieve this with a variable and the set value service.  I don't quite understand.  How would I insert the string pairs?
    Thanks,
    Halynn

Maybe you are looking for

  • How to upload a data using BAPI_SALESORDER_CREATEFROMDAT2 without using LSM

    Hi,        I want to upload a data from an input file on the presentation server using BAPI_SALESORDER_CREATEFROMDAT2 first uploading the data and then creating sales orders out of it.        I will be highly obliged if anyone can guide me with it.  

  • Oracle 9i database monitoring scripts

    Hi Friends, I am asked by my boss to submit weekly reports about the database status. She wanted something in excel format. Can you suggest me what reports do I submit? I found the following monitoring scripts from google: Are these scripts still rel

  • Firefox segfaults with Flash content. x64. [Solved]

    I'm running 64 bit Arch version 2010.05 and I installed flashplugin. When I navigate to a Flash website Firefox segfaults. It also happens on other pages such as Gmail. Chromium doesn't segfaults with Flash or any other page but Flash doesn't work ei

  • JMS MessageBridge Problem ??

              Hello,           We are using WLS 7.0. We 've set up the WLS Message Bridge to communicate between           MQ and WLS JMS queues. The MQSeries JNDI objects are created in WLS JNDI using           a startup class. There are 2 Queues on the

  • My iPad keeps asking me to sign into iCloud

    but when I go to sign out of the iCloud in settings it says my password is incorrect. How does that work? When it has allowed me to sign into iCloud on the same device using my actual password. ANd how do I stop my iPad continually asking me to sign