Search Results

Search found 1372 results on 55 pages for 'userid'.

Page 9/55 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • LINQ-SQL Updating Multiple Rows in a single transaction

    - by RPM1984
    Hi guys, I need help re-factoring this legacy LINQ-SQL code which is generating around 100 update statements. I'll keep playing around with the best solution, but would appreciate some ideas/past experience with this issue. Here's my code: List<Foo> foos; int userId = 123; using (DataClassesDataContext db = new FooDatabase()) { foos = (from f in db.FooBars where f.UserId = userId select f).ToList(); foreach (FooBar fooBar in foos) { fooBar.IsFoo = false; } db.SubmitChanges() } Essentially i want to update the IsFoo field to false for all records that have a particular UserId value. Whats happening is the .ToList() is firing off a query to get all the FooBars for a particular user, then for each Foo object, its executing an UPDATE statement updating the IsFoo property. Can the above code be re-factored to one single UPDATE statement? Ideally, the only SQL i want fired is the below: UPDATE FooBars SET IsFoo = FALSE WHERE UserId = 123 EDIT Ok so looks like it cant be done without using db.ExecuteCommand. Grr...! What i'll probably end up doing is creating another extension method for the DLINQ namespace. Still require some hardcoding (ie writing "WHERE" and "UPDATE"), but at least it hides most of the implementation details away from the actual LINQ query syntax.

    Read the article

  • Convert sql query

    - by nisha
    I have used this query in sql,pls convert this query to use for access database. Table structure is UserID,Username,LogDate,LogTime WITH [TableWithRowId] as (SELECT ROW_NUMBER() OVER(ORDER BY UserId,LogDate,LogTime) RowId, * FROM @YourTable), [OddRows] as (SELECT * FROM [TableWithRowId] WHERE rowid % 2 = 1), [EvenRows] as (SELECT *, RowId-1 As OddRowId FROM [TableWithRowId] WHERE rowid % 2 = 0) SELECT [OddRows].UserId, [OddRows].UserName, [OddRows].LogDate, [OddRows].LogTime, [EvenRows].LogDate, [EvenRows].LogTime FROM [OddRows] LEFT JOIN [EvenRows] ON [OddRows].RowId = [EvenRows].OddRowId

    Read the article

  • How to use Linq To Sql to get Users who has less than 2 photos?

    - by Mike108
    The scenario is I want to get the users who has less than 2 photos. There are two table: [Users] (UserId, UserName) [UserPhotos] (PhotoId, PhotoName, UserId) UserId is a Foreign Key but I do not want to use association like user.Photos. A user may have none photo in the [UserPhotos] table. How to use Linq To Sql to get List<User> who has less than 2 photos?

    Read the article

  • How to display multiple images?

    - by misterwebz
    I'm trying to get multiple image paths from my database in order to display them, but it currently doesn't work. Here's what i'm using: def get_image(self, userid, id): image = meta.Session.query(Image).filter_by(userid=userid) permanent_file = open(image[id].image_path, 'rb') if not os.path.exists(image.image_path): return 'No such file' data = permanent_file.read() permanent_file.close() response.content_type = guess_type(image.image_path)[0] or 'text/plain' return data I'm getting an error regarding this part: image[id].image_path What i want is for Pylons to display several jpg files on 1 page. Any idea how i could achieve this?

    Read the article

  • basic JSON pulling data help..

    - by Webby
    New to json data and struggling i guess the answer is real easy but been bugging me for the last hour.. Sample data { "data": { "userid": "17", "dates": { "timestame": "1275528578", }, "username": "harino54", } } Ok I can pull userid or username easy enough with echo "$t->userid" or echo "$t->username " but how do I pull data from the brackets within ? in this case timestame? cant seem to figure it out.. any ideas?

    Read the article

  • inserting array into database table in single query

    - by Praveen Prasad
    iam having an array of items like [item1,itmem2,item3]; i have to insert these items at a particular userId: final results look like this UserId ItemId 2 || item1 2 || item2 2 || item3 currently iam looping through the array in php code and inserting each item one by one eg foreach($items as $item) { insert into items (UserId,ItemId) value (2,$item); } is it possible i can insert all entries in single query.

    Read the article

  • Using Maven to Deploy to Weblogic Clusters

    - by Mark Sailes
    org.codehaus.mojo weblogic-maven-plugin 2.9.1 We're currently using the weblogic maven plugin successfully to deploy to our local WebLogic 9.2 instances. When we try to deploy to a remote environment we have a problem. We use a two machine cluster, with the admin server and managed server on one machine, and another managed server on a seperate machine. When your plugin uploads the application to the admin server, it doesn't copy it to the second managed server on the seperate machine. This then causes the second managed server a problem, as it cannot find the application in the location where the admin server saved it on its own machine. Config below <configuration> <adminServerHostName>${weblogic.adminServerHostName}</adminServerHostName> <adminServerPort>${weblogic.adminServerPort}</adminServerPort> <adminServerProtocol>${weblogic.adminServerProtocol}</adminServerProtocol> <userId>${weblogic.userId}</userId> <password>${weblogic.password}</password> <upload>${weblogic.upload}</upload> <remote>${weblogic.remote}</remote> <verbose>${weblogic.verbose}</verbose> <debug>${weblogic.debug}</debug> <stage>${weblogic.stage}</stage> <targetNames>${weblogic.targetNames}</targetNames> <exploded>${weblogic.exploded}</exploded> </configuration> <profile> <id>localhost</id> <properties> <weblogic.adminServerHostName>localhost</weblogic.adminServerHostName> <weblogic.adminServerPort>7001</weblogic.adminServerPort> <weblogic.adminServerProtocol>t3</weblogic.adminServerProtocol> <weblogic.userId>weblogic</weblogic.userId> <weblogic.password>weblogic</weblogic.password> <weblogic.upload>false</weblogic.upload> <weblogic.remote>false</weblogic.remote> <weblogic.verbose>true</weblogic.verbose> <weblogic.debug>true</weblogic.debug> <weblogic.stage>false</weblogic.stage> <weblogic.targetNames>AdminServer</weblogic.targetNames> <weblogic.exploded>false</weblogic.exploded> </properties> </profile> <profile> <id>dev</id> <properties> <weblogic.adminServerHostName>******</weblogic.adminServerHostName> <weblogic.adminServerPort>9141</weblogic.adminServerPort> <weblogic.adminServerProtocol>t3</weblogic.adminServerProtocol> <weblogic.userId>******</weblogic.userId> <weblogic.password>******</weblogic.password> <weblogic.upload>true</weblogic.upload> <weblogic.remote>true</weblogic.remote> <weblogic.verbose>true</weblogic.verbose> <weblogic.debug>true</weblogic.debug> <weblogic.stage>true</weblogic.stage> <weblogic.targetNames>dev_cluster01</weblogic.targetNames> <weblogic.exploded>false</weblogic.exploded> </properties> </profile>

    Read the article

  • Flex + PHP + ValueObjects

    - by Tempname
    I have a php/flex value object that I am using to transmit data to/from in my application. Everything works great php-flex, but I am having an issue with flex-php. In my MergeTemplateService.php service I have the following code. This is the method that flex hits directly: function updateTemplate($valueObject){ $object = DAOFactory::getMergeTemplateDAO()->update($valueObject); return $object; } I am passing a value object that from flex looks like this: (com.rottmanj.vo::MergeTemplateVO)#0 communityID = 0 creationDate = (null) enterpriseID = 0 lastModifyDate = (null) templateID = 2 templateName = "My New Test Template" userID = 0 The issue I am having is that my updateTemplate method sees the value object as an array and not an object. In my amfphp globals.php I have set my voPath as: $voPath = "services/class/dto/"; Any help with this is greatly appreciated Here are my two value objects: AS3 VO: package com.rottmanj.vo { [RemoteClass(alias="MergeTemplate")] public class MergeTemplateVO { public var templateID:int; public var templateName:String; public var communityID:int; public var enterpriseID:int; public var userID:int; public var creationDate:String; public var lastModifyDate:String public function MergeTemplateVO(data:Object = null):void { if(data != null) { templateID = data.templateID; templateName = data.templateName; communityID = data.communityID; enterpriseID = data.enterpriseID; userID = data.userID; creationDate = data.creationDate; lastModifyDate = data.lastModifyDate; } } } } PHPVO: <?php class MergeTemplate{ var $templateID; var $templateName; var $communityID; var $enterpriseID; var $userID; var $creationDate; var $lastModifyDate; var $_explictType = 'MergeTemplate'; } ?>

    Read the article

  • LINQ to SQL filter combobox output

    - by Brendan
    OK so I've got 2 tables for this instance, Users{UserID, Name}, Company{CompanyID, UserID, Name, Payrate} i also have 2 combo boxes, first one is for Users which Displays Name, and the Value is UserID i need the second combobox to get the Names from the Company table, but only showing Companies that are relevant to the selected user. I cant work out how to get it to go... Any ideas???

    Read the article

  • using PIVOT to sql server.

    - by NoviceToDotNet
    This is the abstract idea which i want to do by my first select of first line, i am presenting here, but i am unable to do that correct. here category[0], category[2]..etc representing the category columns values...i know this kind of syntax not work, but i want to do something like this. SELECT category[0], category[1], category[2], category[3], category[4], category[5] FROM( select Row_number() OVER(ORDER BY (SELECT 1)) AS 'Serial Number', EP.FirstName,Ep.LastName, Ep.SignUpID, [dbo].[GetBookingRoleName](ES.UserId,EP.BookingRole) as RoleName, (select top 1 convert(varchar(10),eventDate,103)from [3rdi_EventDates] where EventId=@ItemId) as EventDate, (CASE [dbo].[GetBookingRoleName](ES.UserId,EP.BookingRole) WHEN 'Employee - Marketing' THEN 'DC' WHEN 'Employee - Accounting' THEN 'DC' WHEN 'Coaches' THEN 'DC' WHEN 'Student Client' THEN 'ST' WHEN 'Guest Doctor' THEN 'GDC' ---....more categories here, i just removed a few END) as Category from [3rdi_EventParticipants] as EP inner join [3rdi_EventSignup] as ES on EP.SignUpId = ES.SignUpId WHERE EP.EventId = @ItemId AND EP.PlaceStatus IN (0,3,4,8) and userid in( select distinct userid from userroles where roleid not in(19,20,21,22) and roleid not in(1,2, 25, 44)) (My Below Query) PIVOT(sum(First_Name+Last_Name)) FOR Category (category[0], category[1], category[2], category[3], category[4], category[5]) Group by (SignUpID)

    Read the article

  • Is Mysql IF EXIST what should be used for this query?

    - by acctman
    select social_members.* , social_mcouple.* WHERE m_id='".$_SESSION['userid']."' AND c_id='".$_SESSION['userid']."' Select all fields from social_members.* and if social_mcouple.c_id = $_SESSION['userid'] then Select all fields from social_mcouple.* as well. Can this be done with IF EXIST and if so how. Thanks

    Read the article

  • get data from to tables !

    - by mehdi
    i want to sort my users based on most viewed profile in my user list . i have these two tables but i don't know how to right correct query to make this happen . i used grouping like this : $sql ="select userid , count(*) form profile_visit group by userid " ; but it's not make sense to me , i don't think this query will help me at all . +-----------+---------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+---------------+------+-----+-------------------+----------------+ | userid | int(11) | NO | PRI | NULL | auto_increment | | username | varchar(128) | NO | | NULL | | | password | char(40) | NO | | NULL | | | email | varchar(128) | NO | | NULL | | | name | varchar(256) | NO | | NULL | | | lastname | varchar(256) | NO | | NULL | | | job | varchar(256) | NO | | NULL | | | birthdate | varchar(100) | NO | | NULL | | | address | varchar(1024) | NO | | NULL | | | website | varchar(100) | NO | | NULL | | | tel | varchar(100) | NO | | NULL | | | role | tinyint(1) | NO | | 0 | | | reg_date | timestamp | NO | | CURRENT_TIMESTAMP | | +-----------+---------------+------+-----+-------------------+----------------+ and profile_visit table like this +------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | ip_address | varchar(70) | NO | | NULL | | | userid | int(11) | NO | | NULL | | +------------+-------------+------+-----+---------+----------------+

    Read the article

  • Double Inner Join generates unexpected error

    - by Itamar Marom
    In my database I have three tables: Users: UserID (Auto Numbering), UserName, UserPassword and a few other unimportant fields. PrivateMessages: MessageID (Auto Numbering), SenderID and a few other fields defining the message content. MessageStatus: MessageID, ReceiverID, MessageWasRead (Boolean) What I need is a query to which I input a user's id and I get all the private messages he has received. In addition, I also need to receive each message's sender UserName. For this I wrote the following query: SELECT Users.*, PrivateMessages.*, MessageStatus.* FROM PrivateMessages INNER JOIN Users ON PrivateMessages.SenderID = Users.UserID INNER JOIN MessageStatus ON PrivateMessages.MessageID = MessageStatus.MessageID WHERE MessageStatus.ReceiverID=[@userid]; But for some reason when I try saving it in my Access database, I get the following error (translated to English by me, since my office is in a different language): Syntax error (missing operator) at expression: "PrivateMessages.SenderID = Users.UserID INNER JOIN MessageStatus ON PrivateMessages.MessageID = MessageStatus.MessageI". Any ideas what could cause this? Thanks.

    Read the article

  • FluentNHibernate error -- "Invalid object name"

    - by goober
    I'm attempting to do the most simple of mappings with FluentNHibernate & Sql2005. Basically, I have a database table called "sv_Categories". I'd like to add a category, setting the ID automatically, and adding the userid and title supplied. Database table layout: CategoryID -- int -- not-null, primary key, auto-incrementing UserID -- uniqueidentifier -- not null Title -- varchar(50) -- not null Simple. My SessionFactory code (which works, as far as I can tell): _SessionFactory = Fluently.Configure().Database( MsSqlConfiguration.MsSql2005 .ConnectionString(c => c.FromConnectionStringWithKey("SVTest"))) .Mappings(x => x.FluentMappings.AddFromAssemblyOf<CategoryMap>()) .BuildSessionFactory(); My ClassMap code: public class CategoryMap : ClassMap<Category> { public CategoryMap() { Id(x => x.ID).Column("CategoryID").Unique(); Map(x => x.Title).Column("Title").Not.Nullable(); Map(x => x.UserID).Column("UserID").Not.Nullable(); } } My Class code: public class Category { public virtual int ID { get; private set; } public virtual string Title { get; set; } public virtual Guid UserID { get; set; } public Category() { // do nothing } } And the page where I save the object: public void Add(Category catToAdd) { using (ISession session = SessionProvider.GetSession()) { using (ITransaction Transaction = session.BeginTransaction()) { session.Save(catToAdd); Transaction.Commit(); } } } I receive the error Invalid object name 'Category'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'Category'. I think it might be that I haven't told the CategoryMap class to use the "sv_Categories" table, but I'm not sure how to do that. Any help would be appreciated. Thanks!

    Read the article

  • T-SQL UPDATE trigger help

    - by Tan
    Hi iam trying to make an update trigger in my database. But i get this error every time the triggers trigs. Error MEssage: The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(3rows) and heres my trigger ALTER TRIGGER [dbo].[x1pk_qp_update] ON [dbo].[x1pk] FOR UPDATE AS BEGIN TRY DECLARE @UserId int , @PackareKod int , @PersSign varchar(10) SELECT @PackareKod = q_packarekod , @PersSign = q_perssign FROM INSERTED IF @PersSign IS NOT NULL BEGIN IF EXISTS (SELECT * FROM [QPMardskog].[dbo].[UserAccount] WHERE [Account] = @PackareKod) BEGIN SET @UserId = (SELECT [UserId] FROM [QPMardskog].[dbo].[UserAccount] WHERE [Account] = @PackareKod) UPDATE [QPMardskog].[dbo].[UserAccount] SET [Active] = 1 WHERE [Account] = @PackareKod UPDATE [QPMardskog].[dbo].[User] SET [Active] = 1 WHERE [Id] = @UserId END END END TRY But i only update one row in the table how can it says 3 rows. Please advise.

    Read the article

  • Unable to get data from content in jQuery?

    - by Srikanth Chilukuri
    I have 2 HTML files and 2 js files. In App.html I want to include login.html and need to fetch the data from login.html and need to use in in App. App.html <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript" src='js/jquery.js'></script> <script type="text/javascript" src="js/app.js"></script> <script type="text/javascript" src="js/login.js"></script> </head> <body> <div id="content"></div> </body> </html> Login.html <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript" src='js/jquery.js'></script> </head> <body> <div> <div data-role="fieldcontain"> <label for="userid" id="luserid" ><strong>UserId : </strong></label> <input type="text" name="userid" id="userid" value="" class="logon" placeholder="Username" required/> </div> <div data-role="fieldcontain"> <label for="password" id="lpassword"><strong>Password :</strong></label> <input type="password" name="password" id="password" class="logon" value="" placeholder="Password" required/> </div> <div class="ui-body"> <fieldset class="ui-grid-a"> <div class="ui-block-a"><a data-role="button" id="loginbtn" data-theme="b">Login</a></div> </fieldset> </div> </div> </body> </html> app.js $(document).ready(function(){ $('#content').load('login.html'); }); login.js $(document).ready(function(){ var userid= $("#userid").val(); var upassword= $("#password").val(); alert(userid); alert(upassword); }); Please help me out on this. Note: I do not want to include the login.js in the Login.html.

    Read the article

  • Best way to limit results in MySQL with user subcategories

    - by JM4
    I am trying to essentially solve for the following: 1) Find all users in the system who ONLY have programID 1. 2) Find all users in the system who have programID 1 AND any other active program. My tables structures (in very simple terms are as follows): users userID | Name ================ 1 | John Smith 2 | Lewis Black 3 | Mickey Mantle 4 | Babe Ruth 5 | Tommy Bahama plans ID | userID | plan | status --------------------------- 1 | 1 | 1 | 1 2 | 1 | 2 | 1 3 | 1 | 3 | 1 4 | 2 | 1 | 1 5 | 2 | 3 | 1 6 | 3 | 1 | 0 7 | 3 | 2 | 1 8 | 3 | 3 | 1 9 | 3 | 4 | 1 10 | 4 | 2 | 1 11 | 4 | 4 | 1 12 | 5 | 1 | 1 I know I can easily find all members with a specific plan with something like the following: SELECT * FROM users a JOIN plans b ON (a.userID = b.userID) WHERE b.plan = 1 AND b.status = 1 but this will only tell me which users have an 'active' plan 1. How can I tell who ONLY has plan 1 (in this case only userID 5) and how to tell who has plan 1 AND any other active plan? Update: This is not to get a count, I will actually need the original member information, including all the plans they have so a COUNT(*) response may not be what I'm trying to achieve.

    Read the article

  • MYSQL trigger to select from and update the same table gives error #1241 - Operand should contain 1 column(s)

    - by Bipin
    when i try to select and update the same table mysql gives error error #1241 - Operand should contain 1 column(s) The trigger is DELIMITER $$ CREATE TRIGGER visitor_validation BEFORE INSERT ON ratingsvisitors FOR EACH ROW BEGIN SET @ifexists = (SELECT * FROM ratingcounttracks WHERE userid=New.vistorid AND likedate=New.likevalidation AND countfor=New.likeordislike); IF (@ifexists = NULL) THEN INSERT INTO ratingcounttracks(userid, likedate, clickcount,countfor) values (New.vistorid, New.likevalidation ,'1',New.likeordislike); ELSE UPDATE ratingcounttracks SET clickcount=clickcount+1 WHERE userid=New.vistorid AND likedate=New.likevalidation AND countfor=New.likeordislike; END IF; END$$

    Read the article

  • Get the count of login datetime and username from the textfile

    - by user2897388
    I am having a textfile with usename, userid, login and logout time. From this textfile I need to get the userid and howmany times that user logged in on that particular date. I am doing this one using C# (.NET) in windows applications. I tried this code but I am getting the whole text into the string strRead. In that strRead I need to get the count of user login basing on date. StreamReader strmrdr = new StreamReader("Logfiles.txt"); string strRead = strmrdr.ReadToEnd(); Username:Rajini||UserId:abc||Userlogintime:10/19/13 12:33:29 PM||UserLogoutTime:10/19/13 12:33:57 PM Username:Rajini||UserId:abc||Userlogintime:10/19/13 12:35:29 PM||UserLogoutTime:10/19/13 12:36:57 PM

    Read the article

  • MS-Access auto enter information based on date

    - by Desert Spider
    I have a query that calculates an employees anniversary date. I would like that query to generate an entry event for my Table based on the current date. Basically automatically generate an anniversary vacation accrual when their anniversary date comes. Here is an example of my table. Table name "SchedulingLog" LogID "PrimaryKey AutoNbr" UserID "Employee specific" LogDate EventDate Category "ex Vacation, Anniversary..." CatDetail "ex. Vacation Day Used, Anniversary..." Value "ex. -1, 1..." My query Query Name "qry_YOS" UserID "Employee Specific" DOH "Employee hire date" YearsOfService "calculated Field" Annual "calculated Field" Schedule "Employee Specific" Annual Vac Days "calculated field" Anniversary "calculated Field" Query associated SQL INSERT INTO schedulinglog (userid, [value], eventdate, logdate, category, catdetail) SELECT roster.userid, [annual] * [schedule] AS [Value], Month([wm doh]) & "/" & Day([wm doh]) & "/" & Year(DATE()) AS EventDate, DATE() AS LogDate, category.[category name] AS Category, catdetail.catdetail FROM roster, tblaccrual, category INNER JOIN catdetail ON category.categoryid = catdetail.categoryid WHERE (( ( [tblaccrual] ! [years] ) < Round(( DATE() - [wm doh] ) / 365, 2) )) GROUP BY roster.userid, roster.[wm doh], Round(( DATE() - [wm doh] ) / 365, 2), roster.schedule, Month([wm doh]) & "/" & Day([wm doh]) & "/" & Year(DATE()), DATE(), category.[category name], catdetail.catdetail HAVING ( ( ( category.[category name] ) LIKE "vacation*" ) AND ( ( catdetail.catdetail ) LIKE "anniversary*" ) ); I know it is possible I just dont know where to begin.

    Read the article

  • Creating a WCF Restful service, concurrency issues

    - by pmillio
    Hi i am in the process of creating a restful service with WCF, the service is likely to be consumed by at least 500 people at any given time. What settings would i need to set in order to deal with this. Please give me any points and tips, thanks. Here is a sample of what i have so far; [ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] And this is an example of a method being called; public UsersAPI getUserInfo(string UserID) { UsersAPI users = new UsersAPI(int.Parse(UserID)); return users; } [OperationContract] [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "User/{UserID}")] [WebHelp(Comment = "This returns a users info.")] UsersAPI getUserInfo(string UserID);

    Read the article

  • Is a primary key automatically an index?

    - by Lieven Cardoen
    If I run Profiler, then it suggests a lot of indexes like this one CREATE CLUSTERED INDEX [_dta_index_Users_c_9_292912115__K1] ON [dbo].[Users] ( [UserId] ASC )WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY] UserId is the primary key of the table Users. Is this index better than the one already in the table: ALTER TABLE [dbo].[Users] ADD CONSTRAINT [PK_Users] PRIMARY KEY NONCLUSTERED ( [UserId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    Read the article

  • How do you write a recursive stored procedure

    - by Grayson Mitchell
    I simply want a stored procedure that calculates a unique id and inserts it. If it fails it just calls itself to regenerate said id. I have been looking for an example, but cant find one, and am not sure how I should get the sp to call itself, and set the appropriate output parameter. I would also appreciate someone pointing out how to test this sp also. ALTER PROCEDURE [dbo].[DataContainer_Insert] @SomeData varchar(max), @DataContainerId int out AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; BEGIN TRY SELECT @UserId = MAX(UserId) From DataContainer INSERT INTO DataContainer (UserId, SomeData) VALUES (@UserId, SomeData) SELECT @DataContainerId = scope_identity() END TRY BEGIN CATCH --try again exec DataContainer_Insert @DataContainerId, @SomeData END CATCH END

    Read the article

  • MySQL inner join different results

    - by Darryl at NetHosted
    I am trying to work out why the following two queries return different results: SELECT DISTINCT i.id, i.date FROM `tblinvoices` i INNER JOIN `tblinvoiceitems` it ON it.userid=i.userid INNER JOIN `tblcustomfieldsvalues` cf ON it.relid=cf.relid WHERE i.`tax` = 0 AND i.`date` BETWEEN '2012-07-01' AND '2012-09-31' and SELECT DISTINCT i.id, i.date FROM `tblinvoices` i WHERE i.`tax` = 0 AND i.`date` BETWEEN '2012-07-01' AND '2012-09-31' Obviously the difference is the inner join here, but I don't understand why the one with the inner join is returning less results than the one without it, I would have thought since I didn't do any cross table references they should return the same results. The final query I am working towards is SELECT DISTINCT i.id, i.date FROM `tblinvoices` i INNER JOIN `tblinvoiceitems` it ON it.userid=i.userid INNER JOIN `tblcustomfieldsvalues` cf ON it.relid=cf.relid WHERE cf.`fieldid` =5 AND cf.`value` REGEXP '[A-Za-z]' AND i.`tax` = 0 AND i.`date` BETWEEN '2012-07-01' AND '2012-09-31' But because of the different results that seem incorrect when I add the inner join (it removes some results that should be valid) it's not working at present, thanks.

    Read the article

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