RE: Insert data in one table from Another Problem

2011-02-17 Thread Travis Ard
Here's one option to pivot your results:

select
record_id
,max(soi) as soi
,max(heading) as heading
,max(description) as description
,max(relloc) as relloc
from
(select 
record_id
,if(field_name = 'SOI', field_value, '') as soi
,if(field_name = 'Heading', field_value, '') as heading
,if(field_name = 'Description', field_value, '') as description
,if(field_name = 'RelLoc', field_value, '') as relloc
from user_news) s1
group by s1.record_id;



-Original Message-
From: Adarsh Sharma [mailto:adarsh.sha...@orkash.com] 
Sent: Wednesday, February 16, 2011 6:33 AM
To: mysql@lists.mysql.com
Subject: Insert data in one table from Another Problem

 
Dear all,

Today I am puzzled around a problem of inserting data into new table in 
new format. I have a table named *user_news* as :

We have four rows with respect to each record_id.

fore.g : I have listed main columns as
*record_id   field_name   field_value*
572SOIMedia
572  Heading   A senior Police official confirmed the 
presence of the stone quarry at Jafflong near the India-Bangladesh border
572Description HNLC runs a stone quarry in Jafflong 
District of Bangladesh. The outfit is also believed to own several betel 
nut plantations besides running other business in Bangladesh.
572  RelLoc Jafflong

578SOI   Media
578 Heading   Army Chief General V. K. Singh in Shillong 
said he was confident that the NDFB would come to the negotiating table 
if they are handled properly
578Description   A school teacher was abducted by 
unidentified militants in Damas of East Garo Hills District. Army Chief 
General V. K. Singh in Shillong said he was confident .
578   RelLoc  Garo Hills

Similarly i have 1000 of rows.

Now I create a new table as columns as :

*record_id  SOI  heading  Description   RelLoc *  and its 
values is as :
 *  

*
572   MediaA senior Police official confirmed the 
presence of the stone quarry at Jafflong near the India-Bangladesh 
border HNLC runs a stone quarry in Jafflong District of 
Bangladesh.  Jafflong  



   

 
The values in *field_name* becomes four columns in the above table . and 
their values are the values of f*ield_value *column.

The problem is that I want this data now in horizontal form and the data 
of four rows in one row. That is four rows in one table contributes a 
single row in *other *table.

I try with procedures and cursors but fail to achieve the output.

Is it possible in Mysql. Please guide me how to achieve this as I am 
stuck around it.



Thanks  Best Regards

Adarsh Sharma













-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: INSERT DATA INTO TABLE

2009-11-28 Thread mos

At 12:09 AM 11/28/2009, Krishna Chandra Prajapati wrote:

Hi Mos,

In the below two command does 1 is faster than 2.


1. LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;

2. LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet LINES TERMINATED 
BY '\r\n' enclosed by '';



Thanks,
Krishna Ch. Prajapati


Krishna,
They are the same speed.  #2 only gives additional information on how 
the CSV file is formatted. The Load Data, in case you weren't already 
aware, imports comma delimited data from a text file into a MySQL table. 
The LINES TERMINATED BY '\r\n' enclosed by ' ' only tells MySQL how the 
data is formatted.


Before we delve into this any further, how many rows of data are you 
loading? And what table type: MyISAM or InnoDb?


Mike



On Sat, Nov 28, 2009 at 3:50 AM, mos 
mailto:mo...@fastmail.fmmo...@fastmail.fm wrote:

At 07:40 AM 11/27/2009, Krishna Chandra Prajapati wrote:

Hi Experts,

load data local infile and insert into tablename are the two methods of
inserting data into a mysql table.

Out of the above two method. Is there any faster method of inserting data
into mysql tables.


No. Load Data is the fastest method, unless the data is already stored in 
another table.


Tip: Remember when using Load Data, it will be faster if the table is 
empty and optimized (no holes) than with a table that has data in it. 
That's because the non-unique indexes are built after all of the data has 
been loaded. The alternative is to disable the non-unique indexes prior 
to using Load Data. Unfortunately there is no way to disable the building 
of unique indexes during this process unless you remove the unique index 
prior to loading the data and building it later.


Tip: Using Insert will be much slower than Load Data but you can speed it 
up by loading dozens of rows using one Insert statement.


Hope these tips help.

Mike

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysqlhttp://lists.mysql.com/mysql
To 
unsubscribe: 
http://lists.mysql.com/mysql?unsub=prajapat...@gmail.comhttp://lists.mysql.com/mysql?unsub=prajapat...@gmail.com



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: INSERT DATA INTO TABLE

2009-11-27 Thread mos

At 07:40 AM 11/27/2009, Krishna Chandra Prajapati wrote:

Hi Experts,

load data local infile and insert into tablename are the two methods of
inserting data into a mysql table.

Out of the above two method. Is there any faster method of inserting data
into mysql tables.


No. Load Data is the fastest method, unless the data is already stored in 
another table.


Tip: Remember when using Load Data, it will be faster if the table is empty 
and optimized (no holes) than with a table that has data in it. That's 
because the non-unique indexes are built after all of the data has been 
loaded. The alternative is to disable the non-unique indexes prior to using 
Load Data. Unfortunately there is no way to disable the building of unique 
indexes during this process unless you remove the unique index prior to 
loading the data and building it later.


Tip: Using Insert will be much slower than Load Data but you can speed it 
up by loading dozens of rows using one Insert statement.


Hope these tips help.

Mike 



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: INSERT DATA INTO TABLE

2009-11-27 Thread Krishna Chandra Prajapati
Hi Mos,

In the below two command does 1 is faster than 2.

*
1. LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;*

 2. *LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet* *LINES
TERMINATED BY '\r\n' enclosed by '';*

Thanks,
Krishna Ch. Prajapati


On Sat, Nov 28, 2009 at 3:50 AM, mos mo...@fastmail.fm wrote:

 At 07:40 AM 11/27/2009, Krishna Chandra Prajapati wrote:

 Hi Experts,

 load data local infile and insert into tablename are the two methods of
 inserting data into a mysql table.

 Out of the above two method. Is there any faster method of inserting data
 into mysql tables.


 No. Load Data is the fastest method, unless the data is already stored in
 another table.

 Tip: Remember when using Load Data, it will be faster if the table is empty
 and optimized (no holes) than with a table that has data in it. That's
 because the non-unique indexes are built after all of the data has been
 loaded. The alternative is to disable the non-unique indexes prior to using
 Load Data. Unfortunately there is no way to disable the building of unique
 indexes during this process unless you remove the unique index prior to
 loading the data and building it later.

 Tip: Using Insert will be much slower than Load Data but you can speed it
 up by loading dozens of rows using one Insert statement.

 Hope these tips help.

 Mike

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:
 http://lists.mysql.com/mysql?unsub=prajapat...@gmail.com




RE: insert data in to columns base on the selection of the list box.

2007-04-03 Thread Jerry Schwartz
Without knowing where the values of column2, column3, and column4 are coming
from it's a little hard to say what the best technique would be. Usually one
would take the POSTed value from the select control and use it to retrieve
the related data from a table in your data base.


