Gossamer Forum
Home : General : Databases and SQL :

Insert won't Insert!

Quote Reply
Insert won't Insert!
I can't get my SQL code to INSERT a new row into a tableUnsure See both sets of red for pertenant bits.



my $ed = $DB->table('Editors');
my $details = $DB->table('EditorDetails');
my $number_of_editors; #number of editors in Editors
my $editors_in_details; #number of editors in EditorDetails
my @usernames_e; #list of Usernames from Editors
my @usernames_ed; #list of Usernames from EditorDetails

#Select the Usernames field from 'Editors'
blah blah

#Select the Usernames field from 'EditorDetails'
blah blah


#make a list which contains the difference between both Username lists
blah blah


#if there is a discrepancy between numbers then update EditorDetails
if ($editors_in_details == $number_of_editors) {
print "Number of Editors: Ok<br>";
}
else {
print "<b>Difference between tables:</b> [@userdifference]<br>";
print "<b>Number of Editors:</b> Updating table EditorDetails...";
#update EditorDepth with new usernames
my $editorname=();
foreach $editorname (@userdifference) {
$details->insert ( { Username => $editorname, Email => "Not Shown" });
print "($editorname inserted)";
}
print "Ok<br>";
}
print "<hr>";


http://www.iuni.com/...tware/web/index.html
Links Plugins

Last edited by:

sooke: May 18, 2002, 7:03 PM
Quote Reply
Re: [sooke] Insert won't Insert! In reply to
To see what causes the error, use
Code:
$details->insert ( { Username => $editorname, Email => "Not Shown" }) or die $GT::SQL::error;

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Insert won't Insert! In reply to
Thanks for that Ivan.

I get an error which contains: cgi-bin/admin/defs/lsql_EditorDetails.def' does not exist or the permissions are set incorrectly.

I did not realise I need to create a .def file when making new tables in Links?


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Ian] Insert won't Insert! In reply to
>>
I did not realise I need to create a .def file when making new tables in Links?
<<

You don't...links sql does it. Make sure it exists and the permissions are right...if it diesn't exist, drop and recreate the table.
Quote Reply
Re: [Ian] Insert won't Insert! In reply to
Did you create the table via LINKS SQL? If so, then like Paul stated, the .def file should be created automatically. However, if you created the table outside of LINKS SQL, like via shell or some other application, then the .def file would not be created automatically.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Ian] Insert won't Insert! In reply to
As far as I know, you cannot create tables through Links SQL, you can only edit exisiting tables. You would need to write a little script that creates the table using the GT library (see documentation). Then the .def file is created automatically.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Insert won't Insert! In reply to
>>
As far as I know, you cannot create tables through Links SQL, you can only edit exisiting tables. You would need to write a little script that creates the table using the GT library (see documentation).
<<

That doesn't make sense.....you said you can't create tables, then you said you can using the GT libs Cool

But the answer is yes you can create tables.

Last edited by:

Paul: May 27, 2002, 1:16 AM
Quote Reply
Re: [Paul] Insert won't Insert! In reply to
I wasn't very clear...

What I meant is that you cannot create tables from the admin section of Links SQL. Of course, you can create tables in a script using the GT libraries....

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Insert won't Insert! In reply to
Yeah I just realised that whilst I was reading another thread and was on my way back to the thread but you beat me :)
Quote Reply
Re: [Paul] Insert won't Insert! In reply to
Hi Guys! Thanks for all the help and comments.Smile

I am creating this table from a plugin sub using creator-> , which seems to have created the table. But not the .def file.

I have been quite sick the last few days, so I will post back here when I can concentrate a little better I think!!


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Paul] Insert won't Insert! In reply to
I've got this working now, thanks everyone.

The problem was, my install file was "cleared" of the code which created the table in the first place, when I re-ran the plugin wizard. Something to watch out for!!! I had to re-write all of the table creation code, and that seemed to have fixed thisSmile


http://www.iuni.com/...tware/web/index.html
Links Plugins