on Mon, 12 Aug 2002 08:08:18 GMT, [EMAIL PROTECTED] (Theuerkorn Johannes) wrote:
I hope you don't mind me saying so, but you have written some quite horrible (unmaintainable) code here ;-) I'll try to give some general comments. If you would give us some more details about your datamodel and about the things you want to do with the data in you program, we probably could give more detailed comments. > sub board_database{ > > my $sth = $dbh->prepare( "SELECT * FROM $table where serial=@_" ) You have a bug here. The select statement should read: "SELECT * FROM $table WHERE serial = $_[0]" You get away with it here because of the particular way an array is interpolated in double quotes. Also, where is the '$table' variable defined? I would do this as follows (but see below): sub board_database { my $serial = shift; my $sth = $dbh->prepare("SELECT * FROM atable WHERE serial = ?") or die "..."; $sth->execute($serial) or die "..."; # rest of code... } It is never a good idea to do a "SELECT * FROM ...", since in principle you do not know it what order the fields are returned. (What if someone changed the order of the fields, or added a field in the definition of the table?). So always use "SELECT field1, field2, field3 FROM atable WHERE ..."; > while (my ($tstamp,$serial,@ergebnis) = $sth->fetchrow_array ){ > push @tstamp_board , $tstamp; > push @serial , $serial; > push @retests , $ergebnis[0]; [ 29 lines of code snipped ] > push @qu25 , $ergebnis[30]; You are stuffing the results of your query into a bunch of global parallel arrays here - a very bad idea. > Now i want to call the Sub not onla once, but I donīt want to lose > the previous Values, so I tried this in the sub: It might be useful if you told us what you are trying to accomplish. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]