Results 1 to 5 of 5

Thread: Lookup UDF

  1. #1
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506

    Cool Unanswered: Lookup UDF

    Hi,
    Can anybody provide me a Lookup UDF? I need to supply columnname,Tablename and condition dynamically and I need the scalar value in return.
    Any help will be greatly appreciated...
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hello again Rudra - I very recently commented on you not being around much these days

    I have a suspicion about what you want to do and it is probably bad and likely impossible if interpreted literally. Do you want to supply a column name, table name, a key value to a function and get an alternate key value in return (i.e. have some dynamic SQL within the UDF)? If not please can you give more details about what you want this function to actually do.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Quote Originally Posted by pootle flump
    Hello again Rudra - I very recently commented on you not being around much these days

    If not please can you give more details about what you want this function to actually do.
    Thanks Pootle. It seems just like the old days.
    Yea ,I was not around for a long time.But I always find the Yak Corral's B-E-A-U-T -Y Bcoz it always goes on and on and on....

    Well,I know what I am trying to do is quite impossible but can you suggest me a way by which I can fetch a value in by lookup UDF or something like that in a long script?
    In one of the script there are no of cases where things are done in this way-
    case when Policy.FinanceID = 0 Then ' ' else 'Finance Co.: ' + (select name from Finance where financeId= policy.financeid)Can I use something else for that line?
    Last edited by rudra; 07-20-07 at 20:00.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by rudra
    In one of the script there is no of cases where things are done in this way-
    case when Policy.FinanceID = 0 Then ' ' else 'Finance Co.: ' + (select name from Finance where financeId= policy.financeid)Can I use something else for that line?
    Well, not knowing any more about your problem, the easiest thing would be to insert the data into the table.
    Code:
     
    INSERT Finance (financeId, name)
    SELECT 0, ''
    This also covers a bug bear of mine which is sticking your data into code. (linky: http://weblogs.sqlteam.com/jeffs/arc...2/10/9002.aspx) Otherwise you could create a view:
    Code:
     
    CREATE VIEW finance_x
    AS
    SELECT financeId, name
    FROM finance
    UNION ALL
    SELECT 0, ''
    and use that.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Hmm... that link was great thanks a lot Pootle...see u soon.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

Posting Permissions

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