anjela patnaik wrote:
> Hello all,
>
> I've a table in oracle that contains fields of type varchar2. In these fields
> are TCL scripts that contain backslash chars and brackets.
>
> Now, I've generated an SQL file from the Oracle table data that contains SQL
> insert statements. I then use sqlite .read to read in the entire db. This
> runs fine with no issues.
>
> However, when I select the rows using SQLite (TCL api), I notice some of the
> data comes back garbled and messed up. This doesn't happen to all of the
> rows, just some of them.
>
> How do I get around this? It's not exactly clear why the SQLite TCL API is
> not handling some of the data properly.
>
> Note that when I do a select using the sqlite3 command API, I don't see any
> problems.
>
> Below is the insert corresponding to a row that comes back messed up. By
> messed up, I mean that the data that comes back has a \ for every space in
> the original field. But that is not what the original data contained.
>
> Thanks for any help!!
>
>
> Insert into AUTO
> (OPERATION, INTERFACE, OCRELEASE, RUNDATE, PRODUCTS, SERVER, REQUEST,
> REQUEST2, RESPONSE)
> Values
> ('addConnections', 'MultiLayerSubnetworkMgr_I', '9.0.1', '01/16/2009',
> '{Core CI}',
> '10.120.6.104', ' set ver 7.1
> set callName \
> [NamingAttributes_T $ver \
> [NVSList_T $ver \
> [NameAndStringValue_T $ver \
> "EMS" \
> "CI/LightWorks_ON-Center" \
> ] \
> [NameAndStringValue_T $ver \
> "Call" \
> "Tunnel" \
> ] \
> ] \
> ]
> set connectionsToAdd \
> [SNCCreateDataList_T $ver \
> [SNCCreateData_T $ver \
> "" \
> "false" \
> "" \
> "1" \
> "1" \
> "3" \
> "2" \
> "2" \
> "0" \
> [LayerRate_T $ver \
> "14" \
> ] \
> [CrossConnectList_T $ver \
> ] \
> [ResourceList_T $ver \
> ] \
> "false" \
> [ResourceList_T $ver \
> ] \
> [NamingAttributesList_T $ver \
> [NamingAttributes_T $ver \
> [NVSList_T $ver \
> [NameAndStringValue_T $ver \
> "EMS" \
> "CI/LightWorks_ON-Center" \
> ] \
> [NameAndStringValue_T $ver \
> "ManagedElement" \
> "inci095" \
> ] \
> [NameAndStringValue_T $ver \
> "FTP" \
>
> "/rack=1/shelf=3/slot=15/port_group=1/port=Tunnel" \
> ] \
> [NameAndStringValue_T $ver \
> "CTP" \
> "/sts1_au3=29" \
> ] \
> ] \
> ] \
> ] \
> [NamingAttributesList_T $ver \
> [NamingAttributes_T $ver \
> [NVSList_T $ver \
> [NameAndStringValue_T $ver \
> "EMS" \
> "CI/LightWorks_ON-Center" \
> ] \
> [NameAndStringValue_T $ver \
> "ManagedElement" \
> "inci095" \
> ] \
> [NameAndStringValue_T $ver \
> "PTP" \
> "/rack=1/shelf=3/slot=2/sub_slot=1/port=1" \
> ] \
> [NameAndStringValue_T $ver \
> "CTP" \
> "/sts1_au3=27" \
> ] \
> ] \
> ] \
> ] \
> [NVSList_T $ver \
> [NameAndStringValue_T $ver \
> "SNC_NAME" \
> "ethSNC222" \
> ] \
> [NameAndStringValue_T $ver \
> "SNC_PREEMPTING" \
> "No" \
> ] \
> [NameAndStringValue_T $ver \
> "SNC_PREEMPTABILITY" \
> "No" \
> ] \
> [NameAndStringValue_T $ver \
> "SNC_PRIORITY" \
> "0" \
> ] \
> [NameAndStringValue_T $ver \
> "SNC_UNPROTECTED_LINES" \
> "Yes" \
> ] \
> [NameAndStringValue_T $ver \
> "SNC_PROTECT_LINES" \
> "No" \
> ] \
> [NameAndStringValue_T $ver \
> "SNC_LINEAR_APS_PROTECTED_LINES" \
> "No" \
> ] \
> [NameAndStringValue_T $ver \
> "SNC_VLSR_PROTECTED_LINES" \
> "No" \
> ] \
> ] \
> ] \
> ]
> set tpsToModify \
> [TPDataList_T $ver \
> ]
> if [catch {', 'addConnections $thread $callName $connectionsToAdd
> tpsToModify connectionList errorReason} err] {
> puts stderr "addConnections failed, err = $err"
> }
> '
>
> Now select returns this goofy looking data. I've chopped off the output.
>
> \ \ set\ ver\ 7.1\r\n\r\n\ \ set\ callName\ \\\r\n\ \ \ \
> \[NamingAttributes_T\ \$ver\ \\\r\n\ \ \ \ \ \ \ \ \[NVSList_T\ \$ver\
> \\\r\n\ \
>
The TCL sqlite API returns values as list items. To demonstrate
(Temp) 47 % set cmd {\ \ set\ ver\ 7.1\r\n\r\n\ \ set\ callName\ \\\r\n\
\ \ \ \[NamingAttributes_T\ \$ver\ \\\r\n\ \ \ \ \ \ \ \ \[NVSList_T\
\$ver\ \\\r\n\ \ }
\ \ set\ ver\ 7.1\r\n\r\n\ \ set\ callName\ \\\r\n\ \ \ \
\[NamingAttributes_T\ \$ver\ \\\r\n\ \ \ \ \ \ \ \ \[NVSList_T\ \$ver\
\\\r\n\ \
(Temp) 48 % lindex $cmd 0
set ver 7.1
set callName \
[NamingAttributes_T $ver \
[NVSList_T $ver \
Assuming you are only selecting one column from one row each time , you
can use either
set response [ lindex [ myDb eval "select RESPONSE from AUTO where
............."] 0 ]
or
set response [ myDb onecolumn "select RESPONSE from AUTO where
............."]
see http://www.sqlite.org/tclsqlite.html#onecolumn for more detail on
onecolumn
Regards
Lawrence Chitty
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users