Menu

#1 prints out "GetColumnHeaders: 0"

closed-fixed
nobody
None
5
2005-08-18
2005-08-05
Anonymous
No

the following code:

#select * from pagosprueb

package require SQL
namespace import -force ::SQL::*

if { [catch {
if {[llength $argv] < 2 } {
puts { usage: tclsh dumpdb.tcl \"sqlquery\" numfields

+numfields      is the number of fields u spect, 
+sqlquery       is the query to fetch, like  
            "select \* from that where this=that\_other\_thing"
\}
    exit
\}

set query \[lindex $argv 0\]
set numfields \[lindex $argv 1\]

set myHandle \[SQLConnect qgpl "administrador" "oscar" 10\]

set rc ""
set fields

"pcnit,pccia,t64,DESCRI,CEMPLE,ANOMTR,A121,CCONCE,JDCONC,CC06,email"
#set query "Select t64 from pagosprueb"
set result ""
set headers ""
# Set Max return rows to 100
# $myHandle SQLSetStmtAttr SQL_ATTR_MAX_ROWS 1000
# Set Query Time out to 10 secons
$myHandle SQLSetStmtAttr SQL_ATTR_QUERY_TIMEOUT 10

set rc \[$myHandle SQLExecDirect $query\]
set head ""
set rows 0
\# Was the query successful?
puts "&lt;?xml version=\"1.0\" ?&gt;\n&lt;package&gt;\n\t&lt;data&gt;"
while \{$rc == 0 || $rc == 1\} \{
    set rc \[$myHandle SQLFetch result headers\]
    if \{ $rc == 0 || $rc == 1\} \{
        set head ""

        puts "\t\t&lt;row&gt;"
        set n 0
        foreach a $result \{
            if \{$n &gt;= $numfields\} \{
                puts "\t\t\t&lt;cell&gt;$a&lt;/cell&gt;"
            \} else \{
                set head "$head\n\t\t&lt;header&gt;$a&lt;/header&gt;"
            \}
            incr n
        \}
        puts "\t\t&lt;/row&gt;"
        incr rows
    \}
\}
puts

"\t</data>\n\t<headers>$head\n\t</headers>\n\t<query>$query</query>\n\t<rows>$rows</rows>\n\t<fields>$numfields</fields>\n</package>"
$myHandle SQLDisconnect

} doRequestCatch] } {
puts "SQL_ERROR: $doRequestCatch"
}
# Some possible return values:
#
# SQL_SUCCESS 0
# SQL_SUCCESS_WITH_INFO 1
# SQL_NO_DATA 100
# SQL_ERROR (-1)
# SQL_INVALID_HANDLE (-2)
# SQL_STILL_EXECUTING 2
# SQL_NEED_DATA 99

produces the following output:

<?xml version="1.0" ?>
<package>
<data>
<row>
<cell>830060430</cell>
<cell> </cell>
<cell>11001.0</cell>
<cell>BOGOTA</cell>
<cell>6.0</cell>
<cell>MELO CONTRERAS MARTHA E</cell>
<cell>51550255.0</cell>
<cell>1500.0</cell>
<cell>PROMEDIO (RECARGOS) VACACIONES</cell>
<cell>1610803.00</cell>
<cell>lopezcrl@yahoo.es</cell>
</row>

..... lots of rows deleted for briefness

    &lt;row&gt;
        &lt;cell&gt;830060430&lt;/cell&gt;
        &lt;cell&gt;XEROX DE COLOMBIA ----&lt;/cell&gt;
        &lt;cell&gt;11001.0&lt;/cell&gt;
        &lt;cell&gt;BOGOTA&lt;/cell&gt;
        &lt;cell&gt;104.0&lt;/cell&gt;
        &lt;cell&gt;PINZON VIRVIESCAS DIANA&lt;/cell&gt;
        &lt;cell&gt;52149211.0&lt;/cell&gt;
        &lt;cell&gt;7000.0&lt;/cell&gt;
        &lt;cell&gt;PAGO NETO&lt;/cell&gt;
        &lt;cell&gt;1977114.00&lt;/cell&gt;
        &lt;cell&gt;lopezcrl@yahoo.es&lt;/cell&gt;
    &lt;/row&gt;
&lt;/data&gt;
&lt;headers&gt;
    &lt;header&gt;pcnit&lt;/header&gt;
    &lt;header&gt;pccia&lt;/header&gt;
    &lt;header&gt;t64&lt;/header&gt;
    &lt;header&gt;DESCRI&lt;/header&gt;
    &lt;header&gt;CEMPLE&lt;/header&gt;
    &lt;header&gt;ANOMTR&lt;/header&gt;
    &lt;header&gt;A121&lt;/header&gt;
    &lt;header&gt;CCONCE&lt;/header&gt;
    &lt;header&gt;JDCONC&lt;/header&gt;
    &lt;header&gt;CC06&lt;/header&gt;
    &lt;header&gt;email&lt;/header&gt;
&lt;/headers&gt;
&lt;query&gt;select \* from pagosprueb&lt;/query&gt;
&lt;rows&gt;414&lt;/rows&gt;
&lt;fields&gt;11&lt;/fields&gt;

</package>
aders: 0GetColumnHeaders: 0GetColumnHeaders:
0GetColumnHeaders: 0GetColumnHeaders:
0GetColumnHeaders: 0GetColumnHeaders:

lots of getcollumnheaders:0 also omited

im working on a win2000 sp 4 1.7ghz with ODBC 3.0 Tcl
Extension and tcl 8.4.11.0 from activestate

this:

GetColumnHeaders: 0

is printed every time i fetch a new row, since the
output of my program is then fed to another program (an
xml parser)
then the output warning generated by the extension is
unacceptable, it should set errno, or whatever it uses
for error handling instead of tossing output into my
xml file, right?

im shure there is a smiple fix for this....

btw: command line is:

tclsh dumpdb.tcl "select * from pagosprueb" 11 >report.xml

Discussion

  • Scott Nichols

    Scott Nichols - 2005-08-12

    Logged In: YES
    user_id=787831

    Thanks for the bug.

    I look into what's causing this. In the meantime you can code
    around this by using SQLFetchAll insead of SQLFetch. Change
    this line in your code:

    set rc [$myHandle SQLFetch result headers]

    To

    set rc [$myHandle SQLFetchAll result headers]

     
  • Scott Nichols

    Scott Nichols - 2005-08-12

    Logged In: YES
    user_id=787831

    Thanks for the bug.

    I'll look into what's causing this. In the meantime you can code
    around this by using SQLFetchAll insead of SQLFetch. Change
    this line in your code:

    set rc [$myHandle SQLFetch result headers]

    To

    set rc [$myHandle SQLFetchAll result headers]

    This will populate the entire result set into the result as a list of
    lists.

     
  • Scott Nichols

    Scott Nichols - 2005-08-18

    Logged In: YES
    user_id=787831

    Dear Tcl Developer,

    The issue with SQLFetch has been resolved in the TclSQL 1.3
    release that can be downloaded from the file releases link:

    http://sourceforge.net/project/showfiles.php?
    group_id=82145&package_id=161187

     
  • Scott Nichols

    Scott Nichols - 2005-08-18
    • status: open --> closed-fixed
     

Log in to post a comment.

Auth0 Logo