stored-procedures

Can you force a SQL Stored Procedure to take locks in a given order

I have two stored procedures, one of which is called a lot and is thus very simple and executes well. Additionally, these actually work very nicely in paralell even though they are serializable. However I have a second query that is only called in certain circumstances which needs to do many more checks before touching the same tables....

Syntax error when calling a stored procedure. I can't see what the problem is

I am having trouble calling the following stored procedure. When I call ExecuteReader, I am getting the error 'Incorrect syntax near 'GetAverages2'. I can create the stored procedure and call it from TSQL. I can't seem to get it working from ADO: CREATE PROCEDURE GetAverages2 @CompanySize INT, @Q1 FLOAT OUT, @Q2 FLOAT...

Is it possible to define a stored function in MySQL with an unspecified return type?

I suspect the answer to this is "No", based purely on the concept of type safety in general, but I shall ask anyway. If I define a stored function in MySQL, normally part of the CREATE syntax defines the return type of function. Is it possible to define one where the return type is one of two possible types, depending on the result, bu...

java - passing array in oracle stored procedure

Hi, I have a Java app accessing an oracle stored procedure. The arguments to the stored procedure include an array type. I do it like the following... con = this._getConnection(); Connection narrowdConn = (Connection)WSJdbcUtil.getNativeConnection( (WSJdbcConnection)con ); callable = con.prepareCall("{call MY_PKG.MY_PROCEDURE(?, ?...

SQL Server stored procedure case sensitive?

Hello, I have a case sensitive SERVER (SQL_Latin1_General_CP1_CS_AS) but the Database is Case insensitive (SQL_Latin1_General_CP1_CI_AS). If I try to create the following stored procedure on the database, I get the error "Must declare the scalar variable "@test"." CREATE PROCEDURE [dbo].[sp_Test] (@TEST int) as begin SELECT @tes...

Hibernate Security Apprehension: Hibernate vs. Stored Procedures

At the company that I work with, we often have to integrate with client’s infrastructure. Recently, after hearing that we use Hibernate, one client manifested following concern: Since user under which Hibernate connects to database has a direct access to tables and Hibernate generates SQL dynamically, then such user can do pretty mach an...

Stored Procedure Replication or copying (SQL Server)

Is it posible to replicate or copy the stored procedure easy from one SQL Server to an other? ...

Linq to SQL insert via stored proc issue

I have a method that inserts a record into SQL Server using Linq to SQL and a stored proc. However if we refresh the page (it automatically runs a Get method), the updated data doesn't get returned from the Linq query (not a stored proc). I'm guessing if I use a stored proc for the Get, this will solve the issue as it seems the context...

TSQL / SP INSERT statement with text & values

HI, I have an insert statement in a Stored Procedure that requires the value data to be a combination of text and variables/inputs. However my SQL Manager is giving an error on this 'camp' value when trying to compile it. Here is the statement as it currently exists; BEGIN TRAN INSERT INTO TBL_DONATIONS ([donations_MemberID], [d...

Entity Framework, Stored Procedures,ASP.NET GridView - Insert Empty Row

I want to add a empty row in my Grid. <asp:TemplateField> <ItemTemplate> <asp:ImageButton id="Insert" runat="server" CausesValidation="false" CommandName="Insert" OnClick="GridViewInsert" ImageUrl="~/Images/Grid/Insert.gif" /> In GridViewInsert Event: Award_Status_List list = new Award_Status_List(); list.Award...

SQL Server 2005 View vs Materialized View vs Stored Procedure

If I have a table that contains tens of thousands of records of accounts for multiple locations. Is there any speed difference if I query a view that selects all accounts for a specific location and a stored procedure that with the same SQL statement? EDIT: I ran across this Materialized View. It seems like this would always be used. ...

Subsonic 3 fails to identify Stored Procedure Output Parameter

Hi using Subsonic 3.0.0.3 it appears there is some issue with Subsonic identifying Stored Procedure paramters as output parameters. In the StoredProcedures.cs class I find my stored procedure definition but the last parameter is defined incorrectly as a 'AddParameter'. sp.Command.AddParameter("HasPermission",HasPermission,DbType.Boole...

SQL insert error

Below code saying error incorreect syntax near "Main" INSERT INTO tbl ( 'Week', Main, a, b, c, d, e ) Select 'Week', Main, a, b, c, d, e FROM tbl_link ...

Using Stored Procedures with Linq To Sql which have Additional Parameters

I have a very big problem and can't seem to find anybody else on the internet that has my problem. I sure hope StackOverflow can help me... I am writing an ASP.NET MVC application and I'm using the Repository concept with Linq To Sql as my data store. Everything is working great in regards to selecting rows from views. And trapping very...

How to do unit test on remote store procedure

I'm facing to do the unit test on the data access layer, all the data access layer call database through the store procedure. I plan to create a clean database used for unit testing, but I found most of store procedure will remote call the other database, I've no idea on how to unit test this kind of store procedure, should I create all ...

Native Stored Proc v/s Hibernate

I am a newbie in Hibernate. I am working on a cloud service data access layer. Currently we are using Hibernate for OR mapping and as data access layer using Hibernate annotations. But lately i have been asked to implement Hibernate/Data Access layer in such a way that my stored procedures be in HQL and we can change our DB at a short ...

Stored procedure: return multiple columns instead of multiple recordsets?

This is probably a really simple question, but I don't write stored procedures often and I'm a bit mystified... After doing various stuff, the concluding bit of the SP ends by returning counts or sums from several different tables. The obvious approach is: select SUM(ThisCol) as ThisResult from... select SUM(ThatCol) as ThatResult from...

About hibernate NamedNativeQuery

Hello, I am a newbie in hibernate, I am using @javax.persistence.NamedNativeQuery to resolve my stored proc calls from hibernate to mysql but i am getting errors. Please help: My persistent class is: @Entity @javax.persistence.NamedNativeQuery(name = "SampleNameQuery", query = "call spS_NamedQuery(?,?)", resultClass = NamedQuery....

SQL Server CLR Stored Procedure JSON Parameter

Hello, I've come across a scenario where I want to pass a large amount of data to a Stored Procedure for generating some dynamic SQL. The data I want to pass is stored in this Json/C# class object that I use in my ASP.NET MVC web project. [ { "code":"ABC123", "Count": "12998", "Params": [ {"name": "Recent", "value": "0-12...

MySQL stored procedure porting?

I am having a great deal of trouble porting some stored procedures to regular MySQL statements. We have stuff like this example http://dev.mysql.com/doc/refman/5.0/en/stored-programs-defining.html BEGIN SET @x = 0; REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT; END Where many statements are executed. Several If statements and...