Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


creating procedure for Insertion?


creating procedure for Insertion?

Author
Message
Kingston Dhasian
Kingston Dhasian
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3001 Visits: 4995
raghuldrag (5/23/2013)
its simple do nothing while i making new entry.


Try calling the procedure by passing parameters as Bhaskar had suggested earlier and let us know if the row gets inserted

EXEC Insert_Journey '05/20/2013','bankok','London','Air'




Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
g.nipper
g.nipper
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 6
try this - there is a syntax error
create procedure jack
(
@departuredate datetime,
@from_place varchar(50),
@to_place varchar(50),
@travelmode nvarchar(10)
)
as

if exists('select departuredate from journey where departuredate<@departuredate')
begin
print 'Must choose greater date of departuredate'
end
else
begin
insert into journey (departuredate,from_place,to_place,travel mode) values(@depaturedate,@from_place,
@to_place ,
@travelmode,
)
end

go
raghuldrag
raghuldrag
SSC-Enthusiastic
SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)

Group: General Forum Members
Points: 186 Visits: 473
Hai Bhasker,


if suppose i ve the request_id FK column depends travel_request table.


create table travel_request
(
request_id int identity PK
)

create table onward_journey
(
onward_journey_id int identity,
request_id int FK references travel_request(request_id),
departuredate datetime,
from_place varchar(10),
to_place varchar(10),
travel_mode varchar(10)
)



depends on above critirea i made procedure like these


alter procedure Insert_Journey
(
@departuredate datetime,
@from_location varchar(50),
@to_location varchar(50),
@metro nvarchar(50),
@trans_all nvarchar(50),
@mode_of_travel nvarchar(50),
@seat_type nvarchar(50),
@no_of_days int,
@other_details varchar(50),
@status_id int,
@request int


)
as
BEGIN
DECLARE @MaxDate datetime

SELECT @MaxDate = MAX(DepartureDate) FROM onward_journey where request_id=IDENT_CURRENT ('travel_request')


IF(@MaxDate >= @departuredate)
begin

RAISERROR('Your error message for departuredate should be greater then maxdate',16,1)
RETURN
END

insert into onward_journey(departuredate,from_location,to_location,metro,trans_all,mode_of_travel,seat_type,no_of_days,other_details,status_id,request_id) values(@departuredate,@from_location,@to_location,@metro,@trans_all,@mode_of_travel,@seat_type,@no_of_days,@other_details,'2',IDENT_CURRENT ('travel_request'))
--set @request= IDENT_CURRENT ('travel_request')
--return @request
end

is these correct ah?
how to that?
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16548 Visits: 17004
Your code seems to have some concurrency issues. You are using IDENT_CURRENT to determine which value to get for a DepartureDate. How can you know that nobody else has inserted into travel_request before this proc runs? I think you need to revisit your procedure. I would be willing to help but you need to try to explain more clearly what it is you are trying to do here.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search