Ms Sql Stored Procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajsargum
    New Member
    • Nov 2007
    • 2

    Ms Sql Stored Procedure

    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','R am','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,sub string(@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@redi ff.com
    which one i m using always.
    Please Help me ,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,
    Regard's Ram Yadav (India)
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi Ram,
    Some Syntax roblem with Creation of your stored procedure..
    Try This :

    [code=oracle]
    CREATE PROCEDURE prcWorker (OUT incre INT)
    BEGIN
    declare @wid char(5);
    select @wid = max(wid) from worker;
    select incre = convert(int,sub string(@wid,2,4 )) + 1;
    END;
    [/code]

    I guess, all the statements should end with a semi-colon..

    REgards
    Veena

    Comment

    • Kabyr
      New Member
      • Nov 2007
      • 29

      #3
      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("table wid")
      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.

      Comment

      Working...