Regards,

Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341


 -Original Message-
 From: sam rumaizan [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, April 03, 2007 6:51 AM
 To: mysql@lists.mysql.com
 Subject: insert data in to columns base on the selection of
 the list box.



 Can you help me please?


 1-I have created a while loop to populate the list box
 with the information of column1.
 2-I need to update (insert data) in to column2,
 column3, column4 base on the selection of the list box.


 echo'form';



  $query = SELECT  column1 FROM table;

$result = mysql_query($query);

 echobr;



 echobr;

 echocenter;





 echoselect NAME='R';

 echooption value='NULL'Choose a Category:/option

 ;

while ($line = mysql_fetch_array($result))

{

   foreach ($line as $value)

{

  echoOPTION value='$value';

   }

 echo $value/OPTION;



}

 echo /select;

 echo /form;




 $sql=INSERT INTO table WHERE column1='.$_POST[R].'

  (column2, column3, column4)VALUES('info2', 'info3', 'info4');

 $result=mysql_query($sql);







 -
 No need to miss a message. Get email on-the-go
 with Yahoo! Mail for Mobile. Get started.





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: insert data in to columns base on the selection of the list box.

2007-04-03 Thread Carlos Proal


Can you tell us what exactly is your problem ? ie returned error, logic, 
or what ?


My first impression es that your insert is wrong, because inserts cant 
have where conditions (it makes no sense) probably you want to do a 
completely new insert including  the column1 or maybe you want an 
update. Anywhere you can check the manual for sintax issues.


Carlos


sam rumaizan wrote:

Can you help me please?


1-I have created a while loop to populate the list box with the information 
of column1.
2-I need to update (insert data) in to column2, column3, column4 base 
on the selection of the list box.
   


echo'form';

 


 $query = SELECT  column1 FROM table;

   $result = mysql_query($query);

echobr;

 


echobr;

echocenter;

 

 


echoselect NAME='R';

echooption value='NULL'Choose a Category:/option

;

   while ($line = mysql_fetch_array($result))

   {

  foreach ($line as $value)

   {

 echoOPTION value='$value';

  }

echo $value/OPTION;

 


   }

echo /select;

echo /form;

 



$sql=INSERT INTO table WHERE column1='.$_POST[R].'

 (column2, column3, column4)VALUES('info2', 'info3', 'info4');

$result=mysql_query($sql);




 

 
-
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
  



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-03-05 Thread Gerald Preston
Michael, John, ALL;

Thank you! Thanks you! My errors of local_host and if $dbh-err fix it.
I am able to insert and select data.

Thank you ALL,

Jerry

-Original Message-
From: Michael Stassen [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 04, 2005 5:41 PM
To: John Trammell
Cc: mysql@lists.mysql.com; [EMAIL PROTECTED]; Gerald Preston
Subject: Re: insert data

Right.  First, I think the logic is flawed.  We should successfully 
prepare() or die.  Period.  If the call to prepare() failed ($sth is undef),

we should not making dying conditional on yet another value.

More to the point, this line is actually the cause of the problem.  (Sorry I

didn't see it earlier.)  You've run into the precedence rules:

   my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

is read as

   (my $sth = $dbh-prepare( $sql ) or die $dbh-errstr) if $dbh-err;

That is, it is equivalent to

   if ($dbh-err)
   {
 $sth = $dbh-prepare( $sql ) or die $dbh-errstr;
   }

Since the connect succeeded, $dbh-err is undef, so we never even call 
prepare!  Hence, $sth is undef when we get to execute, and you get the error

message.  I expect this is what Joe (John Doe) was trying to tell us
earlier.

The simplest solution would be to drop the if $dbh-err.  That is, change
to

   my $sth = $dbh-prepare( $sql ) or die $dbh-errstr;

John's suggestion (below) is better still, as it adds helpful detail to the 
error message when there is one (though I don't see the need to make it a 
separate line of code).

Michael


John Trammell wrote:

 Gerald Preston wrote:
 [snip]
 
my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;
 
 [snip]
 
 Regardless of other problems you may be having, I think you're not
 doing what you want to do here.  How about instead:
 
 my $sth = $dbh-prepare($sql);
 $sth || die Error preparing sth from '$sql': , $dbh-errstr;
 

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-03-04 Thread Gerald Preston
David,

I read them and installed 4.1.10 and I am back to square one:

I used the following code:

#!/perl
use warnings;
use strict;
use DBI;
#use DBD-mysql;

  my $group_name = beer;
  my $me = E;
  my $daily  = 03032005;
  my $item   = Bacardi;
  my $unit   = 2;
  my $qty= 3;
  my $amount = 6;
  my $tax= 0.41;
  my $total  = 6.41;

  my $dbh=DBI-connect( 'dbi:mysql:club', 'gjwpp88', 'x' ) or die
\n$DBI::errstr\n;

  my $sql = insert into wolfies( group_name, me, daily, item, unit, qty,
amount, tax, total )
  values( ?,  ?,  ?, ?,?,?,   ?,
?,   ? ) ;
  my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) or warn Cannot execute FIRST Statement!!\n$DBI::errstr;

I get DBI connect'club','gjwpp88',.. failed; Client does not support
authentication protocol requested by server

I have done the following with no errors!

GRANT ALL PRIVILEGES ON club.* TO 'gjwpp88'@'local_host';

SET PASSWORD FOR 'gjwpp88'@'local_host' = PASSWORD('x');

UPDATE mysql.user SET Password = OLD_PASSWORD('x')
WHERE Host = 'local_host' AND User = 'gjwpp88';

SET PASSWORD FOR 'gjwpp88'@'local_host' = OLD_PASSWORD('x');

SELECT 'local_host', 'gjwpp88', Password FROM mysql.user
WHERE LENGTH('x')  16;

FLUSH PRIVILEGES;

I am still getting the same error I listed above.

Jerry

-Original Message-
From: Logan, David (SST - Adelaide) [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 28, 2005 6:10 PM
To: Gerald Preston; mysql@lists.mysql.com
Subject: RE: insert data

Hi Gerald,

There are some good tutorials on the web for DBI access via perl to
mysql.

http://www.wbluhm.com/MySQLTut.html
http://perl.about.com/od/installandusemysql/l/aa090803b.htm
http://dev.mysql.com/doc/mysql/en/perl.html

and also

http://search.cpan.org/~timb/DBI-1.47/DBI.pm

You should be able to find several examples of exactly what you are
trying to achieve in one of these. The first one has an almost identical
query to that you are trying to achieve. If you can't select from the
table, then you are unlikely to be able to insert. I would follow the
tutorials, even if they are selects, and make sure they work and then
all you have to do is to change the SELECT to an INSERT statement and
away you go.

These have a very thorough examination of the setting up of the dsn etc.

I would also suggest

http://dev.mysql.com/doc/mysql/en/privilege-system.html

This gives a good explanation of how the GRANT/REVOKE/privileges system
works with MySQL. It is slightly different than Oracle and would be well
worth a read.

Regards

David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 1 March 2005 10:10 AM
To: 'William R. Mussatto'; mysql@lists.mysql.com
Subject: RE: insert data

William,

I tried  GRANT ALL ON *.*  and got error  1064 4200: You have an
error
in your SQL syntax  ??

Jerry

-Original Message-
From: William R. Mussatto [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 28, 2005 3:25 PM
To: mysql@lists.mysql.com
Subject: RE: insert data

Gerald Preston said:
 Michael,

 This is the actual code except for the :

   my $dbh = DBI-connect( 'DBI:mysql:database=club', '', '', {
 PrintError = 0 } ) or die $DBI::errstr;
   my $sql = insert into wolfies( group_name, me, daily, item, unit,
 qty,
 amount, tax, total )
   values( ?,  ?,  ?, ?,?,
?,
  ?,
 ?,   ? ) ;
   my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

   $sth-execute( $group_name, $me, $daily, $item, $unit, $qty,
$amount,
 $tax, $total ) or warn Cannot execute FIRST
Statement!!\n$DBI::errstr;

 Question?  When I created the database club, is there anything I
needed
 to do concerning permissions or anything?

 I am lost here.  I have been writing code on a SUN Oracle systems for
 over five years.

 Regards,

 Jerry
Did you 'grant' user  access to all the tables in database club?

 -Original Message-
 From: Michael Stassen [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 28, 2005 9:29 AM
 To: Gerald Preston
 Cc: [EMAIL PROTECTED]; mysql@lists.mysql.com
 Subject: Re: insert data

  From perldoc DBD::mysql

use DBI;

$dsn = DBI:mysql:database=$database;host=$hostname;port=$port;

$dbh = DBI-connect($dsn, $user, $password);

 So it's not a syntax problem.  Even if it were, we should detect the
 error  long before calling prepare or execute.

 Perl is quite clearly telling you what is wrong.  Originally, you got

Can't call method prepare on an undefined value.

 for the line

my $sth = $dbh-prepare( $sql );

 which means that $dbh is undefined at the time of the call to prepare

Re: insert data

2005-03-04 Thread Roger Baklund
Gerald Preston wrote:
[...]
I get DBI connect'club','gjwpp88',.. failed; Client does not support
authentication protocol requested by server
Check this:
URL: http://dev.mysql.com/doc/mysql/en/old-client.html 
--
Roger
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


RE: insert data

2005-03-04 Thread John Trammell
Gerals Preston wrote:
[snip]
 my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;
[snip]

Regardless of other problems you may be having, I think you're not
doing what you want to do here.  How about instead:

my $sth = $dbh-prepare($sql);
$sth || die Error preparing sth from '$sql': , $dbh-errstr;

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: insert data

2005-03-04 Thread Michael Stassen
Gerald Preston wrote:
David,
I read them and installed 4.1.10 and I am back to square one:
I used the following code:
snip
  my $dbh=DBI-connect( 'dbi:mysql:club', 'gjwpp88', 'x' ) or die
\n$DBI::errstr\n;
You do not specify the host, so you are connecting to the default, which is 
localhost.  Hence, you must be able to log in as [EMAIL PROTECTED].

snip
I have done the following with no errors!
GRANT ALL PRIVILEGES ON club.* TO 'gjwpp88'@'local_host';
Here, however, you create the user [EMAIL PROTECTED].  That's not the 
same thing.  You need to use

  GRANT ALL PRIVILEGES ON club.* TO 'gjwpp88'@'localhost';
See?  No underscore.
Similarly, you need to drop the underscore (localhost, not local_host) in 
all of the following.

SET PASSWORD FOR 'gjwpp88'@'local_host' = PASSWORD('x');
UPDATE mysql.user SET Password = OLD_PASSWORD('x')
WHERE Host = 'local_host' AND User = 'gjwpp88';
SET PASSWORD FOR 'gjwpp88'@'local_host' = OLD_PASSWORD('x');
SELECT 'local_host', 'gjwpp88', Password FROM mysql.user
WHERE LENGTH('x')  16;
FLUSH PRIVILEGES;
I am still getting the same error I listed above.
Jerry
Michael
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: insert data

2005-03-04 Thread Michael Stassen
Right.  First, I think the logic is flawed.  We should successfully 
prepare() or die.  Period.  If the call to prepare() failed ($sth is undef), 
we should not making dying conditional on yet another value.

More to the point, this line is actually the cause of the problem.  (Sorry I 
didn't see it earlier.)  You've run into the precedence rules:

  my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;
is read as
  (my $sth = $dbh-prepare( $sql ) or die $dbh-errstr) if $dbh-err;
That is, it is equivalent to
  if ($dbh-err)
  {
$sth = $dbh-prepare( $sql ) or die $dbh-errstr;
  }
Since the connect succeeded, $dbh-err is undef, so we never even call 
prepare!  Hence, $sth is undef when we get to execute, and you get the error 
message.  I expect this is what Joe (John Doe) was trying to tell us earlier.

The simplest solution would be to drop the if $dbh-err.  That is, change to
  my $sth = $dbh-prepare( $sql ) or die $dbh-errstr;
John's suggestion (below) is better still, as it adds helpful detail to the 
error message when there is one (though I don't see the need to make it a 
separate line of code).

Michael
John Trammell wrote:
Gerald Preston wrote:
[snip]
my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;
[snip]
Regardless of other problems you may be having, I think you're not
doing what you want to do here.  How about instead:
my $sth = $dbh-prepare($sql);
$sth || die Error preparing sth from '$sql': , $dbh-errstr;
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: insert data

2005-02-28 Thread Michael Stassen
I sent this earlier, but it doesn't seem to have gone through.  Apologies to 
anyone who gets it twice.

=
From perldoc DBD::mysql
  use DBI;
  $dsn = DBI:mysql:database=$database;host=$hostname;port=$port;
  $dbh = DBI-connect($dsn, $user, $password);
So it's not a syntax problem.  Even if it were, we should detect the error 
long before calling prepare or execute.

Perl is quite clearly telling you what is wrong.  Originally, you got
  Can't call method prepare on an undefined value.
for the line
  my $sth = $dbh-prepare( $sql );
which means that $dbh is undefined at the time of the call to prepare.
Now, you are getting
  Can't call method execute on an un undefined value
for the line
  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) or warn Cannot execute FIRST Statement!!\n$DBI::errstr;
which means that $sth is undefined at the time of the call to execute.
Are you showing us select lines of your code, rather than the actual code? 
My best guess right now is that you haven't taken into account that my is 
a scoping operator in perl, and in the lines you haven't showed us, the 
variables in question ($dbh or $sth) go out of scope.

Michael
John Doe wrote:
Am Sonntag, 27. Februar 2005 22.19 schrieb Gerald Preston:
Hi Gerald

The object used:
 my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;

I didn't see this part in your first post :-)
Hmm... I've never seen a '=' in the first argument passed to DBI-connect...
Here's an functional example I'm using:
my $db ='database';
my $host ='hostname';
my $port ='1234';
$dbh=DBI-connect(DBI:mysql:$db:$host:$port,
 'a_username',
 'a_password',
 {RaiseError=1,   
 AutoCommit=1}) 
or die $0: $DBI::errstr; }

So, try using club instead of database=club, and a hostname too.
greetings joe
[nothing new below]

-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data
Hi Gerald

I am trying to insert data for the first time using MySQL.  In Oracle I
used the following:
#  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount, tax, total )
#  values( ?,  ?,  ?, ?,?,?,   ?,
?,   ? ) ;
 my $sth = $dbh-prepare( $sql );
 die $dbh-errstr if $dbh-err;
 $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;
I keep getting Can't call method prepare on an un undefined value. 
All the name listed are correct by looking at MySQLAdmin1.3\4.
Apart from David Logan's answer:
You have to create the $dbh object first (man DBI); the undefined value
in the error message refers to that.
HTH
joe

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: insert data

2005-02-28 Thread Michael Stassen
From perldoc DBD::mysql
  use DBI;
  $dsn = DBI:mysql:database=$database;host=$hostname;port=$port;
  $dbh = DBI-connect($dsn, $user, $password);
So it's not a syntax problem.  Even if it were, we should detect the error 
long before calling prepare or execute.

Perl is quite clearly telling you what is wrong.  Originally, you got
  Can't call method prepare on an undefined value.
for the line
  my $sth = $dbh-prepare( $sql );
which means that $dbh is undefined at the time of the call to prepare.
Now, you are getting
  Can't call method execute on an un undefined value
for the line
  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) or warn Cannot execute FIRST Statement!!\n$DBI::errstr;
which means that $sth is undefined at the time of the call to execute.
Are you showing us select lines of your code, rather than the actual code? 
My best guess right now is that you haven't taken into account that my is 
a scoping operator in perl, and in the lines you haven't showed us, the 
variables in question ($dbh or $sth) go out of scope.

Michael
John Doe wrote:
Am Sonntag, 27. Februar 2005 22.19 schrieb Gerald Preston:
Hi Gerald

The object used:
 my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;

I didn't see this part in your first post :-)
Hmm... I've never seen a '=' in the first argument passed to DBI-connect...
Here's an functional example I'm using:
my $db ='database';
my $host ='hostname';
my $port ='1234';
$dbh=DBI-connect(DBI:mysql:$db:$host:$port,
 'a_username',
 'a_password',
 {RaiseError=1,   
 AutoCommit=1}) 
or die $0: $DBI::errstr; }

So, try using club instead of database=club, and a hostname too.
greetings joe
[nothing new below]

-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data
Hi Gerald

I am trying to insert data for the first time using MySQL.  In Oracle I
used the following:
#  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount, tax, total )
#  values( ?,  ?,  ?, ?,?,?,   ?,
?,   ? ) ;
 my $sth = $dbh-prepare( $sql );
 die $dbh-errstr if $dbh-err;
 $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;
