Search Results

Search found 10815 results on 433 pages for 'stored procedure'.

Page 11/433 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • How to query on table returned by Stored procedure within a procedure.

    - by Shantanu Gupta
    I have a stored procedure that is performing some ddl dml operations. It retrieves a data after processing data from CTE and cross apply and other such complex things. Now this returns me a 4 tables which gets binded to various sources at frontend. Now I want to use one of the table to further processing so as to get more usefull information from it. eg. This table would be containing approx 2000 records at most of which i want to get records that belongs to lodging only. PK_CATEGORY_ID DESCRIPTION FK_CATEGORY_ID IMMEDIATE_PARENT Department_ID Department_Name DESCRIPTION_HIERARCHY DEPTH IS_ACTIVE ID_PATH DESC_PATH -------------------- -------------------------------------------------- -------------------- -------------------------------------------------- -------------------- -------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------- ----------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 Food NULL NULL 1 Food (Food) Food 0 1 0 Food 5 Chinese 1 Food 1 Food (Food) ----Chinese 1 1 1 Food->Chinese 14 X 5 Chinese 1 Food (Food) --------X 2 1 1->5 Food->Chinese->X 15 Y 5 Chinese 1 Food (Food) --------Y 2 1 1->5 Food->Chinese->Y 65 asdasd 5 Chinese 1 Food (Food) --------asdasd 2 1 1->5 Food->Chinese->asdasd 66 asdas 5 Chinese 1 Food (Food) --------asdas 2 1 1->5 Food->Chinese->asdas 8 Italian 1 Food 1 Food (Food) ----Italian 1 1 1 Food->Italian 48 hfghfgh 1 Food 1 Food (Food) ----hfghfgh 1 1 1 Food->hfghfgh 55 Asd 1 Food 1 Food (Food) ----Asd 1 1 1 Food->Asd 2 Lodging NULL NULL 2 Lodging (Lodging) Lodging 0 1 0 Lodging 3 Room 2 Lodging 2 Lodging (Lodging) ----Room 1 1 2 Lodging->Room 4 Floor 3 Room 2 Lodging (Lodging) --------Floor 2 1 2->3 Lodging->Room->Floor 9 First 4 Floor 2 Lodging (Lodging) ------------First 3 1 2->3->4 Lodging->Room->Floor->First 10 Second 4 Floor 2 Lodging (Lodging) ------------Second 3 1 2->3->4 Lodging->Room->Floor->Second 11 Third 4 Floor 2 Lodging (Lodging) ------------Third 3 1 2->3->4 Lodging->Room->Floor->Third 29 Fourth 4 Floor 2 Lodging (Lodging) ------------Fourth 3 1 2->3->4 Lodging->Room->Floor->Fourth 12 Air Conditioned 3 Room 2 Lodging (Lodging) --------Air Conditioned 2 1 2->3 Lodging->Room->Air Conditioned 20 With Balcony 12 Air Conditioned 2 Lodging (Lodging) ------------With Balcony 3 1 2->3->12 Lodging->Room->Air Conditioned->With Balcony 24 Mountain View 20 With Balcony 2 Lodging (Lodging) ----------------Mountain View 4 1 2->3->12->20 Lodging->Room->Air Conditioned->With Balcony->Mountain View 25 Ocean View 20 With Balcony 2 Lodging (Lodging) ----------------Ocean View 4 1 2->3->12->20 Lodging->Room->Air Conditioned->With Balcony->Ocean View 26 Garden View 20 With Balcony 2 Lodging (Lodging) ----------------Garden View 4 1 2->3->12->20 Lodging->Room->Air Conditioned->With Balcony->Garden View 52 Smoking 20 With Balcony 2 Lodging (Lodging) ----------------Smoking 4 1 2->3->12->20 Lodging->Room->Air Conditioned->With Balcony->Smoking 21 Without Balcony 12 Air Conditioned 2 Lodging (Lodging) ------------Without Balcony 3 1 2->3->12 Lodging->Room->Air Conditioned->Without Balcony 13 Non Air Conditioned 3 Room 2 Lodging (Lodging) --------Non Air Conditioned 2 1 2->3 Lodging->Room->Non Air Conditioned 22 With Balcony 13 Non Air Conditioned 2 Lodging (Lodging) ------------With Balcony 3 1 2->3->13 Lodging->Room->Non Air Conditioned->With Balcony 71 EA 3 Room 2 Lodging (Lodging) --------EA 2 1 2->3 Lodging->Room->EA 50 Casabellas 2 Lodging 2 Lodging (Lodging) ----Casabellas 1 1 2 Lodging->Casabellas 51 North Beach 50 Casabellas 2 Lodging (Lodging) --------North Beach 2 1 2->50 Lodging->Casabellas->North Beach 40 Fooding NULL NULL 40 Fooding (Fooding) Fooding 0 1 0 Fooding 41 Pizza 40 Fooding 40 Fooding (Fooding) ----Pizza 1 1 40 Fooding->Pizza 45 Onion 41 Pizza 40 Fooding (Fooding) --------Onion 2 1 40->41 Fooding->Pizza->Onion 47 Extra Cheeze 41 Pizza 40 Fooding (Fooding) --------Extra Cheeze 2 1 40->41 Fooding->Pizza->Extra Cheeze 77 Burger 40 Fooding 40 Fooding (Fooding) ----Burger 1 1 40 Fooding->Burger This result is being obtained to me using some stored procedure which contains some DML operations as well. i want something like this select description from exec spName where fk_category_id=5 Remember that this spName is returning me 4 tables of which i want to perform some query on one of the table whose index will be known to me. I dont have to send it to UI before querying further. I am using Sql Server 2008 but would like a compatible solution for 2005 also.

    Read the article

  • Does this mySQL Stored Procedure Work?

    - by Laxmidi
    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 LINESTRING; DECLARE poly1 POINT; DECLARE poly1X DECIMAL(9,6); DECLARE poly1Y DECIMAL(9,6); DECLARE poly2 POINT; DECLARE poly2X DECIMAL(9,6); DECLARE poly2Y DECIMAL(9,6); DECLARE i INT DEFAULT 0; DECLARE result INT(1) DEFAULT 0; SET pX = X(p); SET pY = Y(p); SET ls = ExteriorRing(poly); SET poly2 = EndPoint(ls); SET poly2X = X(poly2); SET poly2Y = Y(poly2); SET n = NumPoints(ls); WHILE i<n DO SET poly1 = PointN(ls, (i+1)); SET poly1X = X(poly1); SET poly1Y = Y(poly1); IF ( ( ( ( poly1X <= pX ) && ( pX < poly2X ) ) || ( ( poly2X <= pX ) && ( pX < poly1X ) ) ) && ( pY > ( poly2Y - poly1Y ) * ( pX - poly1X ) / ( poly2X - poly1X ) + poly1Y ) ) THEN SET result = !result; END IF; SET poly2X = poly1X; SET poly2Y = poly1Y; SET i = i + 1; END WHILE; RETURN result; End; Usage: SET @point = PointFromText('POINT(5 5)') ; SET @polygon = PolyFromText('POLYGON((0 0,10 0,10 10,0 10))') ; SELECT myWithin(@point, @polygon) AS result ; I'm using phpMyAdmin and it blows up when using stored procedures. If this one works, then I'll try to figure out how to call it in php instead. Thanks, Laxmidi

    Read the article

  • Calling MSSQL stored procedure from Zend Controller ? Any other approaches?

    - by Bhavin Rana
    MSSQL and DB, Zend as PHP Framework, I am using this way to call SP with I/P Parameters and to get O/p Parameters. It seems I am writing SQL code in PHP. Any other good approaches? $str1 = "DECLARE @Msgvar varchar(100); DECLARE @last_id int; exec DispatchProduct_m_Ins $DispatchChallanId,'$FRUNo',$QTY,$Rate,$Amount, ".$this->cmpId.",".$this->aspId.",".$this->usrId.",@Msg = @Msgvar OUTPUT,@LAST_ID = @last_id OUTPUT; SELECT @Msgvar AS N'@Msg',@last_id AS '@LAST_ID'; ";//Calling SP $stmt = $db->prepare($str1); $stmt->execute(); $rsDispProd = $stmt->fetchAll(); $DispatchProductId = $rsDispProd[0]["@LAST_ID"];//get last ins ID as O/p Parameter

    Read the article

  • Stored procedure execution problem

    - by geeta
    Iam implementing entity spaces in C# application and was able to execute queries such as the below one successfully. coll.query.where(coll.prodlineid.equal("id") if( coll.query.load()) However I need to replace all these queries in the code with Stored procedures. For this I used: coll.Load(esQuerytype.storedprocedure, "testproc", param) At this point, Iam getting error as 'EntitySpaces.Core.esEntityCollection.Load(EntitySpaces.DynamicQuery.esQueryType, string, params object[])' is inaccessible due to its protection level esEntityCollection is a metadata file, so I could not change the access modifier there from protected to public. Help:-)

    Read the article

  • Why (and when to) use stored procedures?

    - by mr.b
    What would be appropriate scenario when stored procedures should be used? I stumbled upon implementation where almost whole data manipulation was handled by store procedures, even simplest form of INSERT/DELETE statements were wrapped and used via SP's. So, what's the rationale for using stored procedures in general? Sorry for such a beginners question..

    Read the article

  • Changing Database Name In Stored Procedures

    - by Semih
    Hi, I need to change the database name in SQL SERVER 2008 and use it in another project. However it consist hundreds of stored procedures and the name of the database should be changed in the stored procedures as well. Is there any way to do this?

    Read the article

  • SQL Server stored procedure in multi threaded environments

    - by Shamika
    Hi, I need to execute some Sql server stored procs in a thread safe manner. At the moment I'm using software locks (C# locks) to achieve this but wonder what kind of features provided by the Sql server itself to achieve thread safety. It seems to be there are some table and row locking features built in to Sql server. Also from a performance perspective what is best approach? Software locks? Or Sql Server built in locks? Thanks, Shamika

    Read the article

  • C# Winforms - SQL Server 2005 stored procedure - parameters from TextBox

    - by Geo Ego
    I'm trying to call a parameterized stored procedure from SQL Server 2005 in my C# Winforms app. I add the parameters like so (there are 88 of them): cmd.Parameters.Add("@CustomerName", SqlDbType.VarChar, 100).Value = CustomerName.Text; I get the following exception: "System.InvalidCastException: Failed to convert parameter value from a TextBox to a String. ---> System.InvalidCastException: Object must implement IConvertible." The line throwing the error is when I call the query: cmd.ExecuteNonQuery(); I also tried using the .ToString() method on the TextBoxes, which seemed pointless anyway, and threw the same error. Am I passing the parameters incorrectly? Thanks for the help.

    Read the article

  • Call stored procedure using Spring SimpleJdbcCall with callback

    - by MFIhsan
    I have an Oracle Stored procedure that takes CLOB input and REFCURSOR output. I invoke the SP via Spring SimpleJdbcCall passing in a RowMapper to map the results. However, since the result set is large, I need to provide callback feature to the client. I can't quite figure out how to add callback for an SP call using Spring - both with and without SimpleJdbcCall. One thought I have is to pass-in a RowCallbackHandler. Will this work or is there a better way to solve this problem? Any help here is appreciated. private Map<String, Object> arguments = ...; SimpleJdbcCall jdbcCall = new SimpleJdbcCall(this.jdbcTemplate) .withCatalogName(this.packageName) .withProcedureName(this.storedProcName) .withoutProcedureColumnMetaDataAccess() .declareParameters(this.outputParameters.toArray(new SqlOutParameter[]{})); if(!isEmpty(inputParameters)) { jdbcCall.declareParameters(inputParameters.toArray(new SqlParameter[]{})); } this.outputParameters.add(new SqlOutParameter(outputParamName, VARCHAR, rowMapper)); jdbcCall.execute(arguments);

    Read the article

  • Clob as param for PL/SQL Java Stored Procedure

    - by JDS
    I have a java stored procedure that takes in a clob representing a chunk of javascript and mins it. The structure of the function calling the JSP is as follows: function MIN_JS(pcl_js in clob) return clob as language java name 'JSMin.min(oracle.sql.CLOB) return oracle.sql.CLOB'; In the actual JSP, I have the following: import oracle.sql.CLOB; public class JSMin { ... public static min(CLOB js) { ... } The problem I'm having is that whenever I pass a clob to JS_MIN, it is always interpreted as null inside the JSP. I've checked the clob before calling JS_MIN annd it definitely has contents. Any ideas as to what I'm missing? Any help is greatly appreciated.

    Read the article

  • MySQL Stored Procedure: Boolean Logic in IF THEN

    - by xncroft
    I'm looking for the proper syntax (if this is possible in MySQL stored procedures) for using logical operators in an IF THEN statement. Here's something along the lines of what I would like to do, but I'm not certain if I should type "OR" or "||" in the IF ... THEN clause: DELIMITER $$ CREATE PROCEDURE `MyStoredProc` (_id INT) BEGIN DECLARE testVal1 INT DEFAULT 0; DECLARE testVal2 INT DEFAULT 0; SELECT value1, value2 INTO testVal1, testVal2 FROM ValueTable WHERE id = _id; IF testVal1 > 0 OR testVal2 > 0 THEN UPDATE ValueTable SET value1 = (value1+1) WHERE id=_id; END IF; END$$

    Read the article

  • SQL Server catch error from extended stored procedure

    - by haxelit
    Hello I have an extended stored procedure that sends an error message. srv_sendmsg(pSrvProc, SRV_MSG_ERROR, errorNum, SRV_FATAL_SERVER, 1, NULL, 0, (DBUSMALLINT) __LINE__, buff, SRV_NULLTERM); I've set the severity to SVR_FATAL_SERVER just as a test to see if I can cause the message to throw an exception in the sql. In my SQL i'm doing: BEGIN TRY EXEC dbo.xp_somethingCool SET @Error = @@ERROR END TRY BEGIN CATCH PRINT 'AN Error occoured!' SELECT ERROR_NUMBER() AS ErrorNumber ,ERROR_MESSAGE() AS ErrorMessage; END CATCH I would think that when my xp sends the error message the tsql would catch the error and select the error_number and error_message. Instead what ends up happening is that the xp sends the message and the T-SQL continues on its way like nothing happened. The @@Error variable doesn't get set either. So I was wondering if there was any trick to getting SQL to catch an error from an XP ? Thanks, Raul

    Read the article

  • SQL Server Cursor data as result of stored procedure

    - by Dmitry Borovsky
    Hello, I have a stored procedure DECLARE cursor FOR SELECT [FooData] From [FooTable]; OPEN cursor ; FETCH NEXT FROM cursor INTO @CurrFooData; WHILE @@FETCH_STATUS = 0 BEGIN SELECT @CurrFooData AS FooData; INSERT INTO Bar (BarData) VALUES(@CurrFooData); FETCH NEXT FROM cursor INTO @CurrFooData; END; CLOSE cursor DEALLOCATE cursor But in result I have a lot of tables, not one. How can I return one table with 'FooData' column and all '@CurrFooData' rows?

    Read the article

  • Pick Return Values of Stored Procedure

    - by Juergen
    Hi, I have a stored procedure that returns a result with 250!!! columns. But I only need 3 out of the 250. I want to call the SP and put only the 3 column values in a temp table. I don't want to define a temp table with 250 columns! This is how I would like to do it, but this doesn't work of course: create #myTempTable (id int, value1 int, value2 int) insert into #myTempTable exec myBigFatStoredProc Can it be done anyhow? Bye Juergen

    Read the article

  • MSSQL 2000 Stored Procedure to Split Shift Times

    - by JClaspill
    I am being asked to alter a system to include the ability to have pay differentials based on hours worked. The old method included a stored procedure (MSSQL2000 db) that did the basics, but simply knows the start and end of every shift. So, this is the information I start with: EMPLOYEE | TYPE | HOURS | INSTAMP | OUTSTAMP Dave | Hourly | 8.643055 | 2011-01-08 07:57:35.557 | 2011-01-08 16:36:10.120 And I need to turn that into something like: EMPLOYEE | TYPE | HOURS | INSTAMP | OUTSTAMP Dave | Hourly | 4.00 | 2011-01-08 08:00:00.000 | 2011-01-08 12:00:00.000 Dave | ShiftDiff1 | 4.50 | 2011-01-08 12:00:00.000 | 2011-01-08 16:30:00.000 The ShiftDiff's range from hours to certain days, to a combo of both. Should I try to make the SQL2000 SP do this or pass the info back to my ASP.NET(C#) app and let it handle it, then send back?

    Read the article

  • MS SQL Cursor data as result of stored procedure

    - by Dmitry Borovsky
    Hello, I have some stored procedure DECLARE cursor FOR SELECT [FooData] From [FooTable]; OPEN cursor ; FETCH NEXT FROM cursor INTO @CurrFooData; WHILE @@FETCH_STATUS = 0 BEGIN SELECT @CurrFooData AS FooData; INSERT INTO Bar (BarData) VALUES(@CurrFooData); FETCH NEXT FROM cursor INTO @CurrFooData; END; CLOSE OldestFeeds DEALLOCATE OldestFeeds But in result I have a lot of tables, not one. How can I return one table with 'FooData' column and all '@CurrFooData' rows?

    Read the article

  • Calling Stored Procedure from VB.net timeout error

    - by Jim
    When calling a stored procedure from vb.net is there a default SQL timeout time if no timeout is specified in the connection string? I am unsure if there is a CommandTimeout specified in the connection string but am going through all the possibilites. Example if no results after 30 seconds (or more) throw: `System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.` SQL Profiler says that the script runs and ends in 30 seconds when the program timesout.. Tthe script runs without error in about 1 minute 45 seconds by itself in SQL server.

    Read the article

  • Linq to SQl Stored Procedure Problem( it can't figure out the return type)

    - by chobo2
    Hi I have this SP USE [Test] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[UsersInsert](@UpdatedProdData XML) AS INSERT INTO dbo.UserTable(UserId,UserName,LicenseId,Password,PasswordSalt,Email,IsApproved,IsLockedOut,CreateDate, LastLoginDate,LastLockOutDate,FailedPasswordAttempts,RoleId) SELECT @UpdatedProdData.value('(/ArrayOfUsers/Users/UserId)[1]', 'uniqueidentifier'), @UpdatedProdData.value('(/ArrayOfUsers/Users/UserName)[1]', 'varchar(20)'), @UpdatedProdData.value('(/ArrayOfUsers/Users/LicenseId)[1]', 'varchar(50)'), @UpdatedProdData.value('(/ArrayOfUsers/Users/Password)[1]', 'varchar(128)'), @UpdatedProdData.value('(/ArrayOfUsers/Users/PasswordSalt)[1]', 'varchar(128)'), @UpdatedProdData.value('(/ArrayOfUsers/Users/Email)[1]', 'varchar(50)'), @UpdatedProdData.value('(/ArrayOfUsers/Users/IsApproved)[1]', 'bit'), @UpdatedProdData.value('(/ArrayOfUsers/Users/IsLockedOut)[1]', 'bit'), @UpdatedProdData.value('(/ArrayOfUsers/Users/CreateDate)[1]', 'datetime'), @UpdatedProdData.value('(/ArrayOfUsers/Users/LastLoginDate)[1]', 'datetime'), @UpdatedProdData.value('(/ArrayOfUsers/Users/LastLockOutDate)[1]', 'datetime'), @UpdatedProdData.value('(/ArrayOfUsers/Users/FailedPasswordAttempts)[1]', 'int'), @UpdatedProdData.value('(/ArrayOfUsers/Users/RoleId)[1]', 'int') Now this SP creates just fine. It's when I go to VS2010 and try to drag this SP in my method panel of my linq to sql file in design view. It tells me that it can't figure out the return type. I try to go to the properties but it does not have "none" as a choice and I can't type it in. It should be "none" so how do I set it to "none"?

    Read the article

  • Looping over some selected values in a stored procedure

    - by macca1
    I'm trying to modify a stored procedure hooked into an ORM tool. I want to add a few more rows based on a loop of some distinct values in a column. Here's the current SP: SELECT GRP = STAT_CD, CODE = REASN_CD FROM dbo.STATUS_TABLE WITH (NOLOCK) Order by STAT_CD, SRT_ORDR For each distinct STAT_CD, I'd also like to insert a REASN_CD of "--" here in the SP. However I'd like to do it before the order by so I can give them negative sort orders so they come in at the top of the list. I'm getting tripped up on how to implement this. Does anyone know how to do this for each unique STAT_CD?

    Read the article

  • Stored procedure does not return data if executed from VBA

    - by Sam
    I had stored procedure MySPOld in Sybase db. I created new sp MySP. This new sp returns data while executed from Sybase Sql Advantage. But not returning the data when called from VBA - Excel 2003 (EOF property of recordset is True). Here is my code.. Dim dbCon As ADODB.Connection Dim rstTemp As New ADODB.Recordset Dim query As String query = "exec MySP '01/01/2010', '01/14/2010'" dbCon.Open connectionString, "username" "password" dbCon.CommandTimeout = 300 rstTemp.Open query, dbCon, adOpenForwardOnly The code was working well with old sp. What could be the problem ? any idea ? Thanks in Advance.

    Read the article

  • Why can't I pass in a uniqueidentifier/GUID to a stored procedure

    - by chobo2
    Hi I have this SP USE [TestDB] GO /****** Object: StoredProcedure [dbo].[sp_test] Script Date: 06/12/2010 11:47:27 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[sp_test] @id uniqueidentifier AS BEGIN select * from TestTbl where ProductId= @id END I then went to the SP with ms sql 2005 and clicked execute. It comes up with a box where I entered in the GUID. I copied and pasted it straight from my test database. I get this error. Msg 102, Level 15, State 1, Line 5 Incorrect syntax near 'cac671b'. So why can't I sent in GUIDs? even ones that are copied right from the database and must be valid as they where allowed into the db.

    Read the article

  • SQL Server Stored Procedure that return processed records number

    - by Ras
    I have a winform application that fires a Stored Procedure which elaborates several records (around 500k). In order to inform the user about how many record have been processed, I would need a SP which returns a value every n records. For example, every 1000 row processed (most are INSERT). Otherwise I would be able only to inform when ALL record are processed. Any hints how to solve this? I thought it could be useful to use a trigger or some scheduled task, but I cannot figure out how to implement it.

    Read the article

  • Pass in Dynamic number of parameters to a stored procedure

    - by xrum
    Hi, I have a function in my .NET application, that needs to do a search of an unknown number of parameters. for example: select * from tbl where x=1 or x=2 or x=3 or x=4 is it possible to do in .NEt and SQL? how do i go about creating dynamic parameters in .NET (I was thinking doing it with a loop) but then how do i declare them in my stored procedure? does sql have arrays? please help. thank you!

    Read the article

  • Sql server Stored Procedure

    - by user177883
    I m passing a variable to stored procedure, i want the proc to make a look up to another table and get the primary key of the table and insert that value to the table. Table A: pk_id int, user varchar Table B: userKey int When i invoke sp_howto, and pass user to it, i want to it to get the pk_id from table A and insert it to table B userKey. @res = select userKey from TableA where user=@user insert into tableB (userKey) values (@res) Does this work? and what if I have many keys I want to populate like this?

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >