Insertion Problem

  • OK. Few comments.

    The EducationCode and EducationCodeType fields require a non empty string. Are you sure you passing some value into the @EducationCodeDesc parameter?

    The procedure code you posted. Is this the entire code? You have @MajorCode param which is not used.

    Tha last update you have will update ALL records in your tEDUCATION_CODES table. The where clause does not do any filtering.

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

  • I was just playing with that and i noticed that if i give space then am getting error like i mentioned.

    As this site is live and users have started regisering , we can expect people just enter all the crap and they dont follow instructions that we provide to enter details.. i think somehow i should handle this throught not to enter spaces...

    I will mess with it and see if this is the olny reason why it is causing that error.

    If you have any suggestions then please let me know.

    Thank you

  • I think you meant to do this.

    SET @CODE = SCOPE_IDENTITY()

    SELECT @CODE AS EducationCodeidno

    UPDATE tEDUCATION_CODES set EDucationCodedomainIdno = EducationCodeidno where Educationcodeidno = @CODE

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

  • My code in SP seems to be working and where clause is working..

    What i wanted to do is that i need to update other column of that table with the ID of that row immediatly after insertion...

    because i can not modify table and EducationCodeDomainIDNo shouls be same as the ID of that row...Its weared as the application we bought will work only if those two cloumn values are smae..

    Anyways i guess i need to stop users enteing blank values(Spaces).

  • Your code might be working but the last UPDATE is updating ALL the records not the last inserted only. Your WHERE caluse is basically saying WHERE 1 = 1.

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

  • Hi JacekO,

    the issue regarding the update statement for this specific procedure has been discussed in the following thread:

    http://www.sqlservercentral.com/Forums/FindPost681895.aspx

    Your code snippet in post http://www.sqlservercentral.com/Forums/FindPost703959.aspx is the scripted form of the "verbal" recommendation #1 in post http://www.sqlservercentral.com/Forums/FindPost682567.aspx ... 😉



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Hi Imu92,

    How are you doing. Nice to see your reply regarding my post again.

    Huhh!! am still facing problems with that issue since then....

Viewing 7 posts - 16 through 21 (of 21 total)

You must be logged in to reply to this topic. Login to reply