I keep getting Can't call method prepare on an un undefined value. 
All the name listed are correct by looking at MySQLAdmin1.3\4.
Apart from David Logan's answer:
You have to create the $dbh object first (man DBI); the undefined value
in
the error message refers to that.
HTH
joe
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


RE: insert data

2005-02-28 Thread Gerald Preston
Michael,

This is the actual code except for the :

  my $dbh = DBI-connect( 'DBI:mysql:database=club', '', '', {
PrintError = 0 } ) or die $DBI::errstr;
  my $sql = insert into wolfies( group_name, me, daily, item, unit, qty,
amount, tax, total )
  values( ?,  ?,  ?, ?,?,?,   ?,
?,   ? ) ;
  my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) or warn Cannot execute FIRST Statement!!\n$DBI::errstr;

Question?  When I created the database club, is there anything I needed to
do concerning permissions or anything?

I am lost here.  I have been writing code on a SUN Oracle systems for over
five years.

Regards,

Jerry


-Original Message-
From: Michael Stassen [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 28, 2005 9:29 AM
To: Gerald Preston
Cc: [EMAIL PROTECTED]; mysql@lists.mysql.com
Subject: Re: insert data

 From perldoc DBD::mysql

   use DBI;

   $dsn = DBI:mysql:database=$database;host=$hostname;port=$port;

   $dbh = DBI-connect($dsn, $user, $password);

So it's not a syntax problem.  Even if it were, we should detect the error 
long before calling prepare or execute.

Perl is quite clearly telling you what is wrong.  Originally, you got

   Can't call method prepare on an undefined value.

for the line

   my $sth = $dbh-prepare( $sql );

which means that $dbh is undefined at the time of the call to prepare.

Now, you are getting

   Can't call method execute on an un undefined value

for the line

   $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
 $tax, $total ) or warn Cannot execute FIRST
