@@ -543,12 +543,12 @@ sub db_vim_print
543
543
$line_txt = " " ;
544
544
}
545
545
546
- # ans, 2022 - 04 - 08 - allow to print from dbms_output empty lines
547
546
my @l ines = ();
548
547
if (! defined ($line_txt ) || length ($line_txt ) == 0 ) {
549
- @l ines = (" " );
548
+ # from dbms_output it is possible to get empty lines to print
549
+ @l ines = (" " );
550
550
} else {
551
- @l ines = split (" \n " , $line_txt );
551
+ @l ines = split (" \n " , $line_txt );
552
552
}
553
553
554
554
foreach my $line (@l ines) {
@@ -973,9 +973,8 @@ sub db_connect
973
973
LongTruncOk = > 1 ,
974
974
RaiseError = > 0 ,
975
975
PrintError = > 0 ,
976
- ## hello from ans
977
- ora_charset = > ' AL32UTF8' ,
978
- ora_ncharset = > ' AL32UTF8' ,
976
+ ora_charset = > ' AL32UTF8' ,
977
+ ora_ncharset = > ' AL32UTF8' ,
979
978
PrintWarn = > 0 }
980
979
);
981
980
# or die $DBI ::errstr;
@@ -1288,10 +1287,9 @@ sub db_query
1288
1287
return 0 ;
1289
1288
}
1290
1289
1291
- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1292
- # 2021 - 09 - 19 ans: fetch all rows of dbms_output
1293
- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1294
- sub fetch_dbms_output {
1290
+ # Fetches all available rows of dbms_output from server
1291
+ sub fetch_dbms_output
1292
+ {
1295
1293
my ($conn_local ) = (@_ );
1296
1294
1297
1295
my $max_line_size = 32768 ; # anything we put here can be too short...
@@ -1306,7 +1304,7 @@ sub fetch_dbms_output {
1306
1304
$get_lines_st - >bind_param_inout (' :n' , \$ num_lines, 50 , {ora_type = > 1 });
1307
1305
1308
1306
$get_lines_st - >execute ();
1309
- db_debug (" executed get_lines() ok. num_lines = $num_lines" );
1307
+ db_debug (" executed get_lines() ok. num_lines fetched = $num_lines" );
1310
1308
1311
1309
my @t ext_2 = ();
1312
1310
if ($num_lines ) {
@@ -1323,7 +1321,6 @@ sub fetch_dbms_output {
1323
1321
}
1324
1322
}
1325
1323
1326
- #push @t ext_2, " WARNING: please not foget to close the statement, debug version only!!!" ;
1327
1324
$get_lines_st = undef;
1328
1325
1329
1326
## max_line_size exceeded {
@@ -1698,48 +1695,34 @@ sub db_print_results
1698
1695
db_debug (" db_print_results: before last_line(...rows...), last_line=$last_line" );
1699
1696
db_vim_print ($last_line , " (" .scalar (@r esult_set)." rows)" );
1700
1697
if (@d bms_output) {
1701
- $last_line ++ ;
1702
- # ans: we need this " join and afterwards split" trick because otherwise
1703
- # individual rows from @d bms_output are coming encoded differently, see as well
1704
- # exploit Perl_Oracle_DBD_dbms_output/perl_dbd_oracle_dbms_output__inside_vim__simple.vim
1705
- # call :so % | call Check_my_perl__load ()
1706
- ##my @d bms_output_remade = split (" \n " , join (" \n " , @d bms_output));
1707
- # ans: 2021 - 09 - 19 now we use decode (" utf8" ... ) and other method of
1708
- # fetching of array, there are chances we dont need this ugly workaround
1709
- # any more
1710
- db_debug (" db_print_results: \@ dbms_output size: " .scalar (@d bms_output));
1711
- my @d bms_output_remade = @d bms_output;
1712
- for my $dol0 (@d bms_output_remade) {
1713
- #### THIS IS MAGIC ! !!!!!!
1714
- #### THIS_IS_MAGIC ! !!!!!!
1715
- #### THIS IS MAGIC ! !!!!!!
1716
- my $dol = decode (' utf8' , ($dol0 // ' ' ));
1717
- db_debug (" db_print_results: printed dbms_output[i] (raw non-splitted) : " .$dol );
1718
- #chomp ($dol );
1719
-
1720
- # we try to overtake the line number from the " printer" method
1721
- $last_line += db_vim_print ($last_line , $dol );
1722
- #$last_line ++ ;
1723
-
1724
- #my @l ines = split (" \n " , $dol );
1725
- #for my $diag_ln (@l ines) {
1726
- # db_debug (" db_print_results: printed dbms_output[i] (splitted redundantly): " .$diag_ln );
1727
- #}
1728
- }
1729
- db_debug (" db_print_results: printed dbms_output: " . join (" \n " , map { $_ // '' } @dbms_output))
1730
- if ($debug );
1731
- @d bms_output = ();
1732
- $last_line += db_vim_print ($last_line , " printed at: " . scalar localtime );
1698
+ $last_line ++ ;
1699
+ db_debug (" db_print_results: \@ dbms_output size: " .scalar (@d bms_output));
1700
+ for my $dol0 (@d bms_output) {
1701
+ # needed due to (DBI?) encoding problems when receiving from oracle with plsql
1702
+ # in /out table, see https://github.com/ ant0sha/dbext.vim/ commit/b83befafd0fdc45f683aca1fa89b52ab959e8277
1703
+ my $dol = decode (' utf8' , ($dol0 // ' ' ));
1704
+ db_debug (" db_print_results: printed dbms_output[i] (raw non-splitted) : " .$dol );
1705
+ #chomp ($dol );
1706
+
1707
+ # we try to overtake the line number from the " printer" method
1708
+ $last_line += db_vim_print ($last_line , $dol );
1709
+ #$last_line ++ ;
1710
+ }
1711
+ if ($debug ) {
1712
+ db_debug (" db_print_results: printed dbms_output: " . join (" \n " , map { $_ // '' } @dbms_output))
1713
+ }
1714
+ @d bms_output = ();
1715
+ $last_line += db_vim_print ($last_line , " printed at: " . scalar localtime );
1733
1716
} else {
1734
- $last_line ++ ;
1735
- my ($connection_ignored , $driver_ignored , $z_user_data ) = db_get_connection ();
1736
- if ($z_user_data - >{z_srv_out_enabled}) {
1737
- db_vim_print ($last_line , " dbms_output is empty." );
1738
- db_debug (" db_print_results: dbms_output is empty." );
1739
- } else {
1740
- db_vim_print ($last_line , " ACHTUNG: dbms_output is OFF." );
1741
- db_debug (" db_print_results: dbms_output is OFF." );
1742
- }
1717
+ $last_line ++ ;
1718
+ my ($connection_ignored , $driver_ignored , $z_user_data ) = db_get_connection ();
1719
+ if ($z_user_data - >{z_srv_out_enabled}) {
1720
+ db_vim_print ($last_line , " dbms_output is empty." );
1721
+ db_debug (" db_print_results: dbms_output is empty." );
1722
+ } else {
1723
+ db_vim_print ($last_line , " ACHTUNG: dbms_output is OFF." );
1724
+ db_debug (" db_print_results: dbms_output is OFF." );
1725
+ }
1743
1726
}
1744
1727
db_debug (" db_print_results: returning 0" );
1745
1728
return 0 ;
@@ -1947,37 +1930,39 @@ sub db_results_list
1947
1930
sub db_enable_srv_out
1948
1931
{
1949
1932
1950
- # see ~/Documents/0.mop/Perl_Oracle_DBD_dbms_output/dbms_output_test_case_1.vim
1951
- # for automated test case :
1952
- # vim - c ' source ~/Documents/0.mop/Perl_Oracle_DBD_dbms_output/dbms_output_test_case_1.vim|call Test_Case_1()'
1933
+ # TODO : refactor/publish related automated test case for dbms_output, which
1934
+ # can be called like this:
1935
+ #
1936
+ # vim - c 'source \
1937
+ # Perl_Oracle_DBD_dbms_output/dbms_output_test_case_1.vim |call \
1938
+ # Test_Case_1 ()'
1953
1939
1954
- my ($conn_local , $driver , $z_user_data ) = db_get_connection ();
1955
- if ($z_user_data - >{z_srv_out_enabled}) {
1956
- db_debug (" skip <enable> of already enabled server output" );
1957
- }
1958
- else {
1959
- $conn_local - >func ( 1000000 , ' dbms_output_enable' );
1960
- $z_user_data - >{z_srv_out_enabled} = 1 ;
1961
- }
1940
+ my ($conn_local , $driver , $z_user_data ) = db_get_connection ();
1941
+ if ($z_user_data - >{z_srv_out_enabled}) {
1942
+ db_debug (" skip <enable> of already enabled server output" );
1943
+ }
1944
+ else {
1945
+ $conn_local - >func ( 1000000 , ' dbms_output_enable' );
1946
+ $z_user_data - >{z_srv_out_enabled} = 1 ;
1947
+ }
1962
1948
1963
- #db_set_vim_var (' g:dbext_dbi_msg' , ' A request_type must be specified' );
1964
- #db_set_vim_var (' g:dbext_dbi_result' , -1 );
1949
+ #db_set_vim_var (' g:dbext_dbi_msg' , ' A request_type must be specified' );
1950
+ #db_set_vim_var (' g:dbext_dbi_result' , -1 );
1965
1951
}
1966
1952
1967
1953
sub db_disable_srv_out
1968
1954
{
1969
- my ($conn_local , $driver , $z_user_data ) = db_get_connection ();
1970
- if ($z_user_data - >{z_srv_out_enabled}) {
1971
- my $stmt = $conn_local - >prepare_cached ( ' begin dbms_output.disable; end;' );
1972
- $stmt - >execute ();
1973
- $z_user_data - >{z_srv_out_enabled} = 0 ;
1974
- }
1975
- else {
1976
- db_debug (" skip <disable> of already disabled server output" );
1977
- }
1955
+ my ($conn_local , $driver , $z_user_data ) = db_get_connection ();
1956
+ if ($z_user_data - >{z_srv_out_enabled}) {
1957
+ my $stmt = $conn_local - >prepare_cached ( ' begin dbms_output.disable; end;' );
1958
+ $stmt - >execute ();
1959
+ $z_user_data - >{z_srv_out_enabled} = 0 ;
1960
+ } else {
1961
+ db_debug (" skip <disable> of already disabled server output" );
1962
+ }
1978
1963
1979
- #db_set_vim_var (' g:dbext_dbi_msg' , ' A request_type must be specified' );
1980
- #db_set_vim_var (' g:dbext_dbi_result' , -1 );
1964
+ #db_set_vim_var (' g:dbext_dbi_msg' , ' A request_type must be specified' );
1965
+ #db_set_vim_var (' g:dbext_dbi_result' , -1 );
1981
1966
}
1982
1967
1983
1968
db_set_vim_var (' g:loaded_dbext_dbi_msg' , ' db_ora_extract_ddl' );
@@ -2108,7 +2093,7 @@ sub db_ora_extract_ddl
2108
2093
end loop;
2109
2094
end ;
2110
2095
2111
- dbms_output.put_line (' gesmtlaenge=' || length (ddl)|| ' , iNL=' || iNL);
2096
+ -- dbms_output.put_line (' gesmtlaenge=' || length (ddl)|| ' , iNL=' || iNL);
2112
2097
exception when others then
2113
2098
l (' exception happened' );
2114
2099
declare
0 commit comments