stored-procedures

Strange system.void return exception generated when running a mapped stored procedure method in LINQ-to-SQL

Hello, I have a SQL Server 2008 stored procedure (pseudocode below) that goes as follows: CREATE PROCEDURE MyProc AS BEGIN CREATE DummyTable INSERT INTO DummyTable SELECT xxx INSERT INTO DummyTable SELECT yyy IF EXISTS FinalTable DROP FinalTable EXEC sp_RENAME 'DummyTable', 'FinalTable' END GO Note that there is no retur...

SQL Server 2005 Stored Procedure Dependencies

Hello I have a list of stored procedures and I'm trying to determine the order they should be implemented in. Is there a way to determine how the stored procedures are dependent on each other. I'm thinking that I could use sysobjects and syscomments. Thanks ...

SQL Server, Converting a select mechanism from "and" into "or"

Hello all, I have a web based program which chooses some records from a database using a checkboxlist. (my check box list sends parameters to a stored procedure and I use the result of stored procedure). Here how my check box list looks like Overflow [] (sends param1) Open Records [] (sends param2) Records with 4...

SQL Server / TSQL Updating a table with a unique constraint

Hi, If I have two tables, say: Clients ( ClientID int primary key, ClientName varchar(50) not null ) and Addresses ( AddressID int primary key, AddressLine1 varchar(50), etc.. ClientID int not null, IsPrimaryAddress bit not null ) with a unique constraint across (ClientID, IsPrimaryAddress), how can up date those tab...

Stored Procedure

Hello, i'm stuck with creating a stored procedure that should update a calculated column daily. Unfortunately my knowledge about stored procedures is limited but it seems to be the right place. I try to give more background informations: The Main-Table stores claims and is called tabData. It has a column 'IsReturn' with datatype bit(b...

MySQL - Change the stored procedure definer

I have a around one hundred stored routines in my MySQL database with with most of them have 'root' as the definer. I have another mysql account named 'abc', how to change the definer of all routines to 'abc'. Is it possible to do the same if I have access to MySQL server only as 'abc' user and not as 'root' ...

stored procedure mapping Entity Framework

Hi, We're using a Function Import in an EF4 model to populate an existing entity in our Model. The entity in the model has a Key field of Id which we're struggling to map as our stored procedure doesn't return an Id field. I've tried setting the value in the mapping to a literal value of 0 but that fails with an EntityCommandExecution...

Linq-to-sql scalar stored procedure, most direct way to get single result?

I am using the following method and looking for input on better methods or more direct methods (less code, clearer purpose): _dc.StoreProcedureName().ToList().First() Thanks ...

Running repetitive maintenance processes on LAMP

I am developing an auction site that requires maintenance scripts to be run in the background to ensure smooth running. Things such as ending auctions, starting auctions, etc... There seem to be many options and no definite answers when I research the subject. Is there a standard for doing this sort of thing? My research so far has unc...

LINQ: Call Stored Procedure and Join its results with IQueryable

I have: a stored procedure which retrieves zip codes in a radius around another zip code a table with contacts I'm getting the contacts through an IQueryable interface which I've extended with various extension methods to filter results by age etc. What I have trouble with is adding an IQueryable extension method which calls the st...

Mysql Stored Procedures Dynamic Queries

Hi guys, I've had quite a few problems and know that I can get some good answers here! Ok kinda 2 part question. Part 1 I'm doing some really big updating of data, kind rejiging the tables mostly. so the question is should I be using a mysql stored procedure or mysql/php like normal. I'm currently on the stored producure frame of mind. ...

Oracle Stored Procedure call by PhP

Here the code: <?php include_once 'config.php'; // Connect to database $conn = oci_connect($dbuser, $dbpasswd, $dbhost."/".$dbname); if (!$conn) { exit ("Connection failed."); } $id = isset($_GET['id']) ? (int)$_GET['id'] : false; $type = isset($_GET['type']) ? strtoupper($_GET['type']) : "BLOG"; $stmt = oci_parse($conn, "beg...

T-Sql Select * Between 30% and 40%

Question How do I write a T-SQL Stored Procedure that lets me select percentages of rows between X% and Y%? So basically I would want to select the rows between 30 PERCENT and 40 PERCENT..... I know that you can do the following, but obviously that doesn't let met specify a set of rows between 2 percentages. SELECT TOP 50 PERCENT * ...

automatically placing results of a called procedure into a select statement

I'm playing with some code from an article written by Peter Brawley found here on page 6 of the pdf. I'm trying to figure out how to automate it so that the result of the procedure is automatically placed in the select query. Right now what I am doing is calling the procedure, exporting the result into a text file, going to the text fi...

What is passing parameters to SQL and why do I need it?

Beginner here: In this answer to my question of how to insert data into SQL Server he mentioned passing parameters instead of string concatenation like I currently have. Is this really necessary for security? If so, what exactly is passing parameters? When i google it I get a lot about stored procedures. Is that what I want, I do n...

Querying using Entity Framework via Stored Procedures

I am quite frustrated with Entity Framework as most of the tutorials only show how to use it with one or two tables, and not multiple tables with relations. I was thinking of the following 'hack' to get my job done quickly: Create and Import procedures in the EF ORM to do most of the CRUD where multiple tables come into picture. What a...

shared stored procedure

Let's say I have many sql server databases which have exactly the same schema. Is there any place where I can write a stored procedure and apply for all databases? If I create the stored procedure for each database, when needed, I have to update them all. ...

How to use NHibernate to process multiple resultsets/SYS_REFCURSOR from Oracle stored procedure

I can get NHibernate (v2) to return and process a single SYS_REFCURSOR that contains my single resultset. Is it possible for multiple resultsets/SYS_REFCURSOR's in NHibernate? What would be the syntax of the .hbm.xml file to map multiple resultsets from the SYS_REFCURSOR's? thanks. ...

Using Cursor in a Loop of a stored procedure

So as to use cursors dynamically using MySQL is it possible to declare a cursor in a loop of a stored procedure? I've tried and got an error: increment: LOOP DECLARE cur1 CURSOR FOR SELECT person_id, publication_id FROM p_publication WHERE person_id = new_count; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; OPEN cur1; REPEAT ...

MySQL Stored procedure: search for a variable number of strings

I need a some stored procedure that called like: search('foo bar') makes a search similar to: SELECT FROM A, B WHERE A.B_ID = B.ID AND (A.f1 LIKE '%foo%' OR A.f2 LIKE '%foo%' OR B.f3 LIKE '%foo%') AND (A.f1 LIKE '%bar%' OR A.f2 LIKE '%bar%' OR B.f3 LIKE '%bar%') And I have some doubts and questions: I can't pass an array to the p...