Pls help me to complete a simple stored prcedure!

Hi,
This is the DDL and the procedure I created.
Create table students
(id int, name varchar (20),score int,[status] varchar(10))
insert into students values (1001,'sachin',100,'pass')
insert into students values (1002,'Dravid',90,'pass')
insert into students values (1003,'Dhoni',30,'fail')
insert into students values (1004,'Kohli',29,'fail')
---Select * from students
create proc uspgetstudents (
@id int, @status varchar(10)) as
begin
select * from students where id=@id and [status]=@status
end
The procedure is just partially correct and I would need your help to complete this.
This procedure is used by .Net. When they pass the  parameters ID and status, it should retrieve the particular Id and status (the above procedure works fine). Now,My requirement is when they don't pass any parameters, it should retrieve
everything. Ie) Select * from students (like without the filters).
Can you please help me how to do this?

vskindia,
You can achieve that by passing NULL values to the procedure (you can also have NULL as default) and use the proc as below:
create proc uspgetstudents
(@id int=NULL, @status varchar(10)=NULL) --by default NULL if value not passed
as
begin
select *
from students
where id=ISNULL(@id,id) and [status]=ISNULL(@status,status) --when NULL take the column value as it is
end
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

Similar Messages

  • Pls help!  Creating a new simple jsp iView...

    Hi, I would like to create a totally new iView JSP project from scratch.  I currently have NetWeaver and EP 6.0.  This is what I have done so far on NetWeaver: <b>File > New > Project > Select Portal Application > click 'Next' > Type in Project name and root folder > click 'FINISH'</b>.  Now, I think I have a project ready?  I have some basic iView JSP code already.   so now can someone provide me with detailed steps on what modifications and steps I need to make on my new project in order for my iView jsp to display on the EP 6.0?  Any files like 'portalapp.xml' that I have to modify?
    Thank you so much for your help,
    Baggett.
    What I know so far: I have looked at an example where I created one using an existing par.  I know how to export .par file to EP 6.0, it's the steps before that I don't know.  Thanks again.

    Hi, I think I found a little solution to my problem but now I have a new issue.  I think I "solved" my problem by doing:  <b>File > New > Project > Select Portal Application > click 'Next' > Type in Project name and root folder > click 'FINISH'.  Now, I do:
    File > New > Other > Portal Application > Create a new Portal Application Object > Select my Project > Portal Component/JSPDynPage (is this the 'easy' one to pick b/c it seems to update the portalapp.xml file, creates a jsp file (myFirstJSP.jsp) and bean for me) > I type in all the textfields for file name, package name, ... > click 'FINISH'. </b>
    Is this a correct/good way of starting a JSP project(I don't really know what a JSPDynPage is)
    Now I have a new issue.  I open up myFirstJSP.jsp and NetWeaver highlights all the code (pasted below) in yellow and there is no error displayed:
    <b><hbj:content id="myContext" >
      <hbj:page title="PageTitle">
       <hbj:form id="myFormId" >
       </hbj:form>
      </hbj:page>
    </hbj:content></b>
    So I try to paste this line into myFirstJSP.jsp: <b><%@ taglib uri="tagLib" prefix="hbj" %></b>and also paste this line onto portalapp.xml:
    <b><component-profile>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
    </component-profile>    </b>
    Now, I get an error saying: <b>"JSP Parsing Error:File "/dist/PORTAL_INF/pagelet/tagLib" not found"</b>
    Why is this?  How can I fix it?
    Thanks so much,
    Baggett.

  • Pls help! is there a simpler way to list this code?

    sym.$("UKstandardbuttons").fadeToggle();
    sym.$("AUSstandardbuttons").fadeOut();
    sym.$("Hongkongstandardbuttons").fadeOut();
    sym.$("Switzerlandstandardbuttons").fadeOut();
    sym.$("Irelandstandardbuttons").fadeOut();
    sym.$("Indiastandardbuttons").fadeOut();
    sym.$("Japanstandardbuttons").fadeOut();
    sym.$("Netherlandsstandardbuttons").fadeOut();
    sym.$("Spainstandardbuttons").fadeOut();
    sym.$("UK").fadeToggle();
    sym.$("AUS").fadeOut();
    sym.$("Hongkong").fadeOut();
    sym.$("Switzerland").fadeOut();
    sym.$("Ireland").fadeOut();
    sym.$("India").fadeOut();
    sym.$("Japan").fadeOut();
    sym.$("Netherlands").fadeOut();
    sym.$("Spain").fadeOut();
    sym.$("UKcountrybutton").fadeOut();
    sym.$("UKcountrybutton").fadeIn();
    sym.$("UKtextwindow").slideToggle();
    sym.$("Austextwindow").fadeOut();
    sym.$("Hongkongtextwindow").fadeOut();
    sym.$("Switzerlandtextwindow").fadeOut();
    sym.$("Irelandtextwindow").fadeOut();
    sym.$("Indiatextwindow").fadeOut();
    sym.$("Japantextwindow").fadeOut();
    sym.$("Netherlandstextwindow").fadeOut();
    sym.$("Spaintextwindow").fadeOut();
    sym.$("UKpiechart").slideToggle();
    sym.$("UKfinalpiechart").fadeOut();

    thanks, but i think that's a bit to complex for me, at this stage I just need to know how to condense writing something like:
    sym.$("UKstandardbuttons").fadeToggle();
    sym.$("AUSstandardbuttons").fadeOut();
    sym.$("Hongkongstandardbuttons").fadeOut();
    sym.$("Switzerlandstandardbuttons").fadeOut();
    sym.$("Irelandstandardbuttons").fadeOut();
    sym.$("Indiastandardbuttons").fadeOut();
    sym.$("Japanstandardbuttons").fadeOut();
    sym.$("Netherlandsstandardbuttons").fadeOut();
    sym.$("Spainstandardbuttons").fadeOut();
    into a var or class?
    as i don't want to have to repeat the above code within each elements action (with the fadeToggle swapping for each elements action etc)
    thanks

  • Iphone in recovery mode,i'm restoring and updating to itunes but download cannot be completed... my phone wont open, i can't even turn the power on.what to do? pls help

    iphone in recovery mode,i'm restoring and updating to itunes but download cannot be completed...
    my phone wont open, i can't even turn the power on.
    what to do? pls help
    (iphone 4  and  iphone 4s)

    So I just did this on my iPhone 4 and it worked like a charm it unlocked it immediately. My phone was put into recovery mode and I know that not all data is deleted it just puts the phone into a sort of hibernation in order for the files to stay uncorrupted. I went to http://www.recovery-ipad.com/iphone-stuck-in-recovery-mode.html  downloaded the software it unlocked my phone in a matter of minutes. Calls, messages, photos, apps, and voicemail was all there as if it never happened  If you leave it unregistered you don't have to pay for it works for either windows or mac. Hope this helps!

  • Stored proc execution status, pls help

    hi,
    i need to know if there is a way to find out whether an sp has been executed successfully or not, with the status code being returned.
    i know about the dbms_output.getline() function but i don't know how to use it!
    pls help
    thank you

    Hi,
    do you mean something like that ?
    SQL> create or replace procedure getData(id in number)
      2  is
      3   status number;
      4  begin
      5   select count(1) into status from emp where empno = id;
      6   if status > 0 then
      7     dbms_output.put_line('Success');
      8   else
      9     dbms_output.put_line('Failed');
    10   end if;
    11  end;
    12  /
    &nbsp
    Procedure created.
    &nbsp
    SQL> set serveroutput on
    SQL> exec getData(1)
    Failed
    &nbsp
    PL/SQL procedure successfully completed.
    &nbsp
    SQL> exec getData(7369)
    Success
    &nbsp
    PL/SQL procedure successfully completed.
    &nbspRgds.

  • Ipod nano(6th generation) it is not recognised in itunes.. it says it cannot recognise this device completely..try unistalling and re-install itunes.. i did but it still doesnt.. even my ipad is not recognised in itunes,.. wat shall i do ..pls help me ...

    ipod nano(6th generation) it is not recognised in itunes.. it says it cannot recognise this device completely..try unistalling and re-install itunes.. i did but it still doesnt.. even my ipad is not recognised in itunes,.. wat shall i do ..pls help me ...

    Did you uninstall iTunes and all other Apple related software using the instructions in this Apple support document?
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    B-rock

  • HT3702 I can't buy anything in the game. Apple said "your purchase can not be completed" pls help! Why?

    I can't buy anything in the game. Apple said "your purchase can not be completed" pls help! Why?

    It's a really bad idea to post your email address - it's an invitation to spam - and I've asked the Hosts to remove it.

  • There is a problem with this windows installer package.  A program required for this install to complete could not be run. Contact your support personnel or package vendor. Pls help, need assistance.

    I tried uninstalling my itunes thinking it was perhaps a conflict with the previous version, now I don't have itunes on my pc at all!!
    Reading a previous post for this problem, I attempted to uninstall the 6 individual programs from within control panel.  Everything uninstalled fine except for the Apple Software Updater which failed to uninstall and gave me the same error message.
    I only encountered this when trying to update to the current version of itunes64setup.  When using itunes ver 9 on Windows 7, everything was still fine.
    Pls help, any assistance would be appreciated.

    I have also tried extracting the individual components to the temp file and attempting to install them individually despite being unable to remove the previous install of Apple Software Updater.  The outcome, both Apple Software Updater and itunes encountered the same error message during the install process.

  • Very simple question pls help me

    I just want to use oracle sql and pl/sql workshop isqp*plus web site, so which product or software shouuld i download??? pls help me.
    thanks.

    Pl see your other 2 threads on the same topic (posting the same question multiple times does not make the issue go away ;-) )
    Oracle install error 10g 64 bit windows
    which product should i install??
    HTH
    Srini

  • Simple Servlet question, pls help

    This is my form submission part in my jsp page
    <form name="updateForm" method="POST" action="/Update"> This is my web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
      <servlet>
        <servlet-name>/Update</servlet-name>
        <servlet-class>UpdateMap</servlet-class>
      </servlet>
    </web-app>This is my UpdateMap.java
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    public class UpdateMap extends HttpServlet
        public UpdateMap()
    }I put my UpdateMap.class in WEB-INF/classes/ directory but when I clicked the submit button in my jsp page, I got The requested resource (/Update) is not available error

    Found my own error. The jsp submission code should be
    <form name="updateForm" method="POST" action="Update"> But I still got error when submit
    The specified HTTP method is not allowed for the requested resource ( POST method of HTTP is not supported by this URL.)Pls help.
    Thanks

  • Simple calculation problem...pls help

    i have 2 report blocks in my report.
    the query for report block 1 is
    select emp_name,sal sal1 from emptable where emp_num=7167
    the query for the next report block is
    select emp_name,sal sal2 from emptable where emp_num=7168
    both the reports query the same table and get the same number of records.
    i want the difference of sal1-sal2...
    how do i do it..
    pls help....

    You could do salary diff calculation in a pl/sql function, and create the ref cursor query based on the function.
    Thanks,
    -Shaun

  • Error in Oracle9iAS when registering Lotus Notes?-pls help.

    Hi..
    I not sure whether to post my problem here, or in Portal forum...
    I got this error when registering Lotus Notes mail in Portal(We done all the step, but stuck in the Final Step). I know, maybe you will ask me to post it in PDK/Lotus Notes Forum, but, one of my friend said that This is Portal/Oracle9iAS Error..
    can anybody pls help me? Where to configure in the server to let Lotus Notes app is ok?
    This is the error that come out when we tried to register the Lotus Notes Mail...
    "500 Internal Server Error
    java.lang.VerifyError: (class: com/ibm/CORBA/iiop/GenericServerSC, method: dispatch signature: (Lcom/ibm/CORBA/iiop/IIOPInputStream;Lcom/ibm/CORBA/iiop/IIOPOutputStream;)V) Illegal use of nonvirtual function call at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:120) at com.ibm.CORBA.iiop.ORB.registerSubcontracts(ORB.java) at com.ibm.CORBA.iiop.ORB.<init>(ORB.java) at java.lang.Class.newInstance0(Native Method) at java.lang.Class.newInstance(Class.java:237) at org.omg.CORBA.ORB.create_impl(ORB.java:284) at org.omg.CORBA.ORB.init(ORB.java:328) at lotus.domino.cso.Session.OREFtoSession(Session.java:703) at lotus.domino.cso.Session.<init>(Session.java:57) at lotus.domino.cso.Session.createSession(Session.java:36) at lotus.domino.NotesFactory.createSession(NotesFactory.java:67) at oracle.portal.integration.lotusnotes.application.ApplicationLogin.authenticateUser(Unknown Source) at oracle.portal.integration.lotusnotes.application.ApplicationLogin.performLogin(Unknown Source) at oracle.portal.integration.lotusnotes.application.LotusProvider.process(Unknown Source) at oracle.portal.integration.lotusnotes.application.ExternalServlet.doGet(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:244) at javax.servlet.http.HttpServlet.service(HttpServlet.java:336) at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:59) at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283) at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:523) at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269) at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:735) at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.AJPRequestHandler.run(AJPRequestHandler.java:151) at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].util.ThreadPoolThread.run(ThreadPoolThread.java:64)

    Yes I have YemuZip & it works but need something that is either menu or automated. I have tried to use automator to automatically archive a .dat file when I add it to the folder where these files are stored...but can't get it to work. I haven't used automator before.
    I have the workflow done but it will only run when I go to the menu & select the workflow - I though the whoel point was that it was automatic?
    Anyway if YemuZip is the only way I can do it I guess I will have to wear it - I thought it may be a simple thing to alter the way OS X handles the compression...
    Thanks!

  • I try to do simplest thing  in bi but  i failed.  pls help.

    Hi,
    I have a quesiton regarding to security . This is a very basic question and related to a base security feature of Bı. But it doesn't work here.
    My version is obiee 11g. Here is what i try to achive:
    I have created a new user called userA. I put this into the BICOnsumer group so it can run analysis.
    Then in order to userA run an analysis, i log into another user, choose a sample report called reportA , and give full control to userA. ( i also tried other rights)
    Since reportA is stored in folderA , i also give full rights for folderA to userA.
    Now what i expect to see is , if i login with userA , i can open the folderA and see, run the reportA.
    But: although i can open folderA , i can't see the reportA. Very simple thing i think , but it doesn't run .
    And
    Pls help.

    Hi,
    Have you check catalog -->folder A-->
    permission --> add it user A then try log in it will show to userA
    Also make sure below steps also
    Go -- settings manage dashboard access add it user A then it should work
    Thanks
    Deva
    Edited by: Devarasu on Sep 16, 2011 6:19 AM

  • Urgent: need help in creation of a simple PCUI application

    Hi Experts,
        I am new to this PCUI. i need the help of urs.
    My requirement is
    >>>>To create a simple PCUI application.This contains a Search and Result list.
    >>>>Then i have to find the BSP coding or the HTML coding for the the PCUI
      application.
    >>>Can anyone please tell me the detailed steps for creating a simple PCUI application that displays the search and a result list???
    >>>Then how can i find the BSP coding or script(such as HTML,XML..) coding used for the  application.
    Pls help me , its urgent.... If anyone have any kind of useful documents pls mail me in my id <b>[email protected]</b>
    Thanks & Regards
    Sudhansu

    Hi Experts,
    I am new to this PCUI. i need the help of urs.
    My requirement is
    To create a simple PCUI application.This contains a Search and Result list.
    Then i have to find the BSP coding or the HTML coding for the the PCUI
    application.
    Can anyone please tell me the detailed steps for creating a simple PCUI application that displays the search and a result list???
    Then how can i find the BSP coding or script(such as HTML,XML..) coding used for the application.
    Pls help me , its urgent.... If anyone have any kind of useful documents pls mail me in my id [email protected]
    Thanks & Regards
    Preethika

  • Simple stored procedure - select with an if statement, returning a cursor

    Hi,
    I'm trying to create a very simple stored procedure, but having never worked with them before I'm not quite sure what I'm doing wrong.
    Here's my code:
    create or replace
    procedure contact_return(
        v_contact_id IN varchar2,
        p_cursor OUT SYS_REFCURSOR)
    AS
    begin
      set sql_statement varchar2(4000) := '
        SELECT URN,
          FIRSTNAME,
          LASTNAME,
          TITLE,
          CREATED_DT,
          AREA_URN,
          MOBILE,
          WORK,
          EMAIL,
          ORG_NAME,
          ADDRESS,
          POSTCODE,
          IN_USE
        FROM CONTACT';
      if v_contact_id is not null then
        sql_statement := sql_statement || ' where urn = ' || v_contact_id;
      end if;
      open p_cursor for sql_statement;
    end;
    It's actually returning 2 errors:
    Error(7,3): PL/SQL: SQL Statement ignored
    Error(7,7): PL/SQL: ORA-00922: missing or invalid option
    Which seem to be a problem with my set sql_statement line, but it looks correct to me?
    Thanks

    rajendra wrote:
    Dear User,
    It is not allowed to declare a variable inside the PL/SQL block means after begin ( in your case line no 7 ).
    Lot of errors in your code.
    Tell me your exact requirement and what you want to do , after that I will be able to solve your problem.
    Thanks,
    Rajendra
    Well, you can declare after the begin, though it'll be as part of an embedded code block e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure contact_return(empno IN  number
      2                                            ,c     OUT SYS_REFCURSOR
      3                                            ) AS
      4  begin
      5    declare
      6      sql_statement varchar2(4000) := '
      7        select *
      8        from emp
      9        where empno = nvl(:1,empno)';
    10    begin
    11      open c for sql_statement using contact_return.empno;
    12    end;
    13* end;
    SQL> /
    Procedure created.
    SQL> var x refcursor
    SQL> exec contact_return(7788,:x);
    PL/SQL procedure successfully completed.
    SQL> print x;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    20
    so, it is allowed, as long as it's coded correctly.

Maybe you are looking for