Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

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


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, August 22, 2014 12:13 AM
Points: 2,631, Visits: 4,723
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/
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)
)
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
Post #1459915
Posted Thursday, July 25, 2013 11:56 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, July 21, 2014 11:33 PM
Points: 172, Visits: 427
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?
Post #1477866
Posted Friday, July 26, 2013 7:54 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:32 PM
Points: 13,302, Visits: 12,168
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)
Post #1478014
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse