stored-procedures

Problem with Postgres FOR LOOP

Hi all, Ich have a problem in postgres function: CREATE OR REPLACE FUNCTION linkedRepoObjects(id bigint) RETURNS int AS $$ DECLARE catNumber int DEFAULT 0; DECLARE cat RECORD; BEGIN WITH RECURSIVE children(categoryid,category_fk) AS ( SELECT categoryid, category_fk ...

tsql - using internal stored procedure as parameter is where clause

Hi all, I'm tryng to build a stored procedure that makes use of another stored proceudre. Taking its result and using it as part of its where clause, from some reason I receive an error: Invalid object name 'dbo.GetSuitableCategories'. Here is a copy of the code: select distinct top 6 * from ( SELECT TOP 100 * FROM [dbo].[produ...

Why Am I Getting MySQL Error #1312 when Using a Simple Stored Procedure?

Hi, I'm trying to learn how to use MySQL stored procedures. MySQL accepted my procedure: CREATE PROCEDURE SimpleProc() BEGIN SELECT * FROM myTable; END (In phpMyAdmin, I set // for delimiter. The real version has the name of an actual table instead of myTable.). But, when I call the procedure with CALL SimpleProc();, I get...

Insert Stored Procedure does not Create Database Record

Hello All, I have the following stored procedure: ALTER PROCEDURE Pro_members_Insert @id int outPut, @LoginName nvarchar(50), @Password nvarchar(15), @FirstName nvarchar(100), @LastName nvarchar(100), @signupDate smalldatetime, @Company nvarchar(100), @Phone nvarchar(50), @Email nvarchar(150), @Address nvarchar(255), @Pos...

Unit Testing, IDataContext and Stored Procedures via Linq

hey folks, I'm currently using Stephen Walther's approach to unit testing Linq to SQL and the datacontext (http://stephenwalther.com/blog/archive/2008/08/17/asp-net-mvc-tip-33-unit-test-linq-to-sql.aspx) which is working a treat for all things linq. My Dal layer takes in an IDataContext, I use DI (via Unity) to concrete that up as the ...

How to configure outgoing connections from an SQL stored procedure?

I am working on a .NET project which uses Microsoft SQL server. In this project, I need a CLR stored procedure (written in C#) that uses a remote web service. So, when the stored procedure is executed on the SQL server, it makes web service calls and thus sends packets to a remote location. The problem is that when executing the SP I get...

Parameters in stored procedures in SQL Server

How many types of parameters are there in a stored procedures and what are they? Thanks in advance. And can we delete a table using view? I think yes but in what situation we can't delete it if there are no trigger associated with that table. I mean to say i need to delete a table which has no trigger associated with it using view, in w...

Does this mySQL Stored Procedure Work?

Hi, I got the following stored procedure from http://dev.mysql.com/doc/refman/5.1/en/functions-that-test-spatial-relationships-between-geometries.html Does this work? CREATE FUNCTION myWithin(p POINT, poly POLYGON) RETURNS INT(1) DETERMINISTIC BEGIN DECLARE n INT DEFAULT 0; DECLARE pX DECIMAL(9,6); DECLARE pY DECIMAL(9,6); DECLARE ls...

calculated column or stored procedure or just php function needed ?

I have an order table in MySQL database, having a field/column which stores the date timestamp of when the order was placed. I need to calculate when the order must be shipped. I could probably figure out how to write a function to calculate the ship date and call that when ever needed but I think, not sure it may make more sense to ha...

How to write a stored procedure using phpmyadmin and how to use it through php?

I want to create stored procedures through phpmyadmin and later on use it on php. But I dont know how to?. From what I know, I found out that, we cannot manage stored procedures through phpmyadmin. What other tool can manage stored procedure? And I am not sure if it is better option to use stored procedure instead? ...

SQL Stored Procedure fails to update data while the script in it works manually

I have a SQL Script that I execute in a job to transform tables periodically. To speed it up I put that script in a stored procedure and executed it with a job. It worked faster. The problem occurs at times when the stored procedure even though it executes it doesn't work. I use the script manually and run it and everything works fine....

When to use Stored Procedures instead of using any ORM with programming logic?

Hi all I wanted to know when I should prefer writing stored procedures over writing programming logic and pulling data using a ORM or something else. ...

Doubt in Stored Procedure MySql - how to return multiple values for a variable ?

Hi, I have a stored procedure below. I intend this procedure to return the names of all the movies acted by an actor. Create Procedure ActorMovies( In ScreenName varchar(50), OUT Title varchar(50) ) BEGIN Select MovieTitle INTO Title From Movies Natural Join Acts where Acts.ScreenName = 'ScreenName '; End; I mak...

SQL Server 2008 stored procedure result as column default value

First of all, thank you guys. You always know how to direct me when I can't even find the words to explain what the heck I'm trying to do. The default values of the columns on a couple of my tables need to be equal the result of some complicated calculations on other columns in other tables. My first thought is to simply have the column...

Using dbtype.structure with SubSonic 2?

When sending data to a stored procedure through SubSonic, how can I pass a dbtype.structure? I have a TVP defined as READONLY, and when SubSonic generates the StoredProcedures.cs file, the parameter shows up as a string type. What is the way to accomplish this? Thank you. ...

How to capture input parameters from within stored procedure (SQL Server 2005)?

I would like to create a generic logging solution for my stored procedures, allowing me to log the values of input parameters. Currently I am doing this more or less by hand and I am very unhappy with this approach. Ideally, I would like to say something like the following: "given my spid, what are my input parameters and their values...

Obtain stored procedure metadata for a procedure within an Oracle package using ADO.NET

Hi, I am trying to obtain the stored procedure metadata (procedure name,parameter types,parameter names etc) for a procedure declared within an Oracle package, using the standard ADO.NET API - DbConnection.GetSchema call. I am using the ODP driver. I see that the Package is listed in the 'Packages' and 'PackageBodies' metadata collecti...

INSERT stored procedure does not work?

Hello, I'm trying to make an insertion from one database called suspension to the table called Notification in the ANimals database. My stored procedure is this: ALTER PROCEDURE [dbo].[spCreateNotification] -- Add the parameters for the stored procedure here @notRecID int, @notName nvarchar(50), ...

SQL-Server: Is there an equivalent of a trigger for general stored procedure execution

Hi All, Hope you can help. Is there a way to reliably detect when a stored proc is being run on SQL Server without altering the SP itself? Here's the requirement. We need to track users running reports from our enterprise data warehouse as the core product we use doesn't allow for this. Both core product reports and a slew of in-hous...

Stored procedure woes ... inserting binary ...

Ok so I have this storedproc in my SQL 2008 database (works in 2005 too / used to) ... CREATE PROCEDURE [dbo].[SetBinaryContent] @Ref nvarchar(50), @Content varbinary(MAX), @ObjectID uniqueidentifier AS BEGIN DELETE ObjectContent WHERE ObjectId = @ObjectID AND Ref = @Ref IF DATALENGTH(@Content) > 5 BEGIN ...