Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012

    Unanswered: Search database and return Boolean

    I need to cross check two fields in an webform the issue that i have is that i dont know how to return results back to my function

    1st check:
    If the Social security number exists it returns a boolean value so that the function can tell user they already exist

    2nd check
    If chart Number exist return boolean value so that the function can generate a new chart Number...

    Can someone please point me in the right direction, even if its an article

    thank you

  2. #2
    Join Date
    Jan 2012
    Hi there,

    Here is my view:

    -- lets call your table #Content_TABLE, and your fields "social_sec_number" and "chart_number"
    if object_id("sp_SS_CN_validator") is not null
    drop proc SS_CN_validator

    create procedure sp_SS_CN_validator @social int , @chart int

    -------- this block is only to have data to test the sp.
    -------- all the lines that will have this symbol $ on the end means that only needed for this test, not you case specificly
    if object_id("#Content_TABLE") is not null --$
    drop table #Content_TABLE --$
    create table #Content_TABLE ( social_sec_number int , chart_number int) --$
    insert into #Content_TABLE values ( 123, 321) --$

    if not exists(select 1 from #Content_TABLE where social_sec_number = @social)
    return 0

    if not exists (select 1 from #Content_TABLE where chart_number = @chart)
    return 0

    drop table #Content_TABLE --$
    return 1


    -- to test the sp --

    -- test1 - true
    exec SS_CN_validator 123 , 321

    -- test2 - false
    exec SS_CN_validator 0 , 0

    -- test3 - false
    exec SS_CN_validator 123 , 0

    -- test4 - false
    exec SS_CN_validator 0 , 321


    Hope it helps!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts