Questions tagged [stored-procedures]

A subroutine available to applications accessing a relational database system.

stored-procedures
Filter by
Sorted by
Tagged with
2 votes
4 answers
5k views

Convert stored procedure to LINQ

I'm using MVC3 and still learning LINQ. I'm having some trouble trying to convert a query to LINQ to Entities. I want to return an Json method My stored procedure Create Procedure [dbo].[...
Dotnet ReSource's user avatar
0 votes
0 answers
970 views

SQL Server stored procedure very very slow when using SQL Server login

I have a stored procedure in SQL Server 2005 that is very quick when executed in Management Studio when connected using Windows Authentication. The query processes a vast amount of data and takes ...
Chris's user avatar
  • 13
0 votes
1 answer
1k views

SimpleJdbcCall can't find a stored procedure

I'm trying to execute an oracle procedure stored on my database, I've executed it sometimes but after renaming it or changing some parameters i can't execute it from spring anymore. I defined it like ...
CalamarBicefalo's user avatar
0 votes
0 answers
523 views

calling Oracle Stored Procedure setup as Web Service

I have a stored procedure written by someone. The stored procedure is exposed as a web service. The guts of the code is that it creates a custom array of a few fields selected and then returns it. ...
user625832's user avatar
2 votes
1 answer
446 views

'SqlBulkCopy' was not found

When I try to create a following stored procedure in a new server, I get error Msg 6528, Level 16, State 1, Procedure usp_BulkCopy, Line 3 Assembly 'SqlBulkCopy' was not found in the SQL catalog ...
Rainmaker's user avatar
  • 321
0 votes
2 answers
1k views

How can i create an SQL IF statement to check if fields need updating

I've created an update procedure that will change the values of a record in a table if the matching record in another table changed, however, how i've got it set up is that even though there is like ...
Memor-X's user avatar
  • 2,930
0 votes
2 answers
51 views

How to reference the PK of a newly inserted row

I have a query where a record gets added to the table channels. Each record there is then assigned a channelID which is the PK for the table, and auto increments. After a record is added to the ...
xxyyxx's user avatar
  • 2,356
1 vote
1 answer
3k views

JDBC exception at getting decimal out parameter of stored procedure

I'm trying to get parameter from MYSQL procedure. My proc: CREATE PROCEDURE proc(someIn INT UNSIGNED, anotherIn INT UNSIGNED, OUT x DECIMAL(10,7), ...
Borodin.Mik's user avatar
0 votes
3 answers
5k views

Update Statement not updating when run from a stored procedure, but works perfectly when run manually

My first post here, so please be gentle with me :) I have a stored procedure with which I take some source data, do some manipulation, run some update statements on it and then put the data into our ...
Gortreck's user avatar
1 vote
2 answers
1k views

Must declare the scalar variable "@OUTSTANDINGSDATA"

I have this code in a SQL SP. When I'm testing if @OUTSTANDINGSDATA is not null, I get a "Must declare the scalar variable "@OUTSTANDINGSDATA"" error. It does not happen with the other variables. Any ...
Rui Martins's user avatar
  • 2,174
0 votes
2 answers
80 views

ExecuteNonQuery: returning right number

I have a procedure that inserts N records and then updates N records. ExecuteNonQuery on that procedure returns 2N. Is there a way to return only number of records updated, i.e. affected in the ...
David Shochet's user avatar
2 votes
1 answer
1k views

Get next sequence from table in insert statement to another table

