Substring Function without the length!

I know I have seen this before, but cannot find it when searching.
I need to do something similar to the Substring function, where I start from position 4, but the length behind this position is variable.   Due to the IDOC it only passes the value...
I think I possibly saw a UDF for this somewhere - unless I can use some standard mapping!
It is probably very simple - but it is late in the day and my eyes are square!  = )
<i> I need a drink......</i>
Can anyone help?
Message was edited by:
        Barry Neaves

For substring function, you have 1 input and 2 parameters (you set the parameters by double-clicking the function box).
I also didn't understand how you can pass the output of length function two 2nd parameter of substring function (since it is a parameter and not an expected input).
You could always create a UDF...
public String UDSubstring(String a,String b,String c,Container container){
  int d = Integer.parseInt(b);
  int e = Integer.parseInt(c);
  if ((e == 0) && (a.length() >= d)) {
    return a.substring(d);
  else if ((e > d) && (a.length() >= e)) {
    return a.substring(d, e);
  else return "";
They don't bite, you know...
Regards,
Henrique.
<b>Edit:</b> followed by Michal's correction...

Similar Messages

  • Using substring function in the Universe

    What is the correct syntax of using the substring function in the Universe?
    I need to extract the numbers and decimal between the #'s, and the character length varies:
    From: DOE, JOHN  Added the following entry to work history:
    A1S#0.25#
    To: 0.25
    Please help!  Thanks!

    There are ticket details in the text - I replaced certain letters with x, o, or a.  I thought you would need the total number of characters in the text.
    0.25#"
    DOE, JOHN A Xddxd xxx xxllxwOIg xIxxI xx wxxk xOXxxxI:
    A1S#0.25#"O xxxxd Oxck xxxm CJ, xx XxOd xxxx wx xxx XuppxXxd xx Ox gxxxOIg xlxxxX xI xxOX.  Xx, xxx quxXxOxI xxmxOIX wxxx xx dx Ixw?  XOxxxx wx mxkx xxx dxcOXOxI xx OgIxxx xxOX cxIdOxOxI xId xxvx Ox xxmxvxd xxxm XmxxxX, xx wx xxI xx xxXxxxcx xxp xxlkxxX xId Xxx Ox wx cxI Xxxp Xxmx xx xxx xxxxxOc, xx wx xxdxx x OOggxx cOxcuOx xx xxIdlx xxx OuxXxX wOxxxux xII dxxpX.  O'll xxI xx xuI xxOX OI mxIxgxmxIx xId xxx xxXx xx xxx xxxm xx Xxx wxOcx wxI wx wxIx xx gx".
    1#"
    DXX, JXXN X XddXd xxX xxllxAxng XnxrN xx Axrk xxAxxrN:
    A1S#1#"X dxn'x AXX xxxA xn AxnAxrd.  X AxA gxxng xx AxXAk xxX xnxXrxxAX xx AXX xx ApxkXA xn xxrxugxpux AXrX xbAXrvXd xA xxA bXXn AuggXAxXd, xxAXvXr, xxA nxx xn AxnAxrd.  X AxXAkXd Dxrx xnd dxn'x AXX xnN xndxAxxxxn xxxx xxxA xA xn xnN xlxrI grxupA xxr xxrXAxxld Ixnxxxrxng, Ax X'I AxndXrxng AxXrX xxX xlxrI xA AxIxng xrxI.  Xx Axuld bX xxxx xxXrX xA nx xnxXnxxxn xx bX xlxrIxng xn xxxA xx xll xnd xxX xlxrIA Axuld bX AxIxng xrxI xn xld Ixnxxxrxng AxurAX xxxx xA nx lxngXr vxlxd (xX, xxxA AlxppXd xxrxugx xxX ArxAkA AxIXxxA).  X AXnx xn XIxxl xx AurxxA JxnXA xx AXX xx xX Axn xXll Axxx xxX AxurAX xx xxX xlxrI xA (xX, Axxx Ixnxxxrxng ANAxXI xAxuxllN gXnXrxxXd xxX xlxrI)."
    0.5#
    DOE, JOHN A Xaaxa xax OolloxixI xxxIx xo xoIk aisxoIx:
    A1S#.05# "XIxxsOxIIixI xo IXS XixI x quxux OoI xaaixioxxl ixOoIoxxiox xxa Ixcoooaxxioxs."

  • SUBSTR function in the where clause

    HI
    I want to get a number of 15 digits from a column where the user only know the last 10 digits.
    So that when the user enter a number with 10 digits, only the record of that specific number should be displayed.
    And then when the user did not enter any number all the records in the table should be displayed.(this part works fine)
    The problem is: when the user enters any last digits( last, second last, thirth last and so on) the records which satisfy this are retrieved, which is not supose to be the case.
    I' am trying to use the substr function in the where clause but I'm not sure if it's working or not becasue the result of the query is just the same as before i used the substr.
    Thanks

    better to pad with '*' me thinks in case u have a number ending with 0's:
      1  select empno,ename
      2  from emp
      3* where empno like '%'||lpad('&1',2,'*')
    SQL> /
    Enter value for 1: 0
    old   3: where empno like '%'||lpad('&1',2,'*')
    new   3: where empno like '%'||lpad('0',2,'*')
    no rows selected
    SQL> /
    Enter value for 1: 00
    old   3: where empno like '%'||lpad('&1',2,'*')
    new   3: where empno like '%'||lpad('00',2,'*')
         EMPNO ENAME
          7900 JAMES
    SQL> /
    Enter value for 1:
    old   3: where empno like '%'||lpad('&1',2,'*')
    new   3: where empno like '%'||lpad('',2,'*')
         EMPNO ENAME
          7369 SMITH
          7499 ALLEN
          7521 WARD
          7566 JONES
          7654 MARTIN
          7698 BLAKE
          7782 CLARK
          7788 SCOTT
          7839 KING
          7844 TURNER
          7876 ADAMS
         EMPNO ENAME
          7900 JAMES
          7902 FORD
          7934 MILLER
    14 rows selected.

  • Using substring function in the dashboard prompt

    Hi,
    I want to use a function in the dashboard prompt.
    Example: Subject Area:Paint --> Products --> Color
    I want to take second letter of color, describe a label for it and use this label in prompt. The formula is below;
    CASE WHEN (SUBSTRING(Products.Color FROM 2 FOR 1) = 'a') THEN 'AAA' ELSE 'BBB' END
    Dashboard prompt should list 3 choices; All choices, AAA, BBB.
    When selecting AAA in the prompt, these colors should be listed in the request; Carriage House Red, Dante, Manchester Red.
    I created a dashboard prompt (add a function) and a request. When selecting AAA in the prompt, it sends "AAA" as prompt, not sends "a". So I couldn't reach the result.
    Is it possible? Could anyone help me ASAP?
    Thanks & Best Regards,

    Create a column in the logical layer using the same formula that you described. Then use the new column in the prompt. Then add the new column to the report as 'is prompted'.

  • How can a make avi files without the length changing?

    I'm hoping someone can help me with this. I'm posting it first here, as the process also involves FinalCut. If there's a better place to get an answer, maybe someone could streer me in that direction.
    I'm doing some subtling which will then be coded onto professional tapes using FCP. I don't have the equipment (digibeta machines) to do that process at my end, so I'm sending the files to a studio and they're going to do the rest for me.
    I have software that'll let me lay down subtitles and then export files with time code, but the software previews with avi files. After messages from the studio telling me that the subtitles were falling out of sync, I finally realized that the avi files I had made from the 30 minute DVD screeners were 4 seconds shorter in length than the material on the screener. I made more and more avi files to double check, each one came out 4 seconds shorter than it should have been. So that's my problem.
    Does anyone know of a way to convert DVD (or VOB) files to avi without losing any time? Alternatively, does anyone know of a program for subtitling that works straight from DVDs? (I looked into Belle Nuit Subtitler, but it's impossible to tell how it works without paying for it and waiting three or four days for the order to manually process.)
    Thanks for any help and sorry my question is so convoluted.

    The best solution to my particular problem seemed to be putting the avi file on the timeline in FCP, selecting it, the choosing "Duration" from the "Modify" menu and resizing it to the length it should have been.
    I'm actually getting a friend to adjust most of the files in Premiere with his PC as I'm still on a G4 PowerBook and the rendering time for the avi files before I can manipulate them was half a day each. (Premiere has a similar feature.)
    Thanks again to Andy for the MPEG Streamclip tip...it looks like it'll be useful in the future, and it's free! Cinematize also looked like it could have helped, but the demo mode only let me test 10 second exports at a time and that wasn't really enough for me to tell if the length changed or not. Didn't buy it this time around.
    I also get the point that there must be a lot of people who use the term "urgent" to mean "hurry up and help me, I don't have time to read" with prolific good Samaratians no doubt tired of being bossed around in that way.
    Fair enough.
    Anyway, the "Duration" option within FCP is one way to fix DVD burns and other format conversions that come out with different time spreads from the original. Rendering can take time on slower Macs though.

  • I was buying parts of a macbook pro 13" what are all the essential parts, wires perhaps for it to be fully functional (without the fan/ keyboard/ mouse and speakers. Thank you

    I was making an investigation into what I needed to make a bit of a bit of a hybrid between my musical inteface and the mac book pro 13...I looking for the macbook to just hold and processes the application i require to perform live music, in this case the software max msp. I was looking for peoples opinions on what risks im taking just powering the motherboard of the model and have people had experience of reconstructing the mashine, what sort of things did they discover.
    Thank you very much for reading, I will very very much  appreciate any reponce from people
    Joel

    You've got it right. The SSD can be upgraded, though it's expensive and potentially voids the warranty. The RAM can't be upgraded at all.
    Can you return it? If not, your only option may be to sell it.

  • How to use Substring function with Case statement.

    Hello Everyone,
    I have one requirement where I have to use substring function on the field for report criteria.
    E.G.
    I have Branch Name Field where I have all branch names information, Now some of the branch names are too big with some extension after the name .
    now i want to substing it but the character length varies for each branch.
    so is there any way where we can use case statement where we can define that if branch name character are exceeding some value then substing it with this length.

    Try something like this:
    CASE WHEN LENGTH(tablename.Branch_Name) > n THEN SUBSTRING(...) ELSE tablename.Branch_Name END
    where n is the number of characters you want to start the break.

  • Substr function in CTL file of sqlloader

    Hi gurus,
    I am using sql loader to load the data from text file to oracle table.
    I have 2 columns in the input data, which are of more size than their corresponding destination table column sizes.
    I am using substr() function in the control file, but it is failing for some records in 2 scenarios, details given below.
    First scenario:
    destination table column size is 250 characters.
    substr() function works fine when the source data is less than 255 characters, but when it is more than 255 characters, the record is getting rejected as bad record.
    eg: if the source data is of 254 characters, only 250 chars are inserted in the table, but if the size is 256, record is not inserted in the table.
    Here is the syntax i am using
    ENQUIRY "SUBSTR(:ENQUIRY, 0, 250)",
    Second scenario:
    destination table column size is 2000 characters.
    substr() function works fine when the source data is upto 2000 characters, but when it is more than 2000 characters, the record is getting rejected as bad record.
    Here is the syntax i am using
    ANSWER CHAR(2000) "SUBSTR(:ANSWER, 0, 2000)",
    Please suggest.
    Thanks,

    odie_63 wrote:
    Hi,
    Try with specifying a larger size limit for both columns :
    ENQUIRY CHAR(4000) "SUBSTR(:ENQUIRY, 0, 250)",        
    ANSWER  CHAR(4000) "SUBSTR(:ANSWER, 0, 2000)"
    Will the substr work with a starting offset of 0 ? Doesn't substr uses 1 as the first character position? or it is different with sqlloader?
    Okay I checked, It works just like if the offset is given as one. Perfect.
    SQL> select substr('ABCDEF',0,3) from dual;
    SUB
    ABCThanks odie_63. :)
    Edited by: zahid79 on Jul 23, 2010 5:20 PM
    Edited by: zahid79 on Jul 23, 2010 5:22 PM

  • Substring function giving out empty fields

    I am using OAS 10.1.3v . I have a problem with the substring function in the BPEL functions. In 10.1.2v , all the xpaths with substring functions gave out data.
    But in 10.1.3v, all those nodes are seen empty. Is there any particular reason for this ?
    Is this a problem of any particular jar file ? I am using xalan 2.7.0 along with this, for custom functions.
    Also, in which class, inside the jar file, is the substring function defined ?

    Try wrapping the substring function in a @member function. You need the ruturn of a member name not a string. Look at the example of @member in the technical reference for more details

  • Using substr function loses index. Query tune help

    Hi
    when i use substr function in the join condition it loses index and the query is slow. How to fix this problem or tune this query. These are the lines in the query.
    and substr(a.invoice_num,1,9) = l.invoice_num
    and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
    and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_key
    select
    pap.full_name employe_name,
         k.SEGMENT1 ||'.' ||k.segment2 Cost_Center,
         a.invoice_num Invoice_Number,
         b.item_description Line_Item,
         b.amount Amount,
         cc.trx_id Corporate_Card_Transaction_Id,
         cc.transaction_date Date_Charge_Incurred,
         cc.posted_date Date_Charge_Posted_To_USBank,
         cc.creation_date Date_Posted_To_IExpense,
         a.creation_date Expense_Report_Creation_Date,
         l.report_submitted_date Expense_Report_Submitted_Date,
         mgr_apprv_lst.activity_begin_date Managers_Approval_Begin_Date,
         mgr_apprv_lst.activity_end_date Managers_Approval_End_Date,
         pbl_apprv_lst.activity_begin_date AP_Approval_Begin_Date,
         pbl_apprv_lst.activity_end_date AP_Approval_End_Date,
         e.check_date Payment_Date_To_USBank,
         e.check_number Payment_Number,
         mgr_apprv_lst.activity_result_display_name Managers_Process_Result,
         pbl_apprv_lst.activity_result_display_name AP_Process_Result
    from
         ap_checks_all e,
         ap_invoice_payments_all d,
         ap_invoices_all c,
    ap_expense_report_headers_all a,
         ap_credit_card_trxns_all cc,
         per_all_people_f pap,
         ap_expense_report_headers_all l,
         ap_expense_report_lines_all b,
         gl_code_combinations k,
         (select ias1.user_key,
         ias1.activity_result_display_name,
         ias1.activity_begin_date,
         ias1.activity_end_date
    from wf_item_activity_statuses_v ias1,
    (select c1.invoice_num
         from ap_checks_all e1,
         ap_invoice_payments_all d1,
         ap_invoices_all c1
         where trunc(e1.check_date) between nvl(:From_Date, trunc(e1.check_date))
         and nvl(:To_Date, trunc(e1.check_date))
    and e1.org_id = 141
    and e1.void_date IS null
    and d1.check_id = e1.check_id
         and c1.invoice_id = d1.invoice_id) inv_lst1
    where ias1.item_type = 'APEXP'
    and ias1.user_key = inv_lst1.invoice_num
    and ias1.activity_name = 'AP_MANAGER_APPROVAL_PROCESS') mgr_apprv_lst,
    (select ias2.user_key,
         ias2.activity_result_display_name,
         ias2.activity_begin_date,
         ias2.activity_end_date
    from wf_item_activity_statuses_v ias2,
    (select c2.invoice_num
         from ap_checks_all e2,
         ap_invoice_payments_all d2,
         ap_invoices_all c2
         where trunc(e2.check_date) between nvl(:From_Date, trunc(e2.check_date))
         and nvl(:To_Date, trunc(e2.check_date))
    and e2.org_id = 141
    and e2.void_date IS null
    and d2.check_id = e2.check_id
         and c2.invoice_id = d2.invoice_id) inv_lst2
    where ias2.item_type = 'APEXP'
    and ias2.user_key = inv_lst2.invoice_num
    and ias2.activity_name = 'AP_PAYABLES_APPROVAL_PROCESS') pbl_apprv_lst
    where
    trunc(e.check_date) between nvl(:From_Date, trunc(e.check_date))
    and nvl(:To_Date, trunc(e.check_date))
    and e.org_id = 141
    and e.void_date IS null
    and d.check_id = e.check_id
    and c.invoice_id = d.invoice_id
    and a.invoice_num = c.invoice_num
    and a.source = 'CREDIT CARD'
    and a.employee_id = nvl(:Emp_id,a.employee_id)
    and a.report_header_id = b.report_header_id
    and cc.trx_id = b.credit_card_trx_id
    and pap.person_id = a.employee_id
    and pap.effective_start_date <= trunc(sysdate)
    and pap.effective_end_date >= trunc(sysdate)
    and k.code_combination_id = b.code_combination_id
    and k.segment2 between nvl(:From_Cost_Center,k.segment2)
    and nvl(:To_Cost_Center,k.segment2)
    and substr(a.invoice_num,1,9) = l.invoice_num
    and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
    and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_key

    Hi
    If I understood correctly your logic, and if the columns involved are of type varchar2, you can use the like operator:
    and a.invoice_num like l.invoice_num || '%'
    and c.invoice_num like mgr_apprv_lst.user_key  || '%'
    and c.invoice_num like pbl_apprv_lst.user_key  || '%'In this case, Oracle will be able to use the indexes. If they are numeric, you need to do something like:
    and a.invoice_num between l.invoice_num * 1000000
                                and l.invoice_num * 1000000 + 999999I hope this makes sense...
    Luis

  • Invalid length parameter passed to the LEFT or SUBSTRING function.

     Below code is returning me invalid length (or) parameter.
    Msg 537, Level 16, State 2, Line 2
    Invalid length parameter passed to the LEFT or SUBSTRING function.
    , ( select Top 1 person_id from person_membership where status_flag='A' and membership_id = a.membership_id and person_id in (select person_id from person where first_name =SUBSTRING(a.firstname, 1, CHARINDEX(' ', a.firstname) - 1) and surname = REVERSE(SUBSTRING(REVERSE(a.firstname), 1, CHARINDEX(' ', REVERSE(a.firstname)) - 1)) ))as Person_ID
    ,(select rtrim(ltrim(isNull(address_line1,''))) + ' ' + rtrim(ltrim(isNull(address_line2,''))) + ' ' + rtrim(ltrim(isNull(address_line3,'')))
    + ' ' + rtrim(ltrim(isNUll(suburb,''))) + ' ' + rtrim(ltrim(isNUll(state,''))) + ' ' + rtrim(ltrim(isNUll(convert(char(10),postcode),'')))
    from address where address_type= 'P' and person_id = ( select Top 1 person_id from person_membership where status_flag='A' and membership_id = a.membership_id and person_id in (select person_id from person where first_name =SUBSTRING(a.firstname, 1, CHARINDEX(' ', a.firstname) - 1) and surname = REVERSE(SUBSTRING(REVERSE(a.firstname), 1, CHARINDEX(' ', REVERSE(a.firstname)) - 1)) ))
    )as Person_Postal_Address
    ,(select rtrim(ltrim(isNull(address_line1,''))) + ' ' + rtrim(ltrim(isNull(address_line2,''))) + ' ' + rtrim(ltrim(isNull(address_line3,'')))
    + ' ' + rtrim(ltrim(isNUll(suburb,''))) + ' ' + rtrim(ltrim(isNUll(state,''))) + ' ' + rtrim(ltrim(isNUll(convert(char(10),postcode),'')))
    from address where address_type= 'H' and person_id = ( select Top 1 person_id from person_membership where status_flag='A' and membership_id = a.membership_id and person_id in (select person_id from person where first_name =SUBSTRING(a.firstname, 1, CHARINDEX(' ', a.firstname) - 1) and surname = REVERSE(SUBSTRING(REVERSE(a.firstname), 1, CHARINDEX(' ', REVERSE(a.firstname)) - 1)) ))
    )as Person_Home_Address
    ,(SELECT contact.contact_detail FROM contact WHERE contact.contact_type = 'H' AND contact.person_id = d.person_id AND
    contact.contact_id = (SELECT max(dbo.contact.contact_id) FROM dbo.contact WHERE dbo.contact.contact_type = 'H'
    and dbo.contact.person_id = (select Top 1 person_id from person_membership where status_flag='A'
    and membership_id = a.membership_id and person_id in (select person_id from person where first_name =SUBSTRING(a.firstname, 1, CHARINDEX(' ', a.firstname) - 1) and surname = REVERSE(SUBSTRING(REVERSE(a.firstname), 1, CHARINDEX(' ', REVERSE(a.firstname)) - 1)) ) ) )
    ) as Person_Home
    ,(SELECT contact.contact_detail FROM contact WHERE contact.contact_type = 'W' AND contact.person_id = d.person_id AND
    contact.contact_id = (SELECT max(dbo.contact.contact_id) FROM dbo.contact WHERE dbo.contact.contact_type = 'W'
    and dbo.contact.person_id = (select Top 1 person_id from person_membership where status_flag='A'
    and membership_id = a.membership_id and person_id in (select person_id from person
    where first_name =SUBSTRING(a.firstname, 1, CHARINDEX(' ', a.firstname) - 1) and surname = REVERSE(SUBSTRING(REVERSE(a.firstname), 1, CHARINDEX(' ', REVERSE(a.firstname)) - 1)))))
    ) as Person_Work_Phone
    -kccrga http://dbatrend.blogspot.com.au/

    I have fixed the query by applying the below solution
    , ( select Top 1 person_id from person_membership where status_flag='A' and membership_id = a.membership_id and person_id in (select person_id from person
    where first_name =SUBSTRING(a.firstname, NULLIF(CHARINDEX(' ',a.firstname),0)+1, CHARINDEX(' ', a.firstname) + 1)
    and surname = REVERSE(SUBSTRING(REVERSE(a.firstname),NULLIF(CHARINDEX(' ',a.firstname),0)+1, LEN(a.firstname)- CHARINDEX(' ', REVERSE(a.firstname)) + 1)) ))as Person_ID
    ,(select rtrim(ltrim(isNull(address_line1,''))) + ' ' + rtrim(ltrim(isNull(address_line2,''))) + ' ' + rtrim(ltrim(isNull(address_line3,'')))
    + ' ' + rtrim(ltrim(isNUll(suburb,''))) + ' ' + rtrim(ltrim(isNUll(state,''))) + ' ' + rtrim(ltrim(isNUll(convert(char(10),postcode),'')))
    from address where address_type= 'P' and person_id = ( select Top 1 person_id from person_membership where status_flag='A' and membership_id = a.membership_id
    and person_id in (select person_id from person where first_name =SUBSTRING(a.firstname, NULLIF(CHARINDEX(' ',a.firstname),0)+1,LEN(a.firstname)- CHARINDEX(' ', a.firstname) + 1)
    and surname = REVERSE(SUBSTRING(REVERSE(a.firstname),NULLIF(CHARINDEX(' ',a.firstname),0)+1, LEN(a.firstname)- CHARINDEX(' ', REVERSE(a.firstname)) + 1)) ))
    )as Person_Postal_Address
    ,(select rtrim(ltrim(isNull(address_line1,''))) + ' ' + rtrim(ltrim(isNull(address_line2,''))) + ' ' + rtrim(ltrim(isNull(address_line3,'')))
    + ' ' + rtrim(ltrim(isNUll(suburb,''))) + ' ' + rtrim(ltrim(isNUll(state,''))) + ' ' + rtrim(ltrim(isNUll(convert(char(10),postcode),'')))
    from address where address_type= 'H' and person_id = ( select Top 1 person_id from person_membership where status_flag='A'
    and membership_id = a.membership_id and person_id in (select person_id from person
    where first_name =SUBSTRING(a.firstname, NULLIF(CHARINDEX(' ',a.firstname),0)+1, LEN(a.firstname)-CHARINDEX(' ', a.firstname) + 1)
    and surname = REVERSE(SUBSTRING(REVERSE(a.firstname),NULLIF(CHARINDEX(' ',a.firstname),0)+1, LEN(a.firstname)- CHARINDEX(' ', REVERSE(a.firstname)) + 1)) ))
    )as Person_Home_Address
    ,(SELECT contact.contact_detail FROM contact WHERE contact.contact_type = 'H' AND contact.person_id = d.person_id AND
    contact.contact_id = (SELECT max(dbo.contact.contact_id) FROM dbo.contact WHERE dbo.contact.contact_type = 'H'
    and dbo.contact.person_id = (select Top 1 person_id from person_membership where status_flag='A' and membership_id = a.membership_id
    and person_id in (select person_id from person where first_name
    =SUBSTRING(a.firstname, NULLIF(CHARINDEX(' ',a.firstname),0)+1, LEN(a.firstname)-CHARINDEX(' ', a.firstname) + 1)
    and surname = REVERSE(SUBSTRING(REVERSE(a.firstname),NULLIF(CHARINDEX(' ',a.firstname),0)+1, LEN(a.firstname)- CHARINDEX(' ', REVERSE(a.firstname)) + 1)) ) ) )
    ) as Person_Home_Phone
    ,(SELECT contact.contact_detail FROM contact WHERE contact.contact_type = 'W' AND contact.person_id = d.person_id AND
    contact.contact_id = (SELECT max(dbo.contact.contact_id) FROM dbo.contact WHERE dbo.contact.contact_type = 'W' and dbo.contact.person_id = (select Top 1 person_id from person_membership where status_flag='A'
    and membership_id = a.membership_id and person_id in (select person_id from person where first_name
    =SUBSTRING(a.firstname, NULLIF(CHARINDEX(' ',a.firstname),0)+1, LEN(a.firstname)-CHARINDEX(' ', a.firstname) + 1)
    and surname = REVERSE(SUBSTRING(REVERSE(a.firstname), NULLIF(CHARINDEX(' ',a.firstname),0)+1, LEN(a.firstname)-CHARINDEX(' ', REVERSE(a.firstname)) + 1)) ) ) )
    ) as Person_Work_Phone
    -kccrga http://dbatrend.blogspot.com.au/

  • Invalid length parameter passed to the LEFT or SUBSTRING function, error on INSERT

    I have a stored procedure that does a BULK INSERT of a csv file into myCSVTable then INSERTs records from
    myCSVTable into myTable. The INSERT statement is giving me this error: 
    Invalid length parameter passed to the LEFT or SUBSTRING function.
    CSV File: 
    3,020000007,OR,051,97205,02020005,41075,19470721,2,0,,0,0,0,0,0,1,0,0,,,,,,,,,0,2,,334418,334418,334418,13,,0,,0,0,0,0,0,1,0,0,1,20100217,,,,,20100304,20121030,1,1,,,0,0,0,0,0,,,,,0,0,0,0,9,0,0,0,1,1,0,0,0,3,00,20100304,20100426,20100922,20101011,20100304,20100922,20101011,,20101011,20100819,,20100326,20100326,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,,1,1,,9,9,1,1,1,1,0,0,111150,111150,111150,999999,5586.25,4714.01,5884.28,7055.89,11097.89,10839.39,0.00,2,,,,,20120617,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,The
    Workforce Investment Board for the City of xxxxxxxx and xxxxxxxxx and W,020005,,mstr: 1000000000000000017  js: 372651          epi: 1,Jane Doe
    4,020000007,OR,051,97205,02020005,41075,19470721,2,0,,0,0,0,0,0,1,0,0,,,,,,,,,0,2,,334418,334418,334418,13,,0,,0,0,0,0,0,1,0,0,1,20100217,,,,,20100304,20121030,1,1,,,0,0,0,0,0,,,,,0,0,0,0,9,0,0,0,1,1,0,0,0,3,00,20100304,20100426,20100922,20101011,20100304,20100922,20101011,,20101011,20100819,,20100326,20100326,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,,1,1,,9,9,1,1,1,1,0,0,111150,111150,111150,999999,5586.25,4714.01,5884.28,7055.89,11097.89,10839.39,0.00,2,,,,,20120617,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,The
    Workforce Investment Board for the City of xxxxxxxx and xxxxxxxxx and W,020005,,mstr: 1000000000000000017  id: 020000007       epi: 1,Jane Doe
    There is no LEFT or SUBSTRING function used in the procedure and there are no triggers on either table. 
    The procedure had been working fine until today, when I altered one of the CSV fields. The code which triggers the error is this:
    INSERT [myTable]
    SELECT * FROM [myCSVTable]
    The weird thing is, the 1st record containing the changed field (mstr: 1000000000000000017  js: 372651          epi: 1) triggers the error, but the 2nd record containing
    the old field value (mstr: 1000000000000000017  id: 020000007       epi: 1), does not. 
    There are only blank spaces in the 2 strings, no non-printable characters or anything like that. I'm confused.

    A View of myTable was causing the problem.
    Hi LoriCazares,
    Do you mean that you have solved this issue? If so, please close this thread.
    Regards,
    Elvis Long
    TechNet Community Support

  • SAP XI - Using the substring function.

    Hi Experts,
    I am having trouble using the substring function in SAP+XI. I have to consider the value from characters 6 to 19 for a target field of 25 characters. Every time I ma using the standard substring function it is giving an error Array Out of Bounds Exception.
    Please tell me how to proceed.
    Thanks
    Aniruddha

    Hi,
    Above error wil come if the input string length is less than the substring length what you are trying to get..
    i.e length of the input string is less than 25 characters... do some validations or pass substring as 6 and 0 ..
    HTH
    Rajesh

  • Use of substr function will avoid the use of indexes in a table

    i have one table which will contain some 3,00,000 records, it contains some 11 primary keys i am using some update statements to update some fields in the records (of 3,00,000 i will compare some 1,50,000 records with 1,50,000 another records) i am using substr function in all the select statements. whether usage of substr function will avoid the use of index
    can any one clarify?

    contains some 11 primary keys by this I suppose you mean to say the table has a composite PK on 11 columns.
    i am using substr function in all the select statementsCould you please post your SQL statement?

  • I am trying to generate purchase order and i create a BAPI also which is active. But when i call the BAPI from SYbase Mobile Object RFC then after calling it gives an Error "Conflict when calling a Function Module (Field Length)".

    i am trying to generate purchase order and i create a BAPI also which is active.
    But when i call the BAPI from SYbase Mobile Object RFC then after calling it gives an Error "Conflict when calling a Function Module (Field Length)".

    Hi,
    Yeah i tried my Z_BAPI in R3 and then giving some ERROR.
    This is my CODE-
    FUNCTION ZBAPIPOTV2.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(POHD) TYPE  ZPOHD OPTIONAL
    *"     VALUE(POITEM) TYPE  ZPOITEM OPTIONAL
    *"  TABLES
    *"      RETURN STRUCTURE  BAPIRET1 OPTIONAL
    data: ls_pohd type bapimepoheader,
             ls_pohdx TYPE bapimepoheaderx,
             lt_poit TYPE TABLE OF bapimepoitem,
             lt_poitx TYPE TABLE OF bapimepoitemx,
             ls_poit TYPE bapimepoitem,
             ls_poitx TYPE bapimepoitemx.
       MOVE-CORRESPONDING pohd to ls_pohd.
       MOVE-CORRESPONDING poitem to ls_poit.
       ls_pohdx-comp_code = 'x'.
       ls_pohdx-doc_type = 'x'.
       ls_pohdx-vendor = 'x'.
       ls_pohdx-purch_org = 'x'.
       ls_pohdx-pur_group = 'x'.
       ls_poit-po_item = '00010'.
       APPEND ls_poit to lt_poit.
       ls_poitx-po_item = '00010'.
       ls_poitx-po_itemx = 'x'.
       ls_poitx-material = 'x'.
       ls_poitx-plant = 'x'.
       ls_poitx-quantity = 'x'.
       APPEND ls_poitx to lt_poitx.
    CALL FUNCTION 'BAPI_PO_CREATE1'
       EXPORTING
         POHEADER                     = ls_pohd
        POHEADERX                    =  ls_pohdx
    *   POADDRVENDOR                 =
    *   TESTRUN                      =
    *   MEMORY_UNCOMPLETE            =
    *   MEMORY_COMPLETE              =
    *   POEXPIMPHEADER               =
    *   POEXPIMPHEADERX              =
    *   VERSIONS                     =
    *   NO_MESSAGING                 =
    *   NO_MESSAGE_REQ               =
    *   NO_AUTHORITY                 =
    *   NO_PRICE_FROM_PO             =
    *   PARK_COMPLETE                =
    *   PARK_UNCOMPLETE              =
    * IMPORTING
    *   EXPPURCHASEORDER             =
    *   EXPHEADER                    =
    *   EXPPOEXPIMPHEADER            =
      TABLES
        RETURN                       = return
        POITEM                       = lt_poit
        POITEMX                      = lt_poitx
    *   POADDRDELIVERY               =
    *   POSCHEDULE                   =
    *   POSCHEDULEX                  =
    *   POACCOUNT                    =
    *   POACCOUNTPROFITSEGMENT       =
    *   POACCOUNTX                   =
    *   POCONDHEADER                 =
    *   POCONDHEADERX                =
    *   POCOND                       =
    *   POCONDX                      =
    *   POLIMITS                     =
    *   POCONTRACTLIMITS             =
    *   POSERVICES                   =
    *   POSRVACCESSVALUES            =
    *   POSERVICESTEXT               =
    *   EXTENSIONIN                  =
    *   EXTENSIONOUT                 =
    *   POEXPIMPITEM                 =
    *   POEXPIMPITEMX                =
    *   POTEXTHEADER                 =
    *   POTEXTITEM                   =
    *   ALLVERSIONS                  =
    *   POPARTNER                    =
    *   POCOMPONENTS                 =
    *   POCOMPONENTSX                =
    *   POSHIPPING                   =
    *   POSHIPPINGX                  =
    *   POSHIPPINGEXP                =
    *   SERIALNUMBER                 =
    *   SERIALNUMBERX                =
    *   INVPLANHEADER                =
    *   INVPLANHEADERX               =
    *   INVPLANITEM                  =
    *   INVPLANITEMX                 =
    ENDFUNCTION.
    i am trying to generate purchase order and i create a BAPI also which is active. But when i call the BAPI from SYbase Mobile Object RFC then after calling it gives an Error "Conflict when calling a Function Module (Field Length)". 

Maybe you are looking for

  • Group by month of the date

    I need to generate a report based on the month of a date field.its look like month arrived patients May 100 june 129 July 154 How can i write the group by select command on the field of a date. Kindly help me.

  • How to boot T42 into safe mode

    Hi all, first post. I have a T42 with Firefox 4 installed that is giving me trouble. I  want to be able to boot into safe mode to help troubleshoot the problem. I have tried to rebbot and use the F8 key but it does not work. I have tried the F11 key

  • Using Nokia PC Suite - Communication Center to cal...

    I know that I can use the Nokia PC Suite - Communication Center (NPCS-CC) to start a call in my mobile, but... Is it possible to configure the PC to be used as the speaking / hearing device? I would love to make a phone call from the PC and be able t

  • Is there a Snow Leop Utilty that can show me all my applications by size???

    I'm trying to clean up my hard drive of unwanted programs and curiuos if SL or an outside app has the ability to show me all my applicaions and the space they are taking up on the hard drive.....kind of like the windows control panel/add or remove pr

  • Call transaction doubt?

    hi experts, I want to call a transaction and to invoke a function code in the called transaction without any user interaction. Is it possible to use <b>call transaction "Tcode" </b>statement and pass a fuction code along with it. else suggest me how