Statement!!\n$DBI::errstr;

which means that $sth is undefined at the time of the call to execute.

Are you showing us select lines of your code, rather than the actual code? 
My best guess right now is that you haven't taken into account that my is 
a scoping operator in perl, and in the lines you haven't showed us, the 
variables in question ($dbh or $sth) go out of scope.

Michael

John Doe wrote:
 Am Sonntag, 27. Februar 2005 22.19 schrieb Gerald Preston:
 
 Hi Gerald
 
 
The object used:

  my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;
 
 
 I didn't see this part in your first post :-)
 
 Hmm... I've never seen a '=' in the first argument passed to
DBI-connect...
 
 Here's an functional example I'm using:
 
 my $db ='database';
 my $host ='hostname';
 my $port ='1234';
 $dbh=DBI-connect(DBI:mysql:$db:$host:$port,
  'a_username',
  'a_password',
  {RaiseError=1,   
  AutoCommit=1}) 
 or die $0: $DBI::errstr; }
 
 
 So, try using club instead of database=club, and a hostname too.
 
 greetings joe
 
 
 [nothing new below]
 
 
-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data

Hi Gerald


I am trying to insert data for the first time using MySQL.  In Oracle I
used the following:

#  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount, tax, total )

#  values( ?,  ?,  ?, ?,?,?,   ?,
?,   ? ) ;
  my $sth = $dbh-prepare( $sql );
  die $dbh-errstr if $dbh-err;
  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;


I keep getting Can't call method prepare on an un undefined value. 
All the name listed are correct by looking at MySQLAdmin1.3\4.

Apart from David Logan's answer:

You have to create the $dbh object first (man DBI); the undefined value
in

the error message refers to that.


HTH

joe

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-28 Thread William R. Mussatto
Gerald Preston said:
 Michael,

 This is the actual code except for the :

   my $dbh = DBI-connect( 'DBI:mysql:database=club', '', '', {
 PrintError = 0 } ) or die $DBI::errstr;
   my $sql = insert into wolfies( group_name, me, daily, item, unit,
 qty,
 amount, tax, total )
   values( ?,  ?,  ?, ?,?,?,
  ?,
 ?,   ? ) ;
   my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

   $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
 $tax, $total ) or warn Cannot execute FIRST Statement!!\n$DBI::errstr;

 Question?  When I created the database club, is there anything I needed
 to do concerning permissions or anything?

 I am lost here.  I have been writing code on a SUN Oracle systems for
 over five years.

 Regards,

 Jerry
Did you 'grant' user  access to all the tables in database club?

 -Original Message-
 From: Michael Stassen [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 28, 2005 9:29 AM
 To: Gerald Preston
 Cc: [EMAIL PROTECTED]; mysql@lists.mysql.com
 Subject: Re: insert data

  From perldoc DBD::mysql

use DBI;

$dsn = DBI:mysql:database=$database;host=$hostname;port=$port;

$dbh = DBI-connect($dsn, $user, $password);

 So it's not a syntax problem.  Even if it were, we should detect the
 error  long before calling prepare or execute.

 Perl is quite clearly telling you what is wrong.  Originally, you got

Can't call method prepare on an undefined value.

 for the line

my $sth = $dbh-prepare( $sql );

 which means that $dbh is undefined at the time of the call to prepare.

 Now, you are getting

Can't call method execute on an un undefined value

 for the line

$sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
  $tax, $total ) or warn Cannot execute FIRST
 Statement!!\n$DBI::errstr;

 which means that $sth is undefined at the time of the call to execute.

 Are you showing us select lines of your code, rather than the actual
 code?  My best guess right now is that you haven't taken into account
 that my is  a scoping operator in perl, and in the lines you haven't
 showed us, the  variables in question ($dbh or $sth) go out of scope.

 Michael

 John Doe wrote:
 Am Sonntag, 27. Februar 2005 22.19 schrieb Gerald Preston:

 Hi Gerald


The object used:

  my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;


 I didn't see this part in your first post :-)

 Hmm... I've never seen a '=' in the first argument passed to
 DBI-connect...

 Here's an functional example I'm using:

 my $db ='database';
 my $host ='hostname';
 my $port ='1234';
 $dbh=DBI-connect(DBI:mysql:$db:$host:$port,
  'a_username',
  'a_password',
  {RaiseError=1,
  AutoCommit=1})
 or die $0: $DBI::errstr; }


 So, try using club instead of database=club, and a hostname too.

 greetings joe


 [nothing new below]


-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data

Hi Gerald


I am trying to insert data for the first time using MySQL.  In Oracle
 I used the following:

#  my $sql = insert into bar( group_name, me, daily, item, unit,
 qty, amount, tax, total )

#  values( ?,  ?,  ?, ?,?,?,
  ?, ?,   ? ) ;
  my $sth = $dbh-prepare( $sql );
  die $dbh-errstr if $dbh-err;
  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty,
 $amount,
$tax, $total ) || die Cannot execute FIRST
 Statement!!\n$DBI::errstr;


I keep getting Can't call method prepare on an un undefined value.
  All the name listed are correct by looking at MySQLAdmin1.3\4.

Apart from David Logan's answer:

You have to create the $dbh object first (man DBI); the undefined
 value in

the error message refers to that.


HTH

joe



-- 
William R. Mussatto, Senior Systems Engineer
Ph. 909-920-9154 ext. 27
FAX. 909-608-7061



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: insert data

2005-02-28 Thread Eamon Daly
Are you sure that the parameters in the execute are all
properly defined? Try this:
my $dbh = DBI-connect( 'DBI:mysql:database=club', '', '', { 
PrintError = 0 } ) or die $DBI::errstr;

my $sql = insert into bar( group_name, me, daily, item, unit, qty, amount, 
tax, total )
  values( ?,  ?,  ?, ?,?,?,   ?,  ?,   ? ) 
;

my $sth = $dbh-prepare($sql) or die $dbh-errstr;
# If not defined, set to '' to avoid warnings.
for ($group_name, $me, $daily, $item, $unit, $qty, $amount, $tax, $total) {
 $_ ||= '' if ! defined $_;
}
$sth-execute($group_name, $me, $daily, $item, $unit, $qty, $amount, $tax, 
$total) or warn Cannot execute FIRST Statement!!\n$DBI::errstr;

If this succeeds, review your code and make sure that each
of your execute parameters have some value prior to the
execute.

Eamon Daly

- Original Message - 
From: Gerald Preston [EMAIL PROTECTED]
To: 'Michael Stassen' [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; mysql@lists.mysql.com
Sent: Monday, February 28, 2005 3:19 PM
Subject: RE: insert data


Michael,
This is the actual code except for the :
 my $dbh = DBI-connect( 'DBI:mysql:database=club', '', '', {
PrintError = 0 } ) or die $DBI::errstr;
 my $sql = insert into wolfies( group_name, me, daily, item, unit, qty,
amount, tax, total )
 values( ?,  ?,  ?, ?,?,?, 
?,
?,   ? ) ;
 my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

 $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) or warn Cannot execute FIRST Statement!!\n$DBI::errstr;
Question?  When I created the database club, is there anything I needed to
do concerning permissions or anything?
I am lost here.  I have been writing code on a SUN Oracle systems for over
five years.
Regards,
Jerry
-Original Message-
From: Michael Stassen [mailto:[EMAIL PROTECTED]
Sent: Monday, February 28, 2005 9:29 AM
To: Gerald Preston
Cc: [EMAIL PROTECTED]; mysql@lists.mysql.com
Subject: Re: insert data
From perldoc DBD::mysql
  use DBI;
  $dsn = DBI:mysql:database=$database;host=$hostname;port=$port;
  $dbh = DBI-connect($dsn, $user, $password);
So it's not a syntax problem.  Even if it were, we should detect the error
long before calling prepare or execute.
Perl is quite clearly telling you what is wrong.  Originally, you got
  Can't call method prepare on an undefined value.
for the line
  my $sth = $dbh-prepare( $sql );
which means that $dbh is undefined at the time of the call to prepare.
Now, you are getting
  Can't call method execute on an un undefined value
for the line
  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) or warn Cannot execute FIRST
Statement!!\n$DBI::errstr;
which means that $sth is undefined at the time of the call to execute.
Are you showing us select lines of your code, rather than the actual code?
My best guess right now is that you haven't taken into account that my 
is
a scoping operator in perl, and in the lines you haven't showed us, the
variables in question ($dbh or $sth) go out of scope.

