Is it possible to make stored procedure which results with only one row?

Greetings community,
I’m making the app in .NET, and I don’t really have the problem to get the result, but through watching videos I’ve realized that using LINQ isn’t always the best way of doing things, because it requires pulling too much data through the
network to do some LINQ over it. There’s also the issue of security, so I was advised to use stored procedures and functions on SQL server to accomplish what I need without disturbing client machines too much.
I’m absolute beginner in TSQL, so I need your help. I need to extract last order of particular customer and I wonder if that could be accomplished. To make things simple, let’s imagine that my orders table has only these three columns:
OrderID (int, primary key, identity incremented), CustomerID (int), and DateOfOrder(datetime). I need a procedure that would take CustomerID as parameter, and return one single row which represent the last order of that customer.
I would also be very grateful to see the extended procedure that would take LastCount additional parameter and return several rows which would represent last several orders of that customer.
Last thing, if it’s not too much already, I would very appreciate some link to educational videos about SQL server for beginners. There were great videos on msdev.com, but this web address doesn’t exist anymore.

There are many tutorials on MSDN with Linq including SQL Server Express. A good start is this here:
http://msdn.microsoft.com/en-us/library/bb399349(v=vs.110).aspx
-Jens
Jens K. Suessmeyer http://blogs.msdn.com/Jenss

Similar Messages

  • HT201269 me and my brother both are having iphone 4s we just want to exchange phones with each other also the whole data from one iphone to other is this possible or how can i do that with only one itunes?

    just want to move data between two iphones using one itunes.

    Make sure your computer iTunes is up to date. (iTunes 11.1.1)
    Now, do it one iPhone at a time; When you connect and select iPhone in computer iTunes sidebar (iTunes > View > Show Sidebar), what iPhone name do you see?
    iTunes is smart enough to tell the differences if each has a unique name.
    Point One checked.
    Right click on iPhone name in Sidebar and choose Backup.
    Do the same for the second iPhone.
    Make a copy of the backups in computer to another location (Just incase something gone wrong)
    Where iTunes backups are stored on computer http://support.apple.com/kb/HT4946
    Point 2 checked.
    Point 3 & 4
    http://support.apple.com/kb/ht1766

  • How to call a stored procedure which has out parameter value

    my code is
    public Connection createConnection() {
                   Connection conn = null;
                        try {
                             Class.forName(DRIVER);
                             conn = DriverManager.getConnection(URL,USER,PASS);
                        } catch (ClassNotFoundException cnfe) {
                             System.err.print("Class not found");
                        } catch (SQLException sqle) {
                             System.err.print("SQLException");
                   return conn;
         public static void main(String args[]){
              StroedProcedure stp = new StroedProcedure();
              Connection con = stp.createConnection();
              try {
                   CallableStatement stproc_stmt = con.prepareCall("{call Account_Summary(?,?,?,?,?,?,?,?)}");
                   stproc_stmt.setString(1, "123456");
                   stproc_stmt.setDate(2, null);
                   stproc_stmt.setString(3, null);
                   stproc_stmt.setString(4, null);
                   stproc_stmt.setString(5, null);
                   stproc_stmt.setString(6, null);
                   stproc_stmt.setDate(7, null);
                   stproc_stmt.setDate(8, null);
                   stproc_stmt.registerOutParameter(1,Types.CHAR);
                   stproc_stmt.registerOutParameter(2,Types.DATE);
                   stproc_stmt.registerOutParameter(3,Types.CHAR);
                   stproc_stmt.registerOutParameter(4,Types.CHAR);
                   stproc_stmt.registerOutParameter(5,Types.CHAR);
                   stproc_stmt.registerOutParameter(6,Types.CHAR);
                   stproc_stmt.registerOutParameter(7,Types.DATE);
                   stproc_stmt.registerOutParameter(8,Types.DATE);
                   stproc_stmt.execute();
                   System.out.println("test "+stproc_stmt.getString(1));
                   ResultSet rs = stproc_stmt.executeQuery();
                  while (rs.next()){
                       System.out.println("result "+rs.getString("ACCPK"));
              } catch (SQLException e) {
                        e.printStackTrace();
         }And the stored procedure is
    CREATE OR REPLACE
    procedure Account_Summary (accpk in out char, incdt out date, bcur out char, bmark out char, tarTE out char, numHold out char, stDt out date, AsDt out date)
    is
    begin
    select account_pk, inception_date, base_currency, benchmark  into accpk, incdt, bcur, bmark
    from account a
    where a.Account_pk=accpk;
    select target_te, number_holdings, start_date, as_date into tarTE, numHold, StDt, AsDt
    from acc_summary asum
    where asum.account_pk=accpk;
    end Account_Summary;but it gives a exception ORA-01460: unimplemented or unreasonable conversion requested
    ORA-06512: at "REPRO.ACCOUNT_SUMMARY", line 4
    ORA-06512: at line 1
    i want to execute a stored procedure which has in , inout or out parameter
    but it can not work

    ========================
    In some contects varchar2 variable limit is 32512 characters... October 16, 2003
    Reviewer: Piotr Jarmuz from Poznan, Poland
    Interesting to note is the fact that varchar2 variables as parameters to stored
    procedures (in in/out out) may be "only" 32512 bytes long.
    I've checked this in Java and Perl. 32512 is the last value that works, for any
    bigger it throws:
    Exception in thread "main" java.sql.SQLException: ORA-01460: unimplemented or
    unreasonable conversion requested
    But in PL/SQL as you said 32767
    Regards,
    Piotr
    =================================
    This i got it from ask tom, well it make sense.... try checking your input with small numbers and strings
    Have fun

  • 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

  • Calling Stored Procedure which returns single or multiple value

    Hi All Experts,
    I have written one stored procedure which is returning different
    integer values according to condition.I am calling this
    stored procedure through prepareCall() method then executeUpdate() method ,but it is always returning 1,not my desired value.
    Pl also tell me,if my stored procedure returns more than one value
    then how will i get those values in my java program?
    Pl help by writing some sample code.
    Thanx in Advance.
    Pradipto

    1) Create CallableStatement
    2) For each of returning value you have to call RegisterOutParameter()
    3) For others user setXXX() method depending on type of parameter
    4) call
    5) use vars registered through RegisterOutParameter() - all your values should be there
    Pavel

  • Calling a Oracle Stored Procedure which will take a while to complete

    Hey.
    I'm calling a Oracle stored procedure which goes of and do a whole lot of things and therefore takes a fair while to complete.
    Currently I am doing this:
    String sql = "begin concorde.start_transfer(); end;";
    HibernateUtil.getSessionFactory().openStatelessSession().connection().prepareCall(sql).execute();
    ....Where HibernateUtil is just a mean to get to the SessionFactory. The connection I get is the same one as a JDBC, I think.
    I would want to regain control of the application as soon as the procedure is called and continue with the rest of the logic.
    How do I do that? Do I have to initiate it from a different thread?
    Thanks

    If it was me I wouldn't have a stored proc that took a while to complete. Instead I would submit a job to job queue. In terms of implementation I would call a proc that writes a record to a table. Then a process in the database polls that table and runs jobs it finds there. Then reports results somewhere.
    Sometime later you collect the results.
    But without that then the solution in java is obvious - create a thread.

  • Calling a stored procedure which returns a value

    Hi Friends,
    I want to call a stored procedure which returns a value.
    Eg
    create or replace procedure xyz(a1 in varchar2, a2 in varchar2, z1 out number)
    thanks

    Hi,
    use this.
    declare
    retval number;
    begin
    abc('aaa','bbb',retval);
    dbms_output.put_line('retval is ' ||retval);
    end;
    --Basava.S                                                                                                                                                                                                                                                                                               

  • Calling Stored procedure which uses Bulk Collect

    Hi All, I have Oracle stored procedure which uses Bulk Collect and returns table type parameter as output. Can anyone please help me how Can I call this kind of stored procedures which returns table type output using VB and Oracle's Driver. (I am successfully able to call using MS ODBC driver, but I want to use OraOLEDB driver.)

    861412 wrote:
    how Can I call this kind of stored procedures which returns table type output using VB and Oracle's Driver. This forum deals with the server-side languages SQL and PL/SQL.
    Your question deals with the client side and Visual Basic language.

  • I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".

    Hello,
    I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".
    Suppose , 
    Parameter value : person 1,person2,person3 
    table structure : 
    Project Name | officers 1 | officers 2
    here, officers 1 or officers 2 may contain names of multiple people.
    expected OUTPUT : distinct list(rows) of projects where person 1 or person 2 or person 3 is either officer1 or officer 2. 
    please explain or provide solution in detail 
    - Thanks

    Hi Visakh,
    Thanks for reply.
    But the solution you provided giving me right output only if officer 1 or officer 2 contains single value , not with comma seperated value.
    Your solution is working fine for following scenario : 
    Project 
    Officers 1
    Officers 2
    p1
    of11
    off21
    p2
    of12
    off22
    with parameter : of11,off22 : it will give expected output
    And its not working in case of :
    Project 
    Officers 1
    Officers 2
    p1
    of11,of12
    off21,off23
    p2
    of12,of13
    off22,off24
    with parameter : of11,off22 : it will not give any row in output
    I need patten matching not exact match :) 
    ok
    if thats the case use this modified logic
    CREATE PROC GetProjectDetails
    @PersonList varchar(5000)
    AS
    SELECT p.*
    FROM ProjectTable p
    INNER JOIN dbo.ParseValues(@PersonList,',')f
    ON ',' + p.[officers 1] + ',' LIKE '%,' + f.val + ',%'
    OR ',' + p.[officers 2] + ',' LIKE '%,' + f.val + ',%'
    GO
    Keep in mind that what you've done is a wrong design approach
    You should not be storing multiples values like this as comma separated list in a single column. Learn about normalization . This is in violation of 1st Normal Form
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Unused stored procedure parameters marked with a check mark in crystal reports

    Post Author: epowers0213
    CA Forum: General
    Hello,
    I have some Crystal Reports that currently use stored procedures as their datasources (I am in the process of modifying them to use datasets instead).  Some of the original reports have check marks next to stored procedure parameters which I cannot find as being used anywhere in the report.  Is this a legitimate possibility? (Some of them do not have check marks, however, so it is not consistent.)
    More Info:  I am using Crystal Reports within Visual Studio 2005.  I have looked through each report in every way I can think of to find if a parameter field is being used anywhere - I have checked all formula fields, the formatting formulas for sections and individual fields, the record and group selection formulas and the grouping and sorting experts, along with any subreports (although some of them have no subreports).
    (I have read on other forums that exporting a report definition file is another way to look for where fields or parameters are being used, but this does not appear possible within Visual Studio 2005.)
    In some cases, I have gone ahead and replaced the stored procedure datasource location with a dataset (generated based on the same stored procedure).  When I do this, Crystal automatically deletes the stored procedure parameters from the report, and I have still been able to run the modified report successfully - at least it looks ok and nothing is complaining.  So is it possible that these parameters were actually not being used anywhere on the report although they were marked with a check mark?
    Any help would be greatly appreciated!  I want to make sure I am not changing the function of these reports somehow without knowing it...
    Thank you!

    Are you referencing another database that Crystal can't see? Also, you can try and copy the SQL to a command object in Crystal to see if it behaves differently there.

  • Calling Write Stored procedure from xsodata with table/list as input

    I have a stored procedure which takes table type as input and insert data in a table
    PROCEDURE "C"."abcd.procedures::InsertResData" ( IN  resourcelist "abcd.procedures.ResourceT",out error "abcd.data:abcd.procedures.tt_error"  )
      LANGUAGE SQLSCRIPT
      SQL SECURITY INVOKER abc
      --DEFAULT SCHEMA <default_schema_name>
      AS
    BEGIN
    ---some insert logic-
    END
    Now I have exposed the SP using XSODATA so that UI can consume it.
    service namespace "abcd.hana.service"{
    "abcd.views/Resourceview.attributeview" as "resourceitem"
    key("RESOURCE_ID")
    create using "abcd.procedures::InsertResData";
    Question: How can I pass array of input records to XSODATA. from UI? Is it supported?
    I could test with single record (JSON input) but could not test with multiple records
    Please help me on this if you have some expert opinion
    Regards,
    Apoorv

    I have a stored procedure which takes table type as input and insert data in a table
    PROCEDURE "C"."abcd.procedures::InsertResData" ( IN  resourcelist "abcd.procedures.ResourceT",out error "abcd.data:abcd.procedures.tt_error"  )
      LANGUAGE SQLSCRIPT
      SQL SECURITY INVOKER abc
      --DEFAULT SCHEMA <default_schema_name>
      AS
    BEGIN
    ---some insert logic-
    END
    Now I have exposed the SP using XSODATA so that UI can consume it.
    service namespace "abcd.hana.service"{
    "abcd.views/Resourceview.attributeview" as "resourceitem"
    key("RESOURCE_ID")
    create using "abcd.procedures::InsertResData";
    Question: How can I pass array of input records to XSODATA. from UI? Is it supported?
    I could test with single record (JSON input) but could not test with multiple records
    Please help me on this if you have some expert opinion
    Regards,
    Apoorv

  • Can i use Stored procedures and triggers with SDK

    hi all
    How to use the stored procedure and Triggers with SDK, can i get a sample code
    Regards
    Salah

    Hi, Salah.
    Use "Exec" in your query to run procedures.
    SAPbobsCOM.Recordset     oRS;
    oRS = (SAPbobsCOM.Recordset)pCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
    oRS.DoQuery ("EXEC YourStoredProcName");
    Triggers are not supported in SDK.
    Regards,
    Aleksey

  • How to create a table which have always only one entry inside it?

    Hi Experts,
    Is it possible to create a table in data dictionary which have always only one entry inside it. If  we insert another entry, then it should throw an error.

    if  you want to   maintain  only one data  in that  ...   then
    first  time   for  making  one  data entry     in the <b>Delivery & maintaince   </b> tabstrip  in the   table  have an  option   <b>Display /maintaince Allowed ...</b>
    after that
    change  it to  <b>Display/maintianance allowed  Restrictions .</b> ...  so that  table will not  allow to insert the entries .
    reward  points if it is usefull ....
    Girish

  • I want to make a video clip using two still pictures, placing side by side.  I am able to make with only one at a time.

    I want to make a video clip using two still pictures, placing side by side.  I am able to make with only one at a time.  Also, I am able to move the picture using Transform.  But unsuccessfull in making with two stills in same clip.  Thank you for reply.

    If you want a Picture in Picture effect, stack one still on top of the other with a connect edit. Use Transform to scale and reposition the top image.
    Russ

  • How to make 1D Array but with only one element filled in Real Time

    Hi folks,
    here I am with another question. I want to implement an prediction discrete state space observer which is going to run on a CRIO real time target. I am going to do it just like in the example which comes with LV.
    I have some questions regarding the input and outputs which in the example those are "dummy".
    My model is a SISO model, but the function "Construct SS model" returns parameters (A,B,C,D Matrices) as 2D arrays, so once you connect the cluster model into the Discrete Observer model, it takes y and u as 1D arrays despite of the fact that there is a SISO model.
    I realized that the function I am using in the simulations, uses 1D arrays but with only one element filled:
    Does anyone knows how to implement such 1D arrays in Real Time? I guess the way to do it is preallocating one array of zeros of size 1, and then recirculating it through some SR, and replacing the element with my real input and output, but at the dummy.vi, they are using a simple "build array"
    function.

    Ok, I did it that way. But I am facing another problem right now...
    At some point the Discrete Observer return a NAN array, you will see the code in the code snippet?
    I get rid of that component by component, but the observer gets "stuck" in it. So my Control law is zero... but the state stimate is NAN.
    Also I am attaching the VI.
    I do not know why, since in the simulation program all runs well. any thoughts? Maybe the internal numeric precision of the State Space Model?
    Attachments:
    RT - Pole Placement + Complete Observer.vi ‏40 KB

Maybe you are looking for

  • How to update my mac book pro??

    how to update my mac ???

  • Lightroom 5.5 Import from Catalog *very* slow performance.

    Importing from a second catalog from a shoot is *very* slow with the last version or couple of versions of Lightroom.  It's been about 20 minutes and the import is moving glacially slow and is only about 20% done. Here are as many stats as I have: iM

  • Layout to a Report run in the background

    For a standard SAP Report which is run in background everyday with a variant . How can I attach a layout ( i created for sort column )to the report ? I want the output of the report to be as per the Layout ...How can i assign the layout to the report

  • Sizing Requirement

    For sizing requirements, I need to find out the rowcount of certains heavy Cubes. When I try to find the rowcount using LISTCUBE these heavy Cubes give timeout dumps. Any other way I can find the rowcount.. I can not execute in back ground as it does

  • Can't Upgrade to Parrot Pro because it's already purchased

    Hi there. I bought the pro version of Parrot Voice Recorder a while ago (last year maybe?) when I had my Z10. I've upgraded to a passport and all my apps installed fine (including iGrann Pro). However, Parrot is only the free version. I used the in-a