Book Recommendation?
Greets Folks, I wrote in yesterday as per the author of the DBI module, but the documentation i have found really doesnt seem sufficient for learning the module... Is there a book I should buy for this? I checked ou this book: http://www.amazon.com/exec/obidos/ASIN/1565926994/ref=ase_dbi/102-6988665-4359353 But this is a 350 page book, and I am just starting out. Is there something a little more concise? I've got Paul DuBois' book MySQL and Perl for the Web, but I feel like maybe I shoudl focus more on the DBI module itself before going too much further into DuBois' book. What would you folks recommend? Thanks, Will __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
Re: [Poop-group] ANNOUNCE: Class::DBI 0.89
On Tue, Jun 25, 2002 at 08:46:47AM +, william ross wrote: i notice that defining a relationship with might_have doesn't add a column to $class-__hasa_columns. is that something you're likely to change? it's enormously useful for me to be able to define relationship columns which might not be occupied - eg person foo might_have a mugshot in the images table - but at the moment i don't think i can use it because my input functions depend on reading $class-columns and attempting to fill the vacancies that defines. Hmmm... might_have works slightly differently from hasa, so I'm slightly reluctant to start adding its information into the __hasa_columns info. I have a sneaky suspicion that doing this would cause cries of horror from other people who manipulate this information for some other purpose. What I need to do for some other project is have a way of asking a Class::DBI class for some information about itself - what columns it has, what relationships it has etc. If there was a good interface to this would that do what you need? Has anyone any suggestions for how this should operate? Tony
Re: HELP ME !! Can't locate object method connect via package DBI
On Tue, 25 Jun 2002 11:55:36 -0400, [EMAIL PROTECTED] wrote: Can't load module DBI, dynamic loading not available in this perl. This means you have a statically compiled perl, without support for dynamic loading. It should help to recompile perl. As the error message goes on, you basically have two options: (You may need to build a new perl executable which either supports dynamic loading or has the DBI module statically linked into it.) If you're inexperienced in compiling C programs on your system, this will rather be a daunting task. You'd better find someone who's done that before, or, at least, find a very detailed tutorial. -- Bart.
Inserting formatted Date
This works fine: my $sth = $dbh-prepare( INSERT INTO stats VALUES (SYSDATE,?,?,?,?) ) or die Cannot prepare SQL statements from $DBI::errstr\n; however if i try to format it like: my $sth = $dbh-prepare( INSERT INTO stats VALUES (to_char(SYSDATE, 'Dy DD-Mon- HH24:MI'),?,?,?,?) ) or die Cannot prepare SQL statements from $DBI::errstr\n; -- it fails, it tried quoting it with: $qstr = q!to_char(sysdate, 'Dy DD-Mon- HH24:MI')!; and plugging that in: $dbh-prepare( INSERT INTO stats VALUES ($qstr,?,?,?,?) -- failed ! even tried quote(): $qstr = to_char(sysdate, 'Dy DD-Mon- HH24:MI'); $q = $dbh-quote($q); $dbh-prepare( INSERT INTO stats VALUES ($q,?,?,?,?) -- still fails any ideas? Thanks Jim
Re: How I can eliminate the double quotes when I read a csvfile?
TIBA, LIVIA wrote: Thanks Jeff, I already tried that, because I read about the default value for quote_char, escape_char but doesn't work. It works for me. Please try this script which creates the data file you described and then reads it with DBD::CSV. It works as it should for me. If it doesn't for you, please tell me what platform you're on, and what versions of perl, DBI, DBD::CSV, and SQL::Statement you are using and the script output. #!perl -w use strict; use DBI; my $dbh=DBI-connect('dbi:CSV(RaiseError=1):'); open( O, PM_Report) or die $!; print O EOP; MSUID|ServiceType ALM75SPR-001|WAN ARP350JOH-001|WAN EOP close O; $dbh-{'csv_tables'}-{'PM_Report'} = { 'eol' = \n, 'sep_char' = '|', 'file' = './PM_Report' }; my $sth = $dbh-prepare('SELECT * FROM PM_Report'); $sth-execute; while (my $row = $sth-fetchrow_arrayref) { for my $col( $row ) { print [$col] ; } print \n; } __END__ -- Jeff
RE: Inserting formatted Date
I think the problem here is a type problem. The to_char is returning a char type and the column is a date type. To_char returns a character string and that's failing on the insert due to the table requiring a date type. Without knowing exactly what database you are using I can't give you much help making it work. In Oracle it would be something like: to_date(to_char(SYSDATE, 'Dy-DD-Mon- HH24:MI'), 'Dy-DD-Mon- HH24:MI') Gordon -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 25, 2002 11:41 AM To: DBI-Users Subject: Inserting formatted Date This works fine: my $sth = $dbh-prepare( INSERT INTO stats VALUES (SYSDATE,?,?,?,?) ) or die Cannot prepare SQL statements from $DBI::errstr\n; however if i try to format it like: my $sth = $dbh-prepare( INSERT INTO stats VALUES (to_char(SYSDATE, 'Dy DD-Mon- HH24:MI'),?,?,?,?) ) or die Cannot prepare SQL statements from $DBI::errstr\n; -- it fails, it tried quoting it with: $qstr = q!to_char(sysdate, 'Dy DD-Mon- HH24:MI')!; and plugging that in: $dbh-prepare( INSERT INTO stats VALUES ($qstr,?,?,?,?) -- failed ! even tried quote(): $qstr = to_char(sysdate, 'Dy DD-Mon- HH24:MI'); $q = $dbh-quote($q); $dbh-prepare( INSERT INTO stats VALUES ($q,?,?,?,?) -- still fails any ideas? Thanks Jim
RE: Inserting formatted Date
What is the data type for the field into which you are inserting the date? If it's a DATE field, you do the formatting when you retrieve the value, not when you set it. If it's not a DATE field, it should be. the data type is 'date'. I wanted to format it as i insert because the field is a key on 2 tables i will be querying on (so the date/time should be =)? i guess the question would then be how does oracle store the date ? meaning if it is formatted then stored, does oracle still store it like 6/25/2002 1:18:14 PM anyway.
RE: Inserting formatted Date
Oracle stores the date as a number. This works out as the number of seconds from a significant date (in Oracle's mind). Therefore, you must send it as a date (or number). The to_char function returns the character representation of the number stored in the field. so then it does not matter how i format it before when i insert it? what i mean if i insert a date that is formatted to 25-Jun-2002 13:44(no seconds) and this is entered into a date field in 2 seperate tables a second apart (but still both display 25-Jun-2002 13:44 if queried) the 2 will still not be equal? -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 25, 2002 11:20 AM To: DBI-Users Subject: RE: Inserting formatted Date What is the data type for the field into which you are inserting the date? If it's a DATE field, you do the formatting when you retrieve the value, not when you set it. If it's not a DATE field, it should be. the data type is 'date'. I wanted to format it as i insert because the field is a key on 2 tables i will be querying on (so the date/time should be =)? i guess the question would then be how does oracle store the date ? meaning if it is formatted then stored, does oracle still store it like 6/25/2002 1:18:14 PM anyway.
Re: Inserting formatted Date
On Tue, Jun 25, 2002 at 01:19:34PM -0400, Kipp, James wrote: What is the data type for the field into which you are inserting the date? If it's a DATE field, you do the formatting when you retrieve the value, not when you set it. If it's not a DATE field, it should be. the data type is 'date'. I wanted to format it as i insert because the field is a key on 2 tables i will be querying on (so the date/time should be =)? i guess the question would then be how does oracle store the date ? meaning if it is formatted then stored, does oracle still store it like 6/25/2002 1:18:14 PM anyway. The DATE datatype in Oracle is stored in a special internal format. (Specifically, it's a floating point number representing the number of days since some point in time.) As I said before, the formatting only comes into play when you retrieve the value, not when you store it. If you want to use the same date/time in two tables, you should select SysDate from Dual first, and insert that value into both tables. Ronald
RE: Inserting formatted Date
The DATE datatype in Oracle is stored in a special internal format. (Specifically, it's a floating point number representing the number of days since some point in time.) As I said before, the formatting only comes into play when you retrieve the value, not when you store it. If you want to use the same date/time in two tables, you should select SysDate from Dual first, and insert that value into both tables. Ok, that answers my question!! so would i just capture the literal value from the select and insert that value into both tables? Thanks Ronald !!
RE: Inserting formatted Date
IF you insert into a table using the to_date function, Oracle uses that function to make the calculation and converts it to a number. So, if you used the function to_date('01-01-2002', 'dd-mm-') this would be the same as to_date('Jan 01, 2002', 'Mon dd, '). If you start adding times in to get more complicated, but you get the idea. -Bruce -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 25, 2002 12:10 PM To: Powell, Bruce; DBI-Users Subject: RE: Inserting formatted Date Oracle stores the date as a number. This works out as the number of seconds from a significant date (in Oracle's mind). Therefore, you must send it as a date (or number). The to_char function returns the character representation of the number stored in the field. so then it does not matter how i format it before when i insert it? what i mean if i insert a date that is formatted to 25-Jun-2002 13:44(no seconds) and this is entered into a date field in 2 seperate tables a second apart (but still both display 25-Jun-2002 13:44 if queried) the 2 will still not be equal? -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 25, 2002 11:20 AM To: DBI-Users Subject: RE: Inserting formatted Date What is the data type for the field into which you are inserting the date? If it's a DATE field, you do the formatting when you retrieve the value, not when you set it. If it's not a DATE field, it should be. the data type is 'date'. I wanted to format it as i insert because the field is a key on 2 tables i will be querying on (so the date/time should be =)? i guess the question would then be how does oracle store the date ? meaning if it is formatted then stored, does oracle still store it like 6/25/2002 1:18:14 PM anyway. ___ CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
Re: Inserting formatted Date
On Tue, Jun 25, 2002 at 02:09:56PM -0400, Kipp, James wrote: Oracle stores the date as a number. This works out as the number of seconds from a significant date (in Oracle's mind). Therefore, you must send it as a date (or number). The to_char function returns the character representation of the number stored in the field. so then it does not matter how i format it before when i insert it? what i mean if i insert a date that is formatted to 25-Jun-2002 13:44(no seconds) and this is entered into a date field in 2 seperate tables a second apart (but still both display 25-Jun-2002 13:44 if queried) the 2 will still not be equal? You do not need to format the date at all when you insert it. If you store the date 25-Jun-2002 13:44 in two tables, the two *will* be equal. It doesn't matter what time it is in the real world when you insert the fixed date. Ronald
Re: MS Access
Orlando Andico wrote: It IS possible to read MSAccess files on a Linux box. http://mdbtools.sourceforge.net/ Hmm, I had no idea that was available, forget my advice about saving the Access files as CSV. At first glance it looks like it would be trivial to build an AnyData::Format::Access.pm using mdbtools which would then provide direct DBI interface to the MDB files. If anyone is interested in doing this, let me know and I'll help. -- Jeff
Re: MS Access
With the freetds drivers you can connect directly from solaris to an MS-Access database. I have done it many times and if you search on google there is a webpage that tells how to do it. keith Jeff Zucker wrote: Orlando Andico wrote: It IS possible to read MSAccess files on a Linux box. http://mdbtools.sourceforge.net/ Hmm, I had no idea that was available, forget my advice about saving the Access files as CSV. At first glance it looks like it would be trivial to build an AnyData::Format::Access.pm using mdbtools which would then provide direct DBI interface to the MDB files. If anyone is interested in doing this, let me know and I'll help. -- - Keith Clay, [EMAIL PROTECTED] Lead Programmer, Web Integration and Programming 286 Adams Center for Teaching Excellence Abilene Christian University Abilene, TX 79699 (915) 674-2187 (915) 674-2834 -
Re: MS Access
Actually since MDB Tools is also an ODBC driver, you could probably use DBD::ODBC as well. Although to be honest, the SQL engine and ODBC driver have a number of nasty bugs. I haven't tried this arrangement myself, so buyer beware. Brian On 25 Jun 2002, Jeff Zucker wrote: Orlando Andico wrote: It IS possible to read MSAccess files on a Linux box. http://mdbtools.sourceforge.net/ Hmm, I had no idea that was available, forget my advice about saving the Access files as CSV. At first glance it looks like it would be trivial to build an AnyData::Format::Access.pm using mdbtools which would then provide direct DBI interface to the MDB files. If anyone is interested in doing this, let me know and I'll help.