I've only been using SQLite for 5 days so I'm very much a beginner.
I just spent an hour or so working out how to get a list of column
headers from a table and come up with the script below, which will do
fine, but I wonder if there's a more elegant way to do it.
#!/usr/local/bin/perl
use
At 22:41 -0800 25/01/2011, Darren Duncan wrote:
>How long have you been using Perl?
>
>Anyway, to start with I would replace the last couple lines with:
>
>my $catalog_rowset = $dbh->selectall_arrayref("PRAGMA
>table_info(contacts)") ;
>my @col_names = map { $_->[1] } @{$catalog_rowset};
I thought I was making a bit of progress but I've come up against a
brick wall trying to do what appears to be the most simple thing.
A button pressed in the page to delete a selected record is stripped
of its display name to become simply the rowid.
When I run the statement in the sqlite
On 28 January 2011 16:19, Simon Slavin wrote:
> I strongly suspect that your value for $q{BUTTON} is wrong. Can you add a
> diagnostic like to display it ?
Yes, I realised immediately after posting that I had duplicated the
substitution in the stand-alone script so
At 16:44 + 28/01/2011, Black, Michael (IS) wrote:
>Me thinkst you need to put singled quotes around $q{BUTTON}.
>
>my $rows = $dbh->do("DELETE FROM contacts WHERE rowid =\'$q{BUTTON}\'");
SInce the statement is in double quotes I surely wouldn't want to
escape the single quotes, but, as I
At 11:08 -0600 28/01/2011, Puneet Kishor wrote:
>Can't really say what you are doing wrong, but you code is needlessly
>complicated; all those tildes are making my eyes swim.
I also have difficulty interpreting escaped toothpicks, and I didn't
joint the sqlite list to have my Perl style
At 11:33 -0600 28/01/2011, Puneet Kishor wrote:
> > Why would you do this rather than use $dbh->do ? It seems to add a
>> line of code to no purpose.
>
>Because I find using bind values easier, clearer, and safer, even for
>one-off execute statements.
Well, that makes sense.
> > And
On 28 January 2011 16:37, I wrote:
> Once I 'd deleted the second line it did work in the standalone
> script. But the duplication is not in the cgi version. Nevertheless
> now I am assured that it does work, I've just got to find what silly
> mistake I've made in the main script. I already
Google mail seems to have chosen a convenient moment to go AWOL.
I wrote:
print qq~\$q{BUTTON} was: $q{BUTTON}~;
if ($q{BUTTON} =~ s~^Delete[^\d]+~~i){
print qq~\$q{BUTTON}=$q{BUTTON}~;
###my $rows = $dbh->do("DELETE FROM contacts WHERE rowid = $q{BUTTON}");
my $sth =
I now have the script running as required on the remote server, apart
from a couple of creases I'd like you to help me iron out. What I
unwittingly held back, and which you would have picked up on straight
way, was my connect routine, to which I added "{ RaiseError => 1,
AutoCommit => 0 }"
10 matches
Mail list logo