Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004

    Angry Unanswered: resolving field names in records

    I'm trying to execute the following string, but the final field name is not resolving properly. Any ideas?

    v_sql_string varchar2(999) := 'select * from ' || ltrim(rtrim(site)) || '_policy_codes '|| ' where polno = ' || p_load_record.field5 ||
    ' and lifeno = ' || p_load_record.field6 ||
    ' and benefittype = '''|| p_load_record.field7 ||'''' ||
    ' and uwcode = p_load_record.field'|| code_group_counter';

    p_load_record.field'|| code_group_counter' should resolve to a column/field name from a record like 'field9' for example.

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    A shovel is a good tool for making a hole in the ground;
    but only when the "correct" end of the shovel comes into contact with the Earth.

    As a poor analogy, you are using the wrong end of the shovel!

    There is never a good reason to use dynamic SQL for doing a SELECT.

    Unless this is just a homework assignment, you need to seriously
    reconsider exactly what problem you are trying to solve and
    how to solve it in as simple a method as possible.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Apr 2004

    Now works.

    You're right. I was trying to do to many things at once.

    I have simplified my code and have a working solution.


Posting Permissions

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