Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 648
  • Last Modified:

Batch Update in Sybase

We have this batch update in DB2 which works:

UPDATE SESSION."#chap_t" AS tmp
        SET (tmp.n_mla_int_id) = (SELECT  DISTINCT bs.n_mla_int_id
                                      FROM SESSION."#base_t" AS bs
                                      WHERE tmp.bs_num_id = bs.bs_num_id)
        WHERE EXISTS
              (SELECT  *  
               FROM SESSION."#base_t" AS bs
          WHERE tmp.bs_num_id = bs.bs_num_id);

SESSION is schema, #chap_t & #base_t are global temporary tables with the rest being keywords, aliases or columns of these 2 tables.

Can you give a similar batch update that works in Sybase.
0
k_murli_krishna
Asked:
k_murli_krishna
2 Solutions
 
k_murli_krishnaAuthor Commented:
At least can we have a similar one that works on base tables in sybase.
0
 
koppchaCommented:
It is very much the same

update database.tablename
set column=(select distinct ....)
where exists
(select ...)
0
 
k_murli_krishnaAuthor Commented:
We have Sybase 12.5.1 ASE & this is not working. Let me know the version your are accustomed to w.r.t. this issue.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
koppchaCommented:
12.5.0 I did the above and then only i posted it...What is the error it is giving?
0
 
bretCommented:
Please explain (or rather show) how the actual query you are trying in ASE and the results or error messages you are getting.  Just saying "this is not working" does not help us try to diagnose the issue.

Cheers,
-bret
0
 
Jan FranekCommented:
Try this - it should work in ASE

UPDATE #chap_t
        SET n_mla_int_id = (SELECT  DISTINCT bs.n_mla_int_id
                                      FROM #base_t AS bs
                                      WHERE tmp.bs_num_id = bs.bs_num_id)
FROM #chap_t AS tmp
        WHERE EXISTS
              (SELECT  *  
               FROM #base_t AS bs
          WHERE tmp.bs_num_id = bs.bs_num_id)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now