Programming Pointer

G

Gary

I have a simple cgi in perl that basically dumpls a file to the screen from
an SQL database and every field can be chaged. Once I have written the rows
to the screen, and the user has changed potentially several rows, what is
the easiest way to update the database with the new entries ?

Basically existing Perl program looks like this.

# make connection to database
$dbh = DBI->connect($connectionInfo,$userid,$passwd);

# prepare and execute query
$query = "SELECT * FROM WGTextDescription";

$sth = $dbh->prepare($query);
$sth->execute();

# assign fields to variables
$sth->bind_columns(\$QId, \$QSId, \$Description);

$V1=1;

while($sth->fetch()) {
print "<tr><td><input type=hidden name=A$V1 value=$QId>$QId<td><input
type=hidden name=B$V1 value=QSId>$QSId<td><input type=textbox
value=$Description name=D$V1>\n";
$V1=$V1+1;
}

QId and QSId are keys on the file which do not need to be displayed, but
$Description can be changed and needs to be stored after alteration.

The crude way would be as I have done which is to assign each field output
to the screen a code (A$V1) which later I can loop through and use to update
the relevant database rows, BUT there must be a cleaner method -

Any help appreciated.

20+ years programming experience but not in Perl.

Thanks
Gary
 
W

William Herrera

I have a simple cgi in perl that basically dumpls a file to the screen from
an SQL database and every field can be chaged. Once I have written the rows
to the screen, and the user has changed potentially several rows, what is
the easiest way to update the database with the new entries ?

Basically existing Perl program looks like this.

# make connection to database
$dbh = DBI->connect($connectionInfo,$userid,$passwd);

# prepare and execute query
$query = "SELECT * FROM WGTextDescription";

The problem is not Perl DBI, you have that down, more or less. It's that you
want a nice GUI interface for updates? And don't feel like drawing one up
yourself?

Look at some of the existing interfaces, eg
http://www.cgiscriptshop.com/products/mdm/index.html

and maybe use some of those ideas.
 
W

William Herrera

I have a simple cgi in perl that basically dumpls a file to the screen from
an SQL database and every field can be chaged. Once I have written the rows
to the screen, and the user has changed potentially several rows, what is
the easiest way to update the database with the new entries ?

Basically existing Perl program looks like this.

# make connection to database
$dbh = DBI->connect($connectionInfo,$userid,$passwd);

# prepare and execute query
$query = "SELECT * FROM WGTextDescription";

The problem is not Perl DBI, you have that down, more or less. It's that you
want a nice GUI interface for updates? And don't feel like drawing one up
yourself?

Look at some of the existing interfaces, eg
http://www.cgiscriptshop.com/products/mdm/index.html

and maybe use some of those ideas.
 
G

Gary

Are you saying that the crude way I have described here is the way.

i.e There is no changed record status maintained or clever little technique
for doing this update. You have to actually code it (Updates)manually in
full every time.

Assuming you do not buy the tools where it is already written for your use.

regards
Gary
 
W

William Herrera

Are you saying that the crude way I have described here is the way.

i.e There is no changed record status maintained or clever little technique
for doing this update. You have to actually code it (Updates)manually in
full every time.

How would you do this in straight SQL queries on the database in question?
Assuming you do not buy the tools where it is already written for your use.

Unless you arrange to cache the updates yourself (that is, create a duplicate
database and just sync the two datasets occasionally), yes, you need to inform
the database of the changes each time. I beleieve this would be true no matter
what SQL interface you were using, of course.

In addition, there is the question of whether your changes are to result in a
changed record (I guess you mean to do that?) or add a new one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top