stored-procedures

How do I keep the variable value in a MySQL stored procedure from changing when records are updated?

I must be overlooking something simple. I'm setting a variable from a query result in a MySQL stored procedure like this: SELECT @myName := username FROM User WHERE ID=1; So, @myName is storing the username of userid 1, which is 'Paul'. Great. But later in the stored procedure I run an update on this record: UPDATE User SET username...

How do I call a stored procedure exposed as an Entity Framework Function Import through ADO.NET Data Services (Astoria)?

I've created an Entity Data Model and imported several stored procedures as Function Imports. I'm exposing the EDM through ADO.NET Data Services (ANDS). Does ANDS automatically expose the functions through its REST API, or do I need to manually add operations to the service? ...

Obtaining my custom error message from SQL 2000 sp

I have an sp with the following pseudo code... BEGIN TRANSACTION set @errorLocation='Deleting Permissions' DELETE [tblUsrPermissions] WHERE lngUserID = @lngUserID if @@error>0 begin goto roll_back end COMMIT TRANSACTION set @errorLocation='' --clear error messages ...

Nested Datalists using stored procedure parameters

Hi, I'm working with some nested datalist controls and cannot get the SP parameters for my nested stored procedure to work. In debug I can see that SqlDataSource2.SelectParameters.Add("Section",oLabel.Text.ToString()); is getting the correct value from the label but when the results display I always get the results for the last parame...

Is there a way to bind an array to mysqli prepare

I'm trying to make a class that will execute any one of a number of stored procedures with any amount of variables Im using php and mysqli My class enumerates an array and constructs a string based on the number of elements if any giving something like this CALL spTestLogin(?,?) for example I now need to bind the input from my array u...

SQL Table and column Parser for stored procedures

Is there an application , which can parse a given set of stored procedures (SQL Server 2000) and gets all tables and associated columns that are being used in it. The stored procedure can have tables from different databases. Output should be like TableA columnA columnC columnD TableB columnE columnF columnG I ha...

Linq to SQL, Stored Procedure with different return types based on an If/Else

I have an existing Stored Procedure which I am trying to now call with LINQ to SQL, here is the stored procedure: ALTER procedure [dbo].[sp_SELECT_Security_ALL] ( @UID Varchar(15) ) as DECLARE @A_ID int If ISNULL(@UID,'') = '' SELECT DISTINCT App_ID, App_Name, App_Description, DB, DBNameApp...

What data access strategy for a large application

I am about to embark on a rewrite of a VB6 application in .NET 3.5sp1. The VB6 app is pretty well written and the data layer is completely based on stored procedures. I'd like to go with something automated like Linq2SQL/Entity Framework/NHibernate/SubSonic. Admittedly, I haven't used any of these tools in anything other than throwawa...

Using NHibernate with output parameters

Does anyone know if NHibernate supports returning output parameters from stored procedures? I've had a search in the documentation but can't really find anything that confirms either way. ...

Oracle Default Values

Hi everyone, I've got a quick question about default values in PL/SQL functions in Oracle. Take this program as an example; create or replace FUNCTION testFunction ( varNumber IN NUMBER DEFAULT 0 ) RETURN NUMBER AS BEGIN dbms_output.put_line(varNumber); RETURN varNumber; END; The idea here being that if no value is specified fo...

Automatically create C# wrapper classes around stored procedures

I've inherited a rather large application that really could use some cleanup. There is data access code littered throughout the application. In code behinds, some in business logic classes, some inline in in classic asp pages. What I'd like to do is refactor this code, removing all the data access code into a few DAL classes. All the...

Executing shell command from MySQL

I know what I'm looking for is probably a security hole, but since I managed to do it in Oracle and SQL Server, I'll give it a shot: I'm looking for a way to execute a shell command from a SQL script on MySQL. It is possible to create and use a new stored procedure if necessary. Notice: I'm not looking for the SYSTEM command which the ...

Query to list SQL Server stored procedures along with lines of code for each procedure

I want a query that returns a list of all the (user) stored procedures in a database by name, with the number of lines of code for each one. i.e. sp_name lines_of_code -------- ------------- DoStuff1 120 DoStuff2 50 DoStuff3 30 Any ideas how to do this? ...

Stored Procedures MSSQL2005

If you have a lot of Stored Procedures and you change the name of a column of a table, is there a way to check which Stored Procedures won't work any longer? Update: I've read some of the answers and it's clear to me that there's is no easy way to do this. Would it be easier to move away from Stored Procedures? ...

Sproc Parameter Returning First Character Only

I've got a sproc and some C# calling it. My problem is that both the (N)VARCHAR values only have the first character returned. Everything else is fine. Why would only the 1st character be returned? So Content = (string)cmd.Parameters["@SmsContent"].Value, ToNumber = (string) cmd.Parameters["@ToNumber"].Value, both only get the 1st ch...

Linq-to-SQL How to prevent the use of Delete methods?

By convention our DB only alows the use of stored procedures for INSERT, UPDATE and DELETE. For some tables / types there is no DELETE stored procedure, because it is not allowed to delete rows. (You can only update the status of such a type to "deleted"). e.g. a customer may be marked as deleted but is never really removed from the DB. ...

Generate unique ID to share with multiple tables SQL 2008

I have a couple of tables in a SQL 2008 server that I need to generate unique ID's for. I have looked at the "identity" column but the ID's really need to be unique and shared between all the tables. So if I have say (5) five tables of the flavour "asset infrastructure" and I want to run with a unique ID between them as a combined gr...

Does Fluent-NHibernate support mapping to procedures?

I've been wondering if it's possible to have Fluent-NHibernate communicate with stored procedures that already exist and assign mapping from the result set to my own domain objects. Also is Fluent-NHibernate able to directly execute procedures with no result set returned? Basically I've been considering the implications of using Fluent...

How do I find out when a stored procedure was last modified or compiled?

I think the question title pretty much says it all, I'm preferably looking for a PL/SQL query to accomplish this, but other options might be useful too. ...

How do you programatically identify a stored procedure's dependencies?

Is it possible to write a PL/SQL query to identify a complete list of a stored procedures dependencies? I'm only interested in identifying other stored procedures and I'd prefer not to limit the depth of nesting that it gets too either. For example, if A calls B, which calls C, which calls D, I'd want B, C and D reported as dependencies ...