I have 3 tables Table_A has a bunch of rows Table_B where rows are going to be inserted with data from Table_A Table_C holds a number (integer) called code_number I have a stored procedure (...
isioutis's user avatar
  • 314
2 votes
1 answer
2k views

DB connection InfoMessage callback not firing immediately for stored proc print statements

I have several long running Sybase stored procedures with print statements that output progress messages. We've always executed these SPs using isql or manually through aseisql or sqladvantage (all ...
madz's user avatar
  • 992
0 votes
1 answer
174 views

What to paste in when testing a sproc that takes a datetime2

I have written a stored procedure that takes a datetime2 parameter. When I try to debug it from visual studio 2010 it asks me to enter the parameter in a textbox but I can't find the correct format. I ...
Retrocoder's user avatar
  • 4,623
1 vote
1 answer
876 views

How do I validate a MYSQL Date field for NULL/ EMPTY?

I'm developing a MYSQL Stored Proc, and in that I need to validate a date field as follows, IF (dt_wedding_date<>'') THEN IF (int_days_to_wedding>0) THEN SET vc_wedding ='F'; ...
Thanu's user avatar
  • 2,481
1 vote
1 answer
8k views

Cursor on record table type in Oracle

I am having a declaration as shown below type respond_field IS record ( provider_id VARCHAR2(100), provider_name VARCHAR2(100)); type respond_field_group IS TABLE OF ...
Premanand's user avatar
31 votes
2 answers
28k views

How to pass a list of IDs to MySQL stored procedure?

I'm writing a stored procedure which should pass its arguments to IN (..) part of query in the procedure body, like this: DELIMITER // CREATE PROCEDURE `get_users_per_app` (id_list TEXT) BEGIN ...
mr.b's user avatar
  • 4,952
0 votes
1 answer
663 views

SSAS Stored Procedure throwing permission

I am getting the error Execution of the managed stored procedure 'mystoredprocedure' failed with the following error: Exception has been thrown by the target of an invocation.Request for the ...
EthanSpitz's user avatar
0 votes
1 answer
3k views

Stored procedure with table type parameter returns data but SqlDataAdapter will not fill

I'm passing a data table to stored procedure (using a table type) to update multiple records at once. SQL profiler shows the stored procedure executing and the records are updated; however, I'm also ...
xizwyck's user avatar
  • 63
2 votes
1 answer
2k views

How to Populate the Child Collections / Associations of an Entity from a Stored Procedure using NHibernate

I want to know if there is a way to populate recursive entities ( child collections / associations ) from a stored procedure in NHibernate. Suppose I have the next class: public class Category { ...
Guillermo Gutiérrez's user avatar
-1 votes
2 answers
1k views

Conditional statement in SQL Server stored procedure

I am writing a stored procedure in which such as a in update statement but ma confuse how to apply such type of thing? My stored procedure is: ALTER PROCEDURE [dbo].[Payment_SP] @reciptId ...
Mayank Mishra's user avatar
1 vote
2 answers
143 views

Database chicken and egg issue

I am using Sybase DB with TSQL. I am trying to work between 2 SPROCS, one nested inside the other. My outer SPROC will create a temp table #temp_table and fill it up with values to 200. Once the ...
czchlong's user avatar
  • 2,514
0 votes
1 answer
2k views

Calling a Sybase SP, error "SP not found"

I am connecting to a Sybase 9 database to retrieve data. I can query the database without issue using ODBC connections but I am having an issue calling stored procedures. The procedure was written ...
Chase's user avatar
  • 564
0 votes
2 answers
115 views

Transaction in SP avoid correct answer

I have an SP that work very well when called from SSMS. but when I call it from my application that written in native C++ and use ODBC for connecting to database, the operation return no error but ...
BigBoss's user avatar
  • 6,904
9 votes
4 answers
3k views

Alternatives to using dynamic sql

I have a sp which takes input @featuretype. @featuretype will be equal to either "mobile", "login", or "index", and will correspond to a column in the db. In my sp I have: EXEC( 'select TOP 3 * ...
xxyyxx's user avatar
  • 2,356
1 vote
1 answer
163 views

Should my view be much slower than my stored proc?

I have a view that I can't seem to fully tune, so I tried converting it to a proc, moving one of my WHERE conditions that I use when querying into a parameter and using the parameter in my derived ...
Bret Walker's user avatar
  • 1,796
0 votes
1 answer
223 views

Bypassing SAFE CLR Managed Procedure limitation on DROP TABLE

I need advice on the best way of doing this. Currently I have a clr procedure in MSSQL 2012 that bulk inserts a delimited data file into a temporary table it creates, then processes all the rows via ...
enko's user avatar
  • 625
0 votes
2 answers
788 views

inserting into two tables from one sp

I'm working on an sp that inserts data into two tables. The two tables are featured and featured type, both have a pk featuredid that gets auto incremented each time something is added. I have: ...
xxyyxx's user avatar
  • 2,356
3 votes
1 answer
2k views

MySQL stored procedure - How to Return Nothing

I have a stored procedure SP1 that calls another stored procedure SP2 like so: CREATE PROCEDURE SP1() BEGIN CALL SP2(); END The SP2 stored proc returns a row from a table, but I don't want SP1 ...
J Harri's user avatar
  • 407
1 vote
1 answer
255 views

Execute SET statement before STORED PROCEDURE call

I've a simple C# code which is creating MySQL connection, stored procedure command with parameters and returns DataReader object. Since we switched to Percona Cluster I want to execute this stored ...
Piotr Ginalski's user avatar
-1 votes
4 answers
6k views

Populate gridview with results of a SQL Server stored procedure that returns multiple recordsets

I have a stored procedure that returns multiple recordsets. It can be 1 recordset, 2 recordsets, or more. I don't know how many RS will come back. Here at stackoverflow I found the below sample ...
bubble's user avatar
  • 3
0 votes
2 answers
2k views

Stored procedure inner join

My first stored procedure (in sql-server). I'm not able to make it work, it raises a warning in a.Id After reading, and not really understand much, I'm not even sure if I can use this inner join ...
mitomed's user avatar
  • 2,026
0 votes
1 answer
2k views

mysql update statement with a variable in a procedure

I createed a procedure which includes an update. There are two variables otherCategoryId and otherCategoryId. When I try to run the procedure on command line it gives me an error like: You have ...
tallica's user avatar
  • 13
1 vote
4 answers
120 views

How can I use WHERE id IN (@a_varchar_variable) in SQL Server stored procedures? [duplicate]

In my table id column's datatype is int. And I have a list of items' ids to be selected. So, here is some piece of my code: DECLARE @user_list SELECT @user_list=( SELECT user_list FROM sometable ...
MangMang's user avatar
  • 447
27 votes
4 answers
89k views

SQL Server : stored procedure transaction

Hello I got some stored procedures to create products and other stuff on my site. Now I have to run some of them in a transaction. Is that possible or do I have to make a stored procedure only for the ...
saadan's user avatar
  • 467
4 votes
2 answers
318 views

How can I be DRY in columns names in this MySQL procedure?

I'm referencig name, description and user_id columns of meta table. Twice, and maybe more (who knows?) in future. Those columns are used to compute the ETag of my meta resource. Adding one column ...
gremo's user avatar
  • 47.9k
0 votes
1 answer
257 views

MySQL cluster - Does distribution-aware query and stored procedure are conflict idea?

Both stored procedure and distribution-aware query are significant for MySQL Cluster performance. Stored procedure is used to reduce number of query transmission from client software to MySQL server. ...
Nites's user avatar
  • 125
1 vote
1 answer
957 views

Delphi Mysql Stored Procedure Single Quote Trouble

I have Delphi application with mydac stored procedure component which takes an utf8 encoded xml file's content as string parameter. It works with navicat and other db managment programs when I put ...
Alper's user avatar
  • 13
0 votes
1 answer
921 views

How to use a stored procedure for Entity Framework model?

Hi before I use to retrieve and manipulate data directly from my DB..but this time I am using Entity Data Model.. I have all the tables in my .edmx file .... I have some queries in my DB for ...
SoftwareNerd's user avatar
  • 1,885
0 votes
1 answer
184 views

Stored procedure and Linq to sql

If I write a stored procedure and invoke it using Linq-to-SQL and perform (or rather compose) few more queries on the resultant set, how will it be executed? Will the stored procedure execute first ...
Sam's user avatar
  • 933
1 vote
2 answers
1k views

Passing an argument to an Oracle Stored Procedure

This may have been asked before, so I'm sorry if this is repeated. If you can link to where I can find an answer, I would really appreciate it. I've looked around at other answers and on Google but ...
Sagar's user avatar
  • 9,484
1 vote
2 answers
82 views

Trouble with stored procedure for deleting least recent entries in a table

The query I have written is: delete from featured where featuredID IN( select top(@removeAmnt) * from featured order by featured.createdon asc) which doesn't appear to work. The error I get is, ...
xxyyxx's user avatar
  • 2,356
0 votes
0 answers
1k views

DbContext stored procedures oracle 11g

I am attempting to execute a stored procedure that has several in/out parameters. This is what the expected way of doing this with SQLServer would be. using (Context) { const ...
danmanallen's user avatar
1 vote
1 answer
1k views

SQL nested IF's not working

From the looks of it I've wrapped everything in the proper BEGIN...END statements, however the code goes through and executes almost every single line of code. I've done print statements too to make ...
NealR's user avatar
  • 10.4k
0 votes
1 answer
523 views

Get all values from one column of a CSV string using Stored Procedure

Within a stored procedure, I need to take a whole CSV file as a string, then pick out all the values in one "column" to do a further query on the database. I cannot use a saved doc - so i think that ...
JsAndDotNet's user avatar
  • 16.6k
0 votes
1 answer
645 views

To get the whole line while using Mysql LOAD DATA LOCAL INFILE

Need experts help to get whole original line using LOAD DATA LOCAL INFILE and put into my db column Sample table DROP TABLE IF EXISTS `syslog`; CREATE TABLE `syslog` ( `the_time` VARCHAR(80) NOT ...
Joe Ijam's user avatar
  • 2,149
0 votes
1 answer
2k views

SQL stored procedure not working properly

Below is the code for a stored procedure. The first part of the code works as it is supposed to. It takes the variables, does an INSERT into one table, then with the primary key created from that ...
NealR's user avatar
  • 10.4k
16 votes
6 answers
51k views

Query a SQL field for whether it contains any one of multiple values

I want to query the rows of SQL column for whether it contains any one of multiple values. For instance, return rows of a table where its column A contains any of the following words: ('cow','farmer',...
Matt's user avatar
  • 26.5k
0 votes
5 answers
151 views

SQL performance for a returning stored procedure

I have been asked the following question, what would you look into when you want to improve a stored procedure performance? The stored procedure is returning some value and have three joins in it. ...
sheidaei's user avatar
  • 10.1k
2 votes
2 answers
496 views

Increasingly long query times on stored procedure. - EXEC vs SP_EXECUTESQL

I am using a stored procedure to that returns a set of rows about the data in a varbinary column. I cannot, for the life of me, figure out why the query times always increase at the same rate when I ...
Mike Gwilt's user avatar
  • 2,439

1
598 599
600
601 602
742