[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

RE: [sqr-users] Unstring "ing" a dynamic length input file



I wrote this for where clause. Then user inputs number of parameters separated 
by comma.
You can use pieces for your purpose.
 

begin-procedure set-where-clause

let #l_p_state = length($input_str)

  let #i = 1

  while #i <= #l_p_state

    let #pos = instr($input_str, ',', #i)

    if #pos = 0

     let $search_str = substr($input_str, #i, #l_p_state - #i + 1)

     let $search_str = UPPER(rtrim(ltrim($search_str, ' '), ' '))

     let $search_str_t = CHR(39) || $search_str_t || $search_str || CHR(39)

     break

    end-if

    let $search_str = substr($input_str, #i, #pos - #i)

    let #pos_l = length($search_str)

    let $search_str = UPPER(rtrim(ltrim($search_str, ' '), ' '))

    show $search_str

    let $search_str_t = $search_str_t || $search_str || CHR(39) || ',' || 
CHR(39)

    show $search_str_t

    let #i = #i + #pos_l + 1

  end-while

  let $ouput_where = ' in (' || $search_str_t || ')'

  let $search_str_t = ''

  let $search_str = ''

end-procedure set-where-clause

"Turner, Ivan" <Ivan.Turner@qwest.com> wrote:

Why can't you use unstring? You say the field delimiter it comma.
That's what unstring needs to work. I believe you would get nulls in
the variables that are not are superfluous. 

-----Original Message-----
From: sqr-users-bounces+ivan.turner=qwest.com@sqrug.org
[mailto:sqr-users-bounces+ivan.turner=qwest.com@sqrug.org] On Behalf Of
Ashok Kuttan
Sent: Tuesday, August 23, 2005 1:02 PM
To: sqr-users@sqrug.org
Subject: [sqr-users] Unstring "ing" a dynamic length input file

I have a file whose length is dynamic. Employee A might have 5 columns,
whereas Employee B might have 10 columns. Hence I cannot use the
traditional Unstring command to place in variables. Since this file is a
comma delimited file, I was thinking of using "find" command to look for
commas and then store the respective values in an array. Can anyone help
me with the proper find loop or any other better solution ?

File layout example (just one line): E,010,4500

Any help will be appreciated.

Thanks

JR


---------------------------------
Start your day with Yahoo! - make it your home page 

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users

                
---------------------------------
Yahoo! for Good
 Click here to donate to the Hurricane Katrina relief effort. 

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users