Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8627

Re: Use a function to update a column

$
0
0

Hello Jay,

 

unfortunately you can use a scalar UDF only in the SELECT or WHERE clause of a SELECT statement, but not directly in an UPDATE statement.

 

You can transform your UPDATE statement to use a subselect to be able to use your UDF. Something like following:

UPDATE MYTABLE as "T1"

  SET "REFORMATTED_STRING" = ( SELECT FCN_REFORMAT_STRING("ORIGINAL_STRING") as "REFORMATTED_STRING" FROM MYTABLE as "T2" WHERE "T1".<key> = "T2".<key>");


Of course you can do your reformat also within a procedure or depending on the complexity of your reformat directly with the UPDATE statement using expression.


Best regards,

Florian


Viewing all articles
Browse latest Browse all 8627

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>