By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

Ms Sql Stored Procedure

P: 2
hi friends this is Ram
I m making a Project On VB6.0
On Worker Details for a company
I want to create automatic worker Id Generate
what i do,
I create a stored procedure for this problem
but there are a errer when i exec my stored procedure
my table and Proce are give following
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\
create table worker
(
wid char(5),
wfname varchar(15),
wlname varchar(15),
wdobirth varchar(10),
wgender char(8)
)
select * from worker
insert into worker values('W00','Ram','Yadav','23/03/1987','M')
create procedure prcWorker
@incre int output
as
declare @wid char(5)
select @wid = max(wid) from worker
select @incre = convert(int,substring(@wid,2,4)) + 1 return

ERROR://Procedure or Function 'prcWorker' expects parameter '@incre', which was not supplied.//

Please Help Me Immediate ,Please
and Please give me solution on My e-mail id raj_sargum@rediff.com
which one i m using always.
Please Help me ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Regard's Ram Yadav (India)
Nov 26 '07 #1
Share this Question
Share on Google+
2 Replies


QVeen72
Expert 100+
P: 1,445
Hi Ram,
Some Syntax roblem with Creation of your stored procedure..
Try This :

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE prcWorker (OUT incre INT)
  2. BEGIN
  3. declare @wid char(5);
  4. select @wid = max(wid) from worker;
  5. select incre = convert(int,substring(@wid,2,4)) + 1;
  6. END;
  7.  
I guess, all the statements should end with a semi-colon..

REgards
Veena
Nov 26 '07 #2

Kabyr
P: 29
I guess instead of writing a sored SQL procedure, u could read you last ID into a variable and then increment before saving back to table.
Like:
dim WID as integer, newid as integer
Dim urRS
urRS.open querry
urRS.movelast
WID=urRS("tablewid")
newid = wid+1
save newid into your table.

or

create a table to hold the last ID issued
read the id from the table, increment, save the value to warker's table, then updaate the lastid table with new id. ID table will have only 1 record.
Just use "update idtable set lastid = newid;"

either may help.
Nov 29 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.