Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase ««12

creating procedure for Insertion? Expand / Collapse
Posted Thursday, May 23, 2013 5:04 AM



Group: General Forum Members
Last Login: 2 days ago @ 4:52 AM
Points: 2,917, Visits: 4,954
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
Post #1455944
Posted Tuesday, June 4, 2013 1:15 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 4, 2013 1:19 PM
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)

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

Post #1459915
Posted Thursday, July 25, 2013 11:56 PM


Group: General Forum Members
Last Login: Wednesday, July 27, 2016 4:25 AM
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

DECLARE @MaxDate datetime

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

IF(@MaxDate >= @departuredate)

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

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

is these correct ah?
how to that?
Post #1477866
Posted Friday, July 26, 2013 7:54 AM



Group: General Forum Members
Last Login: Yesterday @ 2:44 PM
Points: 16,134, Visits: 16,835
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 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)
Post #1478014
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse