Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

How to update data table column values ​​from a certain result value, Use the value of table A to update the value of the cloumn_name column of the tble_name table table A :

tble_name  cloumn_name              UUID_name           ID_value          upnew_value
contacts       city                     ID                1                kitchener
contacts        state                   ID                2                 tx
contacts         fax                     ID                2                 5105551309

Need to be converted to a dynamic cursor to fetch the value


update    a.table_name set a.clounm_nname=a.n_value where  a.uuid_name=a.id_value

update       contacts      set   city=kitchener                      where  id=1


asked 16 Feb '20, 11:49

mfkpie8's gravatar image

accept rate: 12%

I don't understand what your actual question is...

(17 Feb '20, 03:21) Volker Barth

dint understood the question at all.

(17 Feb '20, 09:53) Dev

  declare ntable_name char(60);
  declare ncloumn_name char(60);
  declare nuuid_name char(60);
  declare nID_value integer;
  declare nupnew_value char(60);
  declare @sqlstr long varchar;
  declare err_notfound exception for sqlstate value '02000';
  declare update_t dynamic scroll cursor for
    select * from A for update;
  open update_t;
  uploop: loop
    fetch next update_t into ntable_name,ncloumn_name,nuuid_name,nID_value,nupnew_value for update;
    if sqlstate = err_notfound then
      leave uploop
      set @sqlstr = 'UPDATE ' || ntable_name || ' '
         || 'set ' || ncloumn_name || ' = ' ||  ''''||  nupnew_value || ''''||  ' where '
         || nuuid_name || ' = ' || nID_value;
      execute immediate with result set on @sqlstr
    -- prepare updatetable from @sqlstr ;
    --  execute updatetable ;
    --DEALLOCATE PREPARE updatetable; 
    --UPDATE table_name SET ncloumn_name = nupnew_value where nuuid_name=nID_value  
    end if
  end loop uploop;
  close update_t
permanent link

answered 18 Feb '20, 10:27

mfkpie8's gravatar image

accept rate: 12%

Hm? I just don't understand...

But if you have answered your question, than it's fine for me...

(18 Feb '20, 10:32) Volker Barth
Replies hidden

yes i at docx find My answer.So I share my answers here!thanks all

(18 Feb '20, 10:53) mfkpie8
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 16 Feb '20, 11:49

question was seen: 779 times

last updated: 18 Feb '20, 10:53