Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Bareword found in conditional at C:\Perl\scripts\test\newer.pl line 43.

In your while statement, I think you want to read from INPUT so put it in brackets like

while (<INPUT>)

Use of uninitialized value in split at C:\Perl\scripts\test\newer.pl line 26.

You get this error because of the one above. Since you didn't read from INPUT into $_, it was undefined when you attempted to use it as input to split.

Use of uninitialized value in concatenation (.) or string at C:\Perl\scripts\test\newer.pl line 33.

You've never assigned anything to $row or $field. Also, why are you interpolating these into strings to compare them? You could have just done $row eq $field1.

Update:$row and @row are two different variables. Your SELECT returned data to @row which is an array. $row is a scalar that just happens to share a name with the @row array but is otherwise a different variable.

Use of uninitialized value in concatenation (.) or string at C:\Perl\scripts\test\newer.pl line 35.

Again, you haven't assigned any value to $field2. Also, since you never read from the file, $driver is also undefined.

"DBD::ODBC::db prepare failed: MicrosoftODBC Microsoft Access Driver Syntax error in INSERT INTO statement. (SQL-42000)(DBD: st_prepare/SQLPrepare err=-1) at C:\Perl\scripts\test\newer.pl line 36.

Since $field2 doesn't have a value, the field list in your insert statement equates to an empty list which is not allowed.

Can't call method "execute" on an undefined value at C:\Perl\scripts\test\newer.pl line 37."

Since the prepare failed, $sth2 is undefined.

Non-syntax errors:

Move your database connect and statement prepares outside the loop. They only have to be done once.

You stated that you wanted to update a field. INSERT adds records to the database. I think you want an UPDATE statement instead.

Unless you include a WHERE clause in your SQL statements, they will act on all rows in the table. Your SELECT statement will return every row from the table. I think you want to add a WHERE clause to limit the returned data to the server that you just read from the file. The same applies to the UPDATE.

Also, the SELECT isn't necessary. You don't need to read a record before updating it.

90% of every Perl application is already written.
dragonchild

In reply to Re: Updating Specific Fields in MS Access by pfaut
in thread Updating Specific Fields in MS Access by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found