Michael
John Doe wrote:
Am Sonntag, 27. Februar 2005 22.19 schrieb Gerald Preston:
Hi Gerald

The object used:
 my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;

I didn't see this part in your first post :-)
Hmm... I've never seen a '=' in the first argument passed to
DBI-connect...
Here's an functional example I'm using:
my $db ='database';
my $host ='hostname';
my $port ='1234';
$dbh=DBI-connect(DBI:mysql:$db:$host:$port,
 'a_username',
 'a_password',
 {RaiseError=1,
 AutoCommit=1})
or die $0: $DBI::errstr; }
So, try using club instead of database=club, and a hostname too.
greetings joe
[nothing new below]

-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data
Hi Gerald

I am trying to insert data for the first time using MySQL.  In Oracle I
used the following:
#  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount, tax, total )
#  values( ?,  ?,  ?, ?,?,?, 
?,
?,   ? ) ;
 my $sth = $dbh-prepare( $sql );
 die $dbh-errstr if $dbh-err;
 $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;

I keep getting Can't call method prepare on an un undefined value.
All the name listed are correct by looking at MySQLAdmin1.3\4.
Apart from David Logan's answer:
You have to create the $dbh object first (man DBI); the undefined value
in
the error message refers to that.
HTH
joe
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http

RE: insert data

2005-02-28 Thread Gerald Preston
William,

I tried  GRANT ALL ON *.*  and got error  1064 4200: You have an error
in your SQL syntax  ??

Jerry

-Original Message-
From: William R. Mussatto [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 28, 2005 3:25 PM
To: mysql@lists.mysql.com
Subject: RE: insert data

Gerald Preston said:
 Michael,

 This is the actual code except for the :

   my $dbh = DBI-connect( 'DBI:mysql:database=club', '', '', {
 PrintError = 0 } ) or die $DBI::errstr;
   my $sql = insert into wolfies( group_name, me, daily, item, unit,
 qty,
 amount, tax, total )
   values( ?,  ?,  ?, ?,?,?,
  ?,
 ?,   ? ) ;
   my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

   $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
 $tax, $total ) or warn Cannot execute FIRST Statement!!\n$DBI::errstr;

 Question?  When I created the database club, is there anything I needed
 to do concerning permissions or anything?

 I am lost here.  I have been writing code on a SUN Oracle systems for
 over five years.

 Regards,

 Jerry
Did you 'grant' user  access to all the tables in database club?

 -Original Message-
 From: Michael Stassen [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 28, 2005 9:29 AM
 To: Gerald Preston
 Cc: [EMAIL PROTECTED]; mysql@lists.mysql.com
 Subject: Re: insert data

  From perldoc DBD::mysql

use DBI;

$dsn = DBI:mysql:database=$database;host=$hostname;port=$port;

$dbh = DBI-connect($dsn, $user, $password);

 So it's not a syntax problem.  Even if it were, we should detect the
 error  long before calling prepare or execute.

 Perl is quite clearly telling you what is wrong.  Originally, you got

Can't call method prepare on an undefined value.

 for the line

my $sth = $dbh-prepare( $sql );

 which means that $dbh is undefined at the time of the call to prepare.

 Now, you are getting

Can't call method execute on an un undefined value

 for the line

$sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
  $tax, $total ) or warn Cannot execute FIRST
 Statement!!\n$DBI::errstr;

 which means that $sth is undefined at the time of the call to execute.

 Are you showing us select lines of your code, rather than the actual
 code?  My best guess right now is that you haven't taken into account
 that my is  a scoping operator in perl, and in the lines you haven't
 showed us, the  variables in question ($dbh or $sth) go out of scope.

 Michael

 John Doe wrote:
 Am Sonntag, 27. Februar 2005 22.19 schrieb Gerald Preston:

 Hi Gerald


The object used:

  my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;


 I didn't see this part in your first post :-)

 Hmm... I've never seen a '=' in the first argument passed to
 DBI-connect...

 Here's an functional example I'm using:

 my $db ='database';
 my $host ='hostname';
 my $port ='1234';
 $dbh=DBI-connect(DBI:mysql:$db:$host:$port,
  'a_username',
  'a_password',
  {RaiseError=1,
  AutoCommit=1})
 or die $0: $DBI::errstr; }


 So, try using club instead of database=club, and a hostname too.

 greetings joe


 [nothing new below]


-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data

Hi Gerald


I am trying to insert data for the first time using MySQL.  In Oracle
 I used the following:

#  my $sql = insert into bar( group_name, me, daily, item, unit,
 qty, amount, tax, total )

#  values( ?,  ?,  ?, ?,?,?,
  ?, ?,   ? ) ;
  my $sth = $dbh-prepare( $sql );
  die $dbh-errstr if $dbh-err;
  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty,
 $amount,
$tax, $total ) || die Cannot execute FIRST
 Statement!!\n$DBI::errstr;


I keep getting Can't call method prepare on an un undefined value.
  All the name listed are correct by looking at MySQLAdmin1.3\4.

Apart from David Logan's answer:

You have to create the $dbh object first (man DBI); the undefined
 value in

the error message refers to that.


HTH

joe



-- 
William R. Mussatto, Senior Systems Engineer
Ph. 909-920-9154 ext. 27
FAX. 909-608-7061



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: insert data

2005-02-28 Thread John Doe
Hi Gerald

my last try... i'm not very lucky in helping in this list...

 This is the actual code except for the :

  [...]
   my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

Maybe this expression is the reason (combination of 'or' and 'if').

Example code:
===
my $no_error=0; # the wanted case :-)

my $a=i_am_defined or die i died! if $no_error;

print defined $a ? defined : not defined;
===
# this prints:

not defined

===

I think the expression 
my $a=i_am_defined or die i died!
is only evaluated if 
$dbh-err is false. 

I think you could just write:

my $sth = $dbh-prepare( $sql ) or die $dbh-errstr;

(omitting if $dbh-err)

[...]

greetings joe

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-28 Thread Logan, David (SST - Adelaide)
Hi Gerald,

There are some good tutorials on the web for DBI access via perl to
mysql.

http://www.wbluhm.com/MySQLTut.html
http://perl.about.com/od/installandusemysql/l/aa090803b.htm
http://dev.mysql.com/doc/mysql/en/perl.html

and also

http://search.cpan.org/~timb/DBI-1.47/DBI.pm

You should be able to find several examples of exactly what you are
trying to achieve in one of these. The first one has an almost identical
query to that you are trying to achieve. If you can't select from the
table, then you are unlikely to be able to insert. I would follow the
tutorials, even if they are selects, and make sure they work and then
all you have to do is to change the SELECT to an INSERT statement and
away you go.

These have a very thorough examination of the setting up of the dsn etc.

I would also suggest

http://dev.mysql.com/doc/mysql/en/privilege-system.html

This gives a good explanation of how the GRANT/REVOKE/privileges system
works with MySQL. It is slightly different than Oracle and would be well
worth a read.

Regards

David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 1 March 2005 10:10 AM
To: 'William R. Mussatto'; mysql@lists.mysql.com
Subject: RE: insert data

William,

I tried  GRANT ALL ON *.*  and got error  1064 4200: You have an
error
in your SQL syntax  ??

Jerry

-Original Message-
From: William R. Mussatto [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 28, 2005 3:25 PM
To: mysql@lists.mysql.com
Subject: RE: insert data

Gerald Preston said:
 Michael,

 This is the actual code except for the :

   my $dbh = DBI-connect( 'DBI:mysql:database=club', '', '', {
 PrintError = 0 } ) or die $DBI::errstr;
   my $sql = insert into wolfies( group_name, me, daily, item, unit,
 qty,
 amount, tax, total )
   values( ?,  ?,  ?, ?,?,
?,
  ?,
 ?,   ? ) ;
   my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

   $sth-execute( $group_name, $me, $daily, $item, $unit, $qty,
$amount,
 $tax, $total ) or warn Cannot execute FIRST
Statement!!\n$DBI::errstr;

 Question?  When I created the database club, is there anything I
needed
 to do concerning permissions or anything?

 I am lost here.  I have been writing code on a SUN Oracle systems for
 over five years.

 Regards,

 Jerry
Did you 'grant' user  access to all the tables in database club?

 -Original Message-
 From: Michael Stassen [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 28, 2005 9:29 AM
 To: Gerald Preston
 Cc: [EMAIL PROTECTED]; mysql@lists.mysql.com
 Subject: Re: insert data

  From perldoc DBD::mysql

use DBI;

$dsn = DBI:mysql:database=$database;host=$hostname;port=$port;

$dbh = DBI-connect($dsn, $user, $password);

 So it's not a syntax problem.  Even if it were, we should detect the
 error  long before calling prepare or execute.

 Perl is quite clearly telling you what is wrong.  Originally, you got

Can't call method prepare on an undefined value.

 for the line

my $sth = $dbh-prepare( $sql );

 which means that $dbh is undefined at the time of the call to prepare.

 Now, you are getting

Can't call method execute on an un undefined value

 for the line

$sth-execute( $group_name, $me, $daily, $item, $unit, $qty,
$amount,
  $tax, $total ) or warn Cannot execute FIRST
 Statement!!\n$DBI::errstr;

 which means that $sth is undefined at the time of the call to execute.

 Are you showing us select lines of your code, rather than the actual
 code?  My best guess right now is that you haven't taken into account
 that my is  a scoping operator in perl, and in the lines you haven't
 showed us, the  variables in question ($dbh or $sth) go out of scope.

 Michael

 John Doe wrote:
 Am Sonntag, 27. Februar 2005 22.19 schrieb Gerald Preston:

 Hi Gerald


The object used:

  my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;


 I didn't see this part in your first post :-)

 Hmm... I've never seen a '=' in the first argument passed to
 DBI-connect...

 Here's an functional example I'm using:

 my $db ='database';
 my $host ='hostname';
 my $port ='1234';
 $dbh=DBI-connect(DBI:mysql:$db:$host:$port,
  'a_username',
  'a_password',
  {RaiseError=1,
  AutoCommit=1})
 or die $0: $DBI::errstr; }


 So, try using club instead of database=club, and a hostname too.

 greetings joe


 [nothing new below]


-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data

Hi Gerald


I am trying to insert data for the first time using MySQL.  In
Oracle
 I used the following:

#  my $sql = insert into bar( group_name, me, daily, item, unit,
 qty, amount, tax, total

RE: insert data

2005-02-27 Thread Logan, David (SST - Adelaide)
Hi Gerald,

If  this is copied out of your perl code then you haven't put anything
into the $sql variable. Try uncommenting the 2 lines above.

Regards 


David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Sunday, 27 February 2005 9:33 PM
To: mysql users
Subject: insert data 

Hi!

 

I am trying to insert data for the first time using MySQL.  In Oracle I
used
the following:

 

#  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount, tax, total )

#  values( ?,  ?,  ?, ?,?,?,
?,
?,   ? ) ;

  my $sth = $dbh-prepare( $sql );

  die $dbh-errstr if $dbh-err;

 

  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;

 

I keep getting Can't call method prepare on an un undefined value.
All
the name listed are correct by looking at MySQLAdmin1.3\4.

 

Any ideas?

 

Thanks,

 

Jerry


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-27 Thread Gerald Preston
David,

The actual code is uncommented:

my $sql = insert into bar( group_name, me, daily, item, unit, qty, amount,
tax, total )
values( ?,  ?,  ?, ?,?,?,   ?,  ?,   ? ) ;

Sorry, 
Jerry

-Original Message-
From: Logan, David (SST - Adelaide) [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 5:09 AM
To: Gerald Preston; mysql users
Subject: RE: insert data 

Hi Gerald,

If  this is copied out of your perl code then you haven't put anything
into the $sql variable. Try uncommenting the 2 lines above.

Regards 


David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Sunday, 27 February 2005 9:33 PM
To: mysql users
Subject: insert data 

Hi!

 

I am trying to insert data for the first time using MySQL.  In Oracle I
used
the following:

 

#  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount, tax, total )

#  values( ?,  ?,  ?, ?,?,?,
?,
?,   ? ) ;

  my $sth = $dbh-prepare( $sql );

  die $dbh-errstr if $dbh-err;

 

  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;

 

I keep getting Can't call method prepare on an un undefined value.
All
the name listed are correct by looking at MySQLAdmin1.3\4.

 

Any ideas?

 

Thanks,

 

Jerry


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]






-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-27 Thread Gerald Preston
I just created a new table with the following:

CREATE TABLE `wolfies` (
`group_name` VARCHAR( 38 ) NOT NULL,
`me` VARCHAR(  3 ) NOT NULL,
`daily`  VARCHAR(  8 ) NOT NULL,
`item`   VARCHAR( 60 ) NOT NULL,
`unit`   VARCHAR( 38 ) NOT NULL,
`qty`int   NOT NULL,
`amount` decimal(8,2) NOT NULL,
`tax`decimal(8,2) NOT NULL,
`total`  decimal(8,2) NOT NULL
);

And get the same Can't call method prepare on an un undefined value.
All the name listed are correct by looking at MySQLAdmin1.4.

my $sql = insert into wolfies ( group_name, me, daily, item, unit, qty,
amount,
tax, total )
values( ?,  ?,  ?, ?,?,?,   ?,  ?,   ? ) ;
  my $sth = $dbh-prepare( $sql );

  die $dbh-errstr if $dbh-err;

What am I ding wrong?

Thanks,

Jerry

---Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 5:13 AM
To: 'Logan, David (SST - Adelaide)'; 'mysql users'
Subject: RE: insert data 

David,

The actual code is uncommented:

my $sql = insert into bar( group_name, me, daily, item, unit, qty, amount,
tax, total )
values( ?,  ?,  ?, ?,?,?,   ?,  ?,   ? ) ;

Sorry, 
Jerry

-Original Message-
From: Logan, David (SST - Adelaide) [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 5:09 AM
To: Gerald Preston; mysql users
Subject: RE: insert data 

Hi Gerald,

If  this is copied out of your perl code then you haven't put anything
into the $sql variable. Try uncommenting the 2 lines above.

Regards 


David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Sunday, 27 February 2005 9:33 PM
To: mysql users
Subject: insert data 

Hi!

 

I am trying to insert data for the first time using MySQL.  In Oracle I
used
the following:

 

#  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount, tax, total )

#  values( ?,  ?,  ?, ?,?,?,
?,
?,   ? ) ;

  my $sth = $dbh-prepare( $sql );

  die $dbh-errstr if $dbh-err;

 

  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;

 

I keep getting Can't call method prepare on an un undefined value.
All
the name listed are correct by looking at MySQLAdmin1.3\4.

 

Any ideas?

 

Thanks,

 

Jerry


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]






-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-27 Thread Logan, David (SST - Adelaide)
Hi Gerald,

Try something like

my $sth = $dbh-prepare(insert into
bar(group_name,me,daily,item,unit,qty,amount,tax,total)
values(?,?,?,?,?,?,?,?,?));
$sth-execute($group_name,$me,$daily,$item,$unit,$qty,$amount,$tax,$tota
l) 
  || die Cannot execute FIRST Statement!!\n$DBI::errstr;

That is exactly the same format as I have running in a number of
scripts. You can check out the documentation at
http://search.cpan.org/~timb/DBI-1.47/DBI.pm

This has tons of info on how to use the various methods/properties that
are available with the DBI interface. I also use an O'Reilly book
Programming the DBI Interface (I don't have it here so can't refer to
the author, I think it is Tim Bunce)

If you still have a problem, check your column names etc. to ensure they
are correct. I'll have another check tomorrow when I get to work

Regards

David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Sunday, 27 February 2005 9:43 PM
To: Logan, David (SST - Adelaide); 'mysql users'
Subject: RE: insert data 

David,

The actual code is uncommented:

my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount,
tax, total )
values( ?,  ?,  ?, ?,?,?,   ?,  ?,   ? )
;

Sorry, 
Jerry

-Original Message-
From: Logan, David (SST - Adelaide) [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 5:09 AM
To: Gerald Preston; mysql users
Subject: RE: insert data 

Hi Gerald,

If  this is copied out of your perl code then you haven't put anything
into the $sql variable. Try uncommenting the 2 lines above.

Regards 


David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Sunday, 27 February 2005 9:33 PM
To: mysql users
Subject: insert data 

Hi!

 

I am trying to insert data for the first time using MySQL.  In Oracle I
used
the following:

 

#  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount, tax, total )

#  values( ?,  ?,  ?, ?,?,?,
?,
?,   ? ) ;

  my $sth = $dbh-prepare( $sql );

  die $dbh-errstr if $dbh-err;

 

  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;

 

I keep getting Can't call method prepare on an un undefined value.
All
the name listed are correct by looking at MySQLAdmin1.3\4.

 

Any ideas?

 

Thanks,

 

Jerry


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]






