in reply to need to access a remote server to move the files around in a set folder there

UPDATE
Works fine so far.
Now I am in the process of building a CGI program to insert, update and delete from the database.
here are the problems That I face.
  1. The db is as decribed.There is a auto number column in the table that acts as the primary key.
  2. I am trying to insert just the values for sys, report and job for the table from user input.
  3. I am using the following statement to insert. INSERT INTO LOOKUP (SYS_ACC,REPORT_NAME,JOB_NAME) VALUES \'$sys\',\rpt\',\'$job\'
  4. my $sqlstatement="insert into lookup (Sys_Acc) values \'$sys_acc\' "; print "<br> $sqlstatement"; $sth = $dbh->prepare($sqlstatement) or die "$DBI::errstr"; $sth->execute(); $dbh->commit(); $dbh->disconnect() or warn "Disconnection Failed \t : $DBI::errstr \n" +;
    Even if i try just one simple thing, it gives ora 42000 SQL error ie SYNTAX ERROR.

Can anyone help me out?Any suggestions ?
  • Comment on Re: need to access a remote server to move the files around in a set folder there
  • Download Code

Replies are listed 'Best First'.
Re^2: need to access a remote server to move the files around in a set folder there
by juster (Friar) on Dec 10, 2008 at 20:16 UTC

    Well, I would say kowtow towards the error message and admit to yourself you may have an error in your SQL syntax. Denial is the first stage! Looks like you are missing parenthesis?

    In general, RTFM if you get into trouble. Type SQL INSERT INTO at Google and click I'm feeling lucky. You are also still not using prepare and execute properly IMO like they are meant to be used (and are described in the manual).

    # For example: my $sql = "insert into lookup (SYS_ACC,REPORT_NAME,JOB_NAME) values (? +,?,?)"; my $sth = $dbh->prepare($sql) or die $dbh->errstr; $sth->execute($sys_acc, $report, $job) or die $sth->errstr #update: fo +rgot error check # Easier to read and how it was intended.

    Or you could use do:

    my $countofrowsaffected = $dbh->do($sql, undef, $sys_acc, $report, $jo +b) or die $dbh->errstr;

    I tend to test SQL statements on their own outside of perl before I put them in code. I use mysql's command line client but there are many alternatives.