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

Re: Updating publication through ISQL

$
0
0

. If this is in a SQL Anywhere database, here is a rough example of SQL to do this:

 

begin

declare alterpubstmt long varchar;

declare publications_crsr cursor for select publication_id, publication_name from syspublication;  

declare pub_id integer;

declare pub_name char(128);

open publications_crsr;

lp: loop

    fetch next publications_crsr into pub_id, pub_name;

    set alterpubstmt = string( 'alter publication ', pub_name );

    if sqlcode <> 0 then leave lp end if;

    begin

        declare tablepubs_crsr cursor for select table_name, where_expr from sysarticle sa join systable st on sa.table_id = st.table_id where publication_id = pub_id;

        declare table_name char(128);

        declare where_expr long varchar;

        open tablepubs_crsr;

        lp1: loop

            fetch next tablepubs_crsr into table_name, where_expr;

            if sqlcode <> 0 then leave lp1 end if;

            set alterpubstmt = string( alterpubstmt, ' alter table ', table_name );

            set alterpubstmt = string( alterpubstmt, ' where ', 'get_sync_user(c_hotel_id) = ''fattal''', ',' )

        end loop lp1;

        set alterpubstmt = left( alterpubstmt, length(alterpubstmt) - 1 );

    end;

    execute immediate alterpubstmt;

end loop lp;

end

 

Currently, this assumes that all tables in the pub will get the where clause that you posted.


Viewing all articles
Browse latest Browse all 8623

Trending Articles



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