--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-27 Thread Gerald Preston
David,

Still the same error!.

Jerry

-Original Message-
From: Logan, David (SST - Adelaide) [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 5:49 AM
To: Gerald Preston; mysql users
Subject: RE: insert data 

Hi Gerald,

Try something like

my $sth = $dbh-prepare(insert into
bar(group_name,me,daily,item,unit,qty,amount,tax,total)
values(?,?,?,?,?,?,?,?,?));
$sth-execute($group_name,$me,$daily,$item,$unit,$qty,$amount,$tax,$tota
l) 
  || die Cannot execute FIRST Statement!!\n$DBI::errstr;

That is exactly the same format as I have running in a number of
scripts. You can check out the documentation at
http://search.cpan.org/~timb/DBI-1.47/DBI.pm

This has tons of info on how to use the various methods/properties that
are available with the DBI interface. I also use an O'Reilly book
Programming the DBI Interface (I don't have it here so can't refer to
the author, I think it is Tim Bunce)

If you still have a problem, check your column names etc. to ensure they
are correct. I'll have another check tomorrow when I get to work

Regards

David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Sunday, 27 February 2005 9:43 PM
To: Logan, David (SST - Adelaide); 'mysql users'
Subject: RE: insert data 

David,

The actual code is uncommented:

my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount,
tax, total )
values( ?,  ?,  ?, ?,?,?,   ?,  ?,   ? )
;

Sorry, 
Jerry

-Original Message-
From: Logan, David (SST - Adelaide) [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 5:09 AM
To: Gerald Preston; mysql users
Subject: RE: insert data 

Hi Gerald,

If  this is copied out of your perl code then you haven't put anything
into the $sql variable. Try uncommenting the 2 lines above.

Regards 


David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Sunday, 27 February 2005 9:33 PM
To: mysql users
Subject: insert data 

Hi!

 

I am trying to insert data for the first time using MySQL.  In Oracle I
used
the following:

 

#  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount, tax, total )

#  values( ?,  ?,  ?, ?,?,?,
?,
?,   ? ) ;

  my $sth = $dbh-prepare( $sql );

  die $dbh-errstr if $dbh-err;

 

  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;

 

I keep getting Can't call method prepare on an un undefined value.
All
the name listed are correct by looking at MySQLAdmin1.3\4.

 

Any ideas?

 

Thanks,

 

Jerry


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]






-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]






-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: insert data

2005-02-27 Thread John Doe
Hi Gerald

 I am trying to insert data for the first time using MySQL.  In Oracle I
 used the following:

 #  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
 amount, tax, total )

 #  values( ?,  ?,  ?, ?,?,?,   ?,
 ?,   ? ) ;
   my $sth = $dbh-prepare( $sql );
   die $dbh-errstr if $dbh-err;
   $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
 $tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;


 I keep getting Can't call method prepare on an un undefined value.  All
 the name listed are correct by looking at MySQLAdmin1.3\4.

Apart from David Logan's answer:

You have to create the $dbh object first (man DBI); the undefined value in 
the error message refers to that.


HTH

joe

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-27 Thread Gerald Preston
The object used:

  my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;

Jerry

-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data

Hi Gerald

 I am trying to insert data for the first time using MySQL.  In Oracle I
 used the following:

 #  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
 amount, tax, total )

 #  values( ?,  ?,  ?, ?,?,?,   ?,
 ?,   ? ) ;
   my $sth = $dbh-prepare( $sql );
   die $dbh-errstr if $dbh-err;
   $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
 $tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;


 I keep getting Can't call method prepare on an un undefined value.  All
 the name listed are correct by looking at MySQLAdmin1.3\4.

Apart from David Logan's answer:

You have to create the $dbh object first (man DBI); the undefined value in

the error message refers to that.


HTH

joe

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-27 Thread Logan, David (SST - Adelaide)
Hi Gerald,

The only thing I can think of is that you have a syntax error in your
SQL that hasn't showed up in translation to email. Are you able to
select from the database prior to the INSERT? This would confirm that
your db has made a successful connection.

The placeholders etc. work exactly as they do in the oracle version of
the DBI.

Regards

David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Monday, 28 February 2005 7:49 AM
To: [EMAIL PROTECTED]; mysql@lists.mysql.com
Subject: RE: insert data

The object used:

  my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;

Jerry

-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data

Hi Gerald

 I am trying to insert data for the first time using MySQL.  In Oracle
I
 used the following:

 #  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
 amount, tax, total )

 #  values( ?,  ?,  ?, ?,?,?,
?,
 ?,   ? ) ;
   my $sth = $dbh-prepare( $sql );
   die $dbh-errstr if $dbh-err;
   $sth-execute( $group_name, $me, $daily, $item, $unit, $qty,
$amount,
 $tax, $total ) || die Cannot execute FIRST
Statement!!\n$DBI::errstr;


 I keep getting Can't call method prepare on an un undefined value.
All
 the name listed are correct by looking at MySQLAdmin1.3\4.

Apart from David Logan's answer:

You have to create the $dbh object first (man DBI); the undefined
value in

the error message refers to that.


HTH

joe

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-27 Thread Gerald Preston
David,

I just cannot believe what a pain this is.  I got past the prepare with no
errors by doing the following:

  my $dbh = DBI-connect( 'DBI:mysql:database=club', 'xxx', 'xxx', {
PrintError = 0 } ) or die $DBI::errstr;
  my $sql = insert into wolfies( group_name, me, daily, item, unit, qty,
amount, tax, total )
  values( ?,  ?,  ?, ?,?,?,   ?,
?,   ? ) ;
  my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) or warn Cannot execute FIRST Statement!!\n$DBI::errstr;

I just do not believe this, but I get the same error (almost ):

Can't call method execute on an un undefined value

Jerry

-Original Message-
From: Logan, David (SST - Adelaide) [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 3:27 PM
To: Gerald Preston; mysql@lists.mysql.com
Subject: RE: insert data

Hi Gerald,

The only thing I can think of is that you have a syntax error in your
SQL that hasn't showed up in translation to email. Are you able to
select from the database prior to the INSERT? This would confirm that
your db has made a successful connection.

The placeholders etc. work exactly as they do in the oracle version of
the DBI.

Regards

David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Monday, 28 February 2005 7:49 AM
To: [EMAIL PROTECTED]; mysql@lists.mysql.com
Subject: RE: insert data

The object used:

  my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;

Jerry

-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data

Hi Gerald

 I am trying to insert data for the first time using MySQL.  In Oracle
I
 used the following:

 #  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
 amount, tax, total )

 #  values( ?,  ?,  ?, ?,?,?,
?,
 ?,   ? ) ;
   my $sth = $dbh-prepare( $sql );
   die $dbh-errstr if $dbh-err;
   $sth-execute( $group_name, $me, $daily, $item, $unit, $qty,
$amount,
 $tax, $total ) || die Cannot execute FIRST
Statement!!\n$DBI::errstr;


 I keep getting Can't call method prepare on an un undefined value.
All
 the name listed are correct by looking at MySQLAdmin1.3\4.

Apart from David Logan's answer:

You have to create the $dbh object first (man DBI); the undefined
value in

the error message refers to that.


HTH

joe

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]






-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-27 Thread Logan, David (SST - Adelaide)
I'll repeat what I said earlier, can you SELECT from this database prior
to the INSERT? I can't see where the problem is, have you read the DBI
doco? That has a nice trace function which can be used in this
circumstance. It allows you to see the SQL prior to it being sent to the
server, the response from the server etc.

I highly recommend a read. Just as an aside, we obviously live in
different time zones (I'm in Australia) and don't look at emails later
at night because I tend to sleep 8-)

Regards 


David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Monday, 28 February 2005 8:41 AM
To: Logan, David (SST - Adelaide); mysql@lists.mysql.com
Subject: RE: insert data

David,

I just cannot believe what a pain this is.  I got past the prepare with
no
errors by doing the following:

  my $dbh = DBI-connect( 'DBI:mysql:database=club', 'xxx',
'xxx', {
PrintError = 0 } ) or die $DBI::errstr;
  my $sql = insert into wolfies( group_name, me, daily, item, unit,
qty,
amount, tax, total )
  values( ?,  ?,  ?, ?,?,?,
?,
?,   ? ) ;
  my $sth = $dbh-prepare( $sql ) or die $dbh-errstr if $dbh-err;

  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) or warn Cannot execute FIRST Statement!!\n$DBI::errstr;

I just do not believe this, but I get the same error (almost ):

Can't call method execute on an un undefined value

Jerry

-Original Message-
From: Logan, David (SST - Adelaide) [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 3:27 PM
To: Gerald Preston; mysql@lists.mysql.com
Subject: RE: insert data

Hi Gerald,

The only thing I can think of is that you have a syntax error in your
SQL that hasn't showed up in translation to email. Are you able to
select from the database prior to the INSERT? This would confirm that
your db has made a successful connection.

The placeholders etc. work exactly as they do in the oracle version of
the DBI.

Regards

David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Monday, 28 February 2005 7:49 AM
To: [EMAIL PROTECTED]; mysql@lists.mysql.com
Subject: RE: insert data

The object used:

  my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
PrintError = 0} ) or die $DBI::errstr;

Jerry

-Original Message-
From: John Doe [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data

Hi Gerald

 I am trying to insert data for the first time using MySQL.  In Oracle
I
 used the following:

 #  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
 amount, tax, total )

 #  values( ?,  ?,  ?, ?,?,?,
?,
 ?,   ? ) ;
   my $sth = $dbh-prepare( $sql );
   die $dbh-errstr if $dbh-err;
   $sth-execute( $group_name, $me, $daily, $item, $unit, $qty,
$amount,
 $tax, $total ) || die Cannot execute FIRST
Statement!!\n$DBI::errstr;


 I keep getting Can't call method prepare on an un undefined value.
All
 the name listed are correct by looking at MySQLAdmin1.3\4.

Apart from David Logan's answer:

You have to create the $dbh object first (man DBI); the undefined
value in

the error message refers to that.


HTH

joe

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]






--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: insert data

2005-02-27 Thread Paul DuBois
At 5:38 -0600 2/27/05, Gerald Preston wrote:
I just created a new table with the following:
CREATE TABLE `wolfies` (
`group_name` VARCHAR( 38 ) NOT NULL,
`me` VARCHAR(  3 ) NOT NULL,
`daily`  VARCHAR(  8 ) NOT NULL,
`item`   VARCHAR( 60 ) NOT NULL,
`unit`   VARCHAR( 38 ) NOT NULL,
`qty`int   NOT NULL,
`amount` decimal(8,2) NOT NULL,
`tax`decimal(8,2) NOT NULL,
`total`  decimal(8,2) NOT NULL
);
And get the same Can't call method prepare on an un undefined value.
I suspect that means $dbh is not defined, not that $sql is undefined.
prepare() isn't being called as a method of $sql.

All the name listed are correct by looking at MySQLAdmin1.4.
my $sql = insert into wolfies ( group_name, me, daily, item, unit, qty,
amount,
tax, total )
values( ?,  ?,  ?, ?,?,?,   ?,  ?,   ? ) ;
  my $sth = $dbh-prepare( $sql );
  die $dbh-errstr if $dbh-err;
What am I ding wrong?
Thanks,
Jerry
---Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 5:13 AM
To: 'Logan, David (SST - Adelaide)'; 'mysql users'
Subject: RE: insert data
David,
The actual code is uncommented:
my $sql = insert into bar( group_name, me, daily, item, unit, qty, amount,
tax, total )
values( ?,  ?,  ?, ?,?,?,   ?,  ?,   ? ) ;
Sorry,
Jerry
-Original Message-
From: Logan, David (SST - Adelaide) [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 5:09 AM
To: Gerald Preston; mysql users
Subject: RE: insert data
Hi Gerald,
If  this is copied out of your perl code then you haven't put anything
into the $sql variable. Try uncommenting the 2 lines above.
Regards
David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia
+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax
-Original Message-
From: Gerald Preston [mailto:[EMAIL PROTECTED]
Sent: Sunday, 27 February 2005 9:33 PM
To: mysql users
Subject: insert data
Hi!

I am trying to insert data for the first time using MySQL.  In Oracle I
used
the following:

#  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
amount, tax, total )
#  values( ?,  ?,  ?, ?,?,?,
?,
?,   ? ) ;
  my $sth = $dbh-prepare( $sql );
  die $dbh-errstr if $dbh-err;

  $sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;

I keep getting Can't call method prepare on an un undefined value.
All
the name listed are correct by looking at MySQLAdmin1.3\4.

Any ideas?

Thanks,

Jerry
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: insert data

2005-02-27 Thread John Doe
Am Sonntag, 27. Februar 2005 22.19 schrieb Gerald Preston:

Hi Gerald

 The object used:

   my $dbh=DBI-connect( 'DBI:mysql:database=club', 'xxx, 'x', {
 PrintError = 0} ) or die $DBI::errstr;

I didn't see this part in your first post :-)

Hmm... I've never seen a '=' in the first argument passed to DBI-connect...

Here's an functional example I'm using:

my $db ='database';
my $host ='hostname';
my $port ='1234';
$dbh=DBI-connect(DBI:mysql:$db:$host:$port,
 'a_username',
 'a_password',
 {RaiseError=1,   
 AutoCommit=1}) 
or die $0: $DBI::errstr; }


So, try using club instead of database=club, and a hostname too.

greetings joe


[nothing new below]

 -Original Message-
 From: John Doe [mailto:[EMAIL PROTECTED]
 Sent: Sunday, February 27, 2005 6:37 AM
 To: mysql@lists.mysql.com
 Subject: Re: insert data

 Hi Gerald

  I am trying to insert data for the first time using MySQL.  In Oracle I
  used the following:
 
  #  my $sql = insert into bar( group_name, me, daily, item, unit, qty,
  amount, tax, total )
 
  #  values( ?,  ?,  ?, ?,?,?,   ?,
  ?,   ? ) ;
my $sth = $dbh-prepare( $sql );
die $dbh-errstr if $dbh-err;
$sth-execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
  $tax, $total ) || die Cannot execute FIRST Statement!!\n$DBI::errstr;
 
 
  I keep getting Can't call method prepare on an un undefined value. 
  All the name listed are correct by looking at MySQLAdmin1.3\4.

 Apart from David Logan's answer:

 You have to create the $dbh object first (man DBI); the undefined value
 in

 the error message refers to that.


 HTH

 joe

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: Insert data if not duplicate based on order

2004-06-21 Thread John McCaskey
I don't think its possible in one query.  One thing you can do is lock
the table when you select the 20 rows and determine whether to do the
insert.  Then unlock when done.  This avoids the concurrency issue you
are having, but it may cause unacceptable perfomance if you have a lot
of queries hitting this table.  Maybe someone else has a better
solution.

John A. McCaskey

-Original Message-
From: Grant Giddens [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 21, 2004 4:59 PM
To: [EMAIL PROTECTED]
Subject: Insert data if not duplicate based on order


Hi,

  I have a table that has many rows.  I want to be
able to insert a new row only if has a unique field of
the last 20 rows when I sort them by date.

Currently before I insert a new row, I will select a
specific field for 20 rows and run a for loop in php
looking for a match with the data I'm getting ready to
insert.  If a match occurs I will skip the insert
command.

This normally works fine, but I have seen occasions
when 2 people visit my website at the same exact time.
 In this case, sometimes I might insert the data twice
because I think I'm spinning in the for loop for 2
site visitors simultaneously.

I know this is bad syntax, but this is what I imagine
a insert query to look like:


INSERT INTO $table (datax, datay, dataz)
   VALUES ('x', 'y', 'z') IF 'x' unique WHEN
ordering by 'z' DESC LIMIT 20

In this example, 'z' is a datetime field and 'x' is a
varchar.  I don't mind duplicate entries in my table,
but I don't want duplicates entries to occur within 20
rows when sorting by date.

Is this possible to do with one INSERT command?  I saw
the IGNORE statment in the mysql manual, but I don't
think it really aplies to what I'm trying to do here.

Any suggestions would be appreciated,
Thanks,
Grant 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: INSERT data into multiple tables

2003-09-24 Thread Antony Dovgal
On Wed, 24 Sep 2003 14:23:04 -0500
Dan J. Rychlik [EMAIL PROTECTED] wrote:

 Hello,
 
 I have a question about INSERTing data into 2 different tables with one statement.  
 Can you do this?
 
 INSERT INTO table1 (name,address,phone) VALUES ( ' USER ', ' USERADDY ',' 
 USERPHONE') AND table2 (name) VALUES( ' USER ');

No.
Use 2 queries for that:

INSERT INTO table1 (name,address,phone) VALUES ( ' USER ', ' USERADDY ',' USERPHONE');
INSERT INTO table2 (name) VALUES( ' USER ');

---
WBR,
Antony Dovgal aka tony2001
[EMAIL PROTECTED]

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]