Beta Shell
v2.0 ยท web2.us.cloudlogin.co
[FM]
[CMD]
[PHP]
[DB]
[INFO]
[SEC]
File Manager
~
/
usr
/
share
/
doc
/
perl-SQL-Interp
/
ex
Upload
4 items
Name
Size
Perms
Modified
Actions
[ .. / .. ]
basic.pl
932 B
-rw-r--r--
2021-02-15 09:24:39
Edit
Del
dbi.pl
889 B
-rw-r--r--
2021-02-15 09:24:39
Edit
Del
Editing: basic.pl
(932 B)
Path: /usr/share/doc/perl-SQL-Interp/ex/basic.pl
Back
# one.pl # simple tests of SQL::Interp. use strict; use Data::Dumper; use SQL::Interp qw(:all); my @colors = ('blue', 'green'); my $x = 5; my($sql, @bind) = sql_interp qq[ SELECT * FROM table WHERE color IN], \@colors, qq[ AND y = ], \$x, "LIMIT", \10, "OFFSET", \0 ; print "$sql\n" . Dumper(\@bind); @colors = (); ($sql, @bind) = sql_interp qq[ SELECT * FROM table WHERE color IN], \@colors, qq[ AND y = ], \$x, "LIMIT", \10, "OFFSET", \0 ; print "$sql\n" . Dumper(\@bind); my $new_color = 'red'; my $new_shape = 'square'; ($sql, @bind) = sql_interp qq[ INSERT INTO table ], { color => $new_color, shape => $new_shape} ; print "$sql\n" . Dumper(\@bind); my $color = 'yellow'; ($sql, @bind) = sql_interp qq[ UPDATE table SET ], { color => $new_color, shape => $new_shape}, qq[ WHERE color <> ], \$color ; print "$sql\n" . Dumper(\@bind);