update a table based on record by record

  • Hi All,

    subject line might be easy to implement but the problem I have is :-

    I have a table where we have a column as telephonenum and have data as

    sdf345345fsdtgeg45345

    sdg34543543ggh

    3453453456fghtr

    534345ertert3455645

    I have write the function which take the telephonenum and return the number from by extracting all character. So first result will be like:-

    34534545345

    as of now I am simply using:- select myfunction('sdf345345fsdtgeg45345') which giving me result as 34534545345.

    But problem is I want to update the record which I am getting in select statement.

    Can someone please suggest how to proceed?

    ----------
    Ashish

  • You can perform an UPDATE ... FROM. Example:

    UPDATE <dest_table>

    SET <dest_table_field> = <source_table_field>, ...

    FROM <source_table>

    WHERE ...

    The FROM clause can be a full SELECT subquery.

  • thanks for reply, but actually the data need to be updated in same table.

    So lets say table a have all those data which I am able to convert using function.

    But how can I update the data using function in same table?

    ----------
    Ashish

  • UPDATE <table>

    SET <field> = myfunction(<same_field_or_other_field>)

    WHERE ...

  • yes, thanks for help.

    It worked perfectly.

    ----------
    Ashish

Viewing 5 posts - 1 through 4 (of 4 total)

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