Re: invoked from within

From: Cameron Laird (claird_at_lairds.us)
Date: 11/10/04

  • Next message: Csaba Nemethi: "Re: TableList Bindings"
    Date: Wed, 10 Nov 2004 19:08:07 GMT
    
    

    In article <4192291a$0$33637$ed2619ec@ptn-nntp-reader02.plus.net>,
    Simon Geard <simon@quintic.co.uk> wrote:
    >Michael wrote:
    >> Hi!
    >> I'm writing a TCL script Under RH9 for CISCO.
    >> I'm connecting to ORACLE database , get some values in one string and
    >than try to
    >> break it into tokens.
    >> routine look like this
    >> set wholestring "{.21;2-DEC-2004}"
    >> regexp {^\{(.+);(.+)\}} $wholestring fl dt
    >> ### here comes an error ####
    >> puts "$fl"
    >> ###################
    >> while executing
    >> puts "$fl"
    >>
    >> (procedure "the_procedure" line 26)
    >> invoked from within
    >>
    >> what's wrong???
    >> Thanks
    >
    >Michael,
    >
    >I've just run that on my setup here (ActiveTcl8.4.7 / winXP) and can't
    >reproduce the error. A couple of points on your example:
    >
    > 1) in general you should enclose the regexp in an if block, that way
    >you'll only try to use variables that have been defined
    >
    > 2) your regexp command is not catching all the sub-expressions (which
    >may be intentional) because the first variable (fl) will be assigned the
    >whole string
    >
    >e.g.
    >
    >set wholestring "{.21;2-DEC-2004}"
    >if {[regexp {^\{(.+);(.+)\}} $wholestring ws first second]} {
    > puts "$ws ; $first ; $second"
    >} else {
    > puts "no match for $wholestring"
    >}
    >
    >-> {.21;2-DEC-2004} ; .21 ; 2-DEC-2004
                            .
                            .
                            .
    I see issues.

    First, most Tcl-Oracle databases will return data as tuples,
    that is, lists; I MUCH prefer to write

      set datum [lindex $wholestring 0]

    than to [regexp] off the enclosing {}-s.

    Next, I'm happier working with

      split $datum \;

    One general principle operating here is that I reserve REs
    for operations other built-ins don't do easily. I know others
    prefer REs whenever possible.


  • Next message: Csaba Nemethi: "Re: TableList Bindings"

    Relevant Pages

    • Re: Building Very Large Records
      ... > I am working on a routine to pull information from an Oracle database and ... as it creates a new copy of the string each time. ... I don't know enough about Oracle SQL yet, could I format the ... 'Takes a ctypes object and returns it as a string' ...
      (comp.lang.python)
    • Inserting foreign/special characters from a database
      ... I'm extracting a record set from an oracle database but I am getting the ... In both instances it was when trying to insert a string which contained ... understand is to define the character set to use, however, I can't find ...
      (microsoft.public.excel.programming)
    • Re: Float to String
      ... The problem in that case was that values stored in an Oracle database ... For binary numbers having n bits following the binary point, n digits ... Subject: Float to String ...
      (comp.lang.ada)
    • Re: ADO Recordset
      ... I plugged the string into the ODBC Connect String ... query, I'm now getting a "function sequence error". ... There has got to be something wrong with the Microsoft ODBC for Oracle ... This code gets me into the Oracle database (the number of records returned ...
      (microsoft.public.access.modulesdaovba)