Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2009
    Posts
    2

    Unanswered: Update using Substr in SQL

    I am new to doing fancy updates and I am in need of help....

    I need to change the first four digits in a field. Here is my sql:

    update INPT_PKT_hdr
    set substr(pkt_ctrl_nbr,1,4) = 'EUAZ'
    where substr(pkt_ctrl_nbr,1,4) like 'EUAT%';

    can anyone help me?

  2. #2
    Join Date
    May 2003
    Posts
    113
    Quote Originally Posted by cboden
    I am new to doing fancy updates and I am in need of help....

    I need to change the first four digits in a field. Here is my sql:

    update INPT_PKT_hdr
    set substr(pkt_ctrl_nbr,1,4) = 'EUAZ'
    where substr(pkt_ctrl_nbr,1,4) like 'EUAT%';

    can anyone help me?
    update INPT_PKT_hdr
    set pkt_ctrl_nbr = 'EUAZ' || substr(pkt_ctrl_nbr, 5, ddd)
    where pkt_ctrl_nbr like 'EUAT%';


    ddd in above substr is the max length of your column pkt_ctrl_nbr

    BTW, I changed your predicate by removing the substr to make it more efficiently. Another alternative is:
    where substr(pkt_ctrl_nbr, 1,4) = 'EUAT';

  3. #3
    Join Date
    Apr 2009
    Posts
    2
    Worked like a charm...thank you....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •