_acs-tcl__db__db_foreach (private)

 _acs-tcl__db__db_foreach

Defined in packages/acs-tcl/tcl/test/db-proc-test-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_log aa_log (public) aa_log_result aa_log_result (public) db_foreach db_foreach (public) _acs-tcl__db__db_foreach _acs-tcl__db__db_foreach _acs-tcl__db__db_foreach->aa_equals _acs-tcl__db__db_foreach->aa_log _acs-tcl__db__db_foreach->aa_log_result _acs-tcl__db__db_foreach->db_foreach

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
        set results [list]
        db_foreach query {SELECT a FROM (VALUES (1), (2), (3), (4), (5), (6), (7)) AS X(a)} {
            lappend results $a
        }
        aa_equals "db_foreach collects correct values from query"  [list 1 2 3 4 5 6 7]  $results

        set results ""
        db_foreach query {select 1 from dual where 1 = 2} {
            set results "found"
        } else {
            set results "not found"
        }
        aa_equals "db_foreach executes the 'no row' code block using the 'else' syntax"  "not found"  $results

        set results ""
        db_foreach query {select 1 from dual where 1 = 2} {
            set results "found"
        } if_no_rows {
            set results "not found"
        }
        aa_equals "db_foreach executes the 'no row' code block using the 'if_no_rows' syntax"  "not found"  $results

        # 3 columns
        set results ""
        db_foreach query {select * from (values ('a1','b1','c 1')) as X(a,b,c)} {
            lappend results [list a $a b $b c $c]
        }
        aa_equals "db_foreach with three columns instvars" "{a a1 b b1 c {c 1}}" $results

        set results ""
        db_foreach query {select * from (values ('a1','b1','c 1')) as X(a,b,c)}  -column_array things {
                lappend results [lsort [array get things]]
            }
        aa_equals "db_foreach with three columns" "{a a1 b b1 c {c 1}}" $results

        # 4 columns
        set results ""
        db_foreach query {select * from (values ('a1','b1','c 1','d1')) as X(a,b,c,d)} {
            lappend results [list a $a b $b c $c d $d]
        }
        aa_equals "db_foreach with fopur columns instvars" "{a a1 b b1 c {c 1} d d1}" $results

        set results ""
        db_foreach query {select * from (values ('a1','b1','c 1','d1')) as X(a,b,c,d)}  -column_array things {
                lappend results [lsort [array get things]]
            }
        aa_equals "db_foreach with four columns" "{a a1 b b1 c {c 1} d d1}" $results

        set results ""
        db_foreach query {
            select *
            from (values
                  ('a1','b1','c 1','d1'),
                  ('a2','b2','c 2','d2')
                  ) as X(a,b,c,d)
        } -column_set set_things {
            lappend results [lsort [ns_set array $set_things]]
        }
        aa_equals "db_foreach with four columns"  $results  {{a a1 b b1 c {c 1} d d1} {a a2 b b2 c {c 2} d d2}}

    }} {
          aa_log "Running testcase body $body_count"
          set ::__aa_test_indent [info level]
          set catch_val [catch $testcase_body msg]
          if {$catch_val != 0 && $catch_val != 2} {
              aa_log_result "fail" "db__db_foreach (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: