auto repair script for mysql

2005-12-23 Thread Ing. Branislav Gerzo
Hello all, I have one server, where electric power goes down time to time. I have many databases in mysql, and some tables are corrupted. Do you think it is good idea to write script and put it to cron, and it should check if some table has error (MYSQL show status command?), and if yes, it will

storing hierarchical values in db; methods

2005-06-13 Thread Ing. Branislav Gerzo
Hi all, I have question about storing hierarchical values in db. I found some methods, pick up the first easiest, but I ahve question about that - have someone coded some methods, or knows some module, which helps me with this issue ? Ok, here is infos: MYSQL tables: CREATE TABLE `cat_name` (

better error description

2005-05-16 Thread Ing. Branislav Gerzo
Hello all, exist a better error description for DBI errors? I have quite complex datastructure, I'm saving it to DB, using ODBC and MS SQL 2000. I get only: DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Invalid charact er value for cast specification (SQL-22018)(DBD:

executing 2 and more statements

2005-05-16 Thread Ing. Branislav Gerzo
Hello, I'd like to do something like this: $sth-prepare(...) $sth-execute(...) while (my $hr = $sth-fetchrow_hashref) { my $oses = get_os( $hr-{id} ); ... } Function get_os() prepare, execute and return $sth-fetchall_arrayref(); but I'm getting error: DBD::ODBC::st execute failed:

Re: insert column if not exist

2005-05-13 Thread Ing. Branislav Gerzo
Michael A Chase [MAC], on Thursday, May 12, 2005 at 05:48 (-0700) made these points: MAC I'd do something like this: MACmy $sth = $dbh - column_info( undef, $sSchema, $sTable, $sColumn ); MACmy @sColumnInfo = (); MACeval { # The eval isn't needed if RaiseError == 0. MAC

insert column if not exist

2005-05-12 Thread Ing. Branislav Gerzo
Hi all, I'm making script, and I'd like add column, if column not exist. My DBS is MySQL, and I didn't find direct SQL command for this. Is there some workaround for this ? thanks.

Re: insert column if not exist

2005-05-12 Thread Ing. Branislav Gerzo
Michael A Chase [MAC], on Thursday, May 12, 2005 at 05:48 (-0700) has on mind: MAC I'd do something like this: MACmy $sth = $dbh - column_info( undef, $sSchema, $sTable, $sColumn ); MACmy @sColumnInfo = (); MACeval { # The eval isn't needed if RaiseError == 0. MAC @sColumnInfo =

Re: last_insert_id() / MSSQL

2005-05-02 Thread Ing. Branislav Gerzo
Michael Peppler [MP], on Friday, April 29, 2005 at 17:55 (+0200) contributed this to our collective wisdom: MP No - just do a select @@identity to get the latest value. ok, that's the way too, I totally forget about @@identity. thanks. -- How do you protect mail on web? I use

last_insert_id() / MSSQL

2005-04-29 Thread Ing. Branislav Gerzo
Hello all, I connect to MSSQL via ODBC, exist some method to get last inserted id? I read in DBI docs: For some drivers the value may only be available if placeholders have not been used (e.g., Sybase, MS SQL). In this case the value returned would be from the last non-placeholder insert

Re: db or file access?

2005-04-11 Thread Ing. Branislav Gerzo
Ron Savage [RS], on Sunday, April 10, 2005 at 10:23 (+1000) made these points: RS IMHO data goes in databases and files go in directories. RS Raving about speed is simply premature optimization, and hence is a design fault. ok, thanks, will store that into files, I will know in future. Is there

Re: db or file access?

2005-04-11 Thread Ing. Branislav Gerzo
Peter J. Holzer [PJH], on Monday, April 11, 2005 at 09:56 (+0200) wrote: PJH Consistency: Do you need to ensure consistency between this data and PJH other data? If you store data in files, then somebody can remove or PJH alter the files without updating the meta-data in the database. yes, I

Re: db or file access?

2005-04-11 Thread Ing. Branislav Gerzo
Ron Savage [RS], on Monday, April 11, 2005 at 21:06 (+1000) thoughtfully wrote the following: RS Also, I'm glad you did not take my comments as criticism of yourself. I did not RS use the word 'you' which would have implied you personally were raving. that's ok. I'd like to know both sides of

db or file access?

2005-04-09 Thread Ing . Branislav Gerzo
Hi all, This is not direct perl question, but it is database related. I am on freebsd, using mysql, and thinking about storing pictures in database. But someone tolds me, that is faster to have only id in db, and picture stored in harddisk in good dir structure, for example: /1/10/100/1000342.jpg

Re: charset trouble

2005-03-22 Thread Ing. Branislav Gerzo
Ing. Branislav Gerzo [IBG], on Monday, March 21, 2005 at 15:18 (+0100) made these points: IBG I'm using AS perl 5.8.6 on win2003, I can't continue work, because I IBG don't understand what's going here: IBG I have in MSSQL table, where I have only 1 column, and 1 row, which IBG contains accent c

Re: parsing a file

2005-02-28 Thread Ing. Branislav Gerzo
Laurie Vien [LV], on Monday, February 28, 2005 at 10:11 (-0500) wrote: LV How do I unsubscribe from this list? you have that in _every_ mail, just look at headers. List-Unsubscribe: mailto:[EMAIL PROTECTED] -- ...m8s, cu l8r, Brano. [When the going gets weird, the weird turn pro. --

retrieve many values

2005-02-22 Thread Ing. Branislav Gerzo
Hi all, I have table which consist of cca 20.000.000 rows, using MySQL. How to do something with each row ? I mean: I can't select them all into memory, I can't use LIMIT, because it is slow at higher values, so what is good to use ? I think about: select id, name from table where id 100 and

Re: retrieve many values

2005-02-22 Thread Ing. Branislav Gerzo
Reidy, Ron [RR], on Tuesday, February 22, 2005 at 06:58 (-0700) wrote: my $sth = $dbh-prepare_cached(select id, name from table); my $sth = $dbh-$sth-execute(); RR [rr] This should read $sth-execute. Execute retruns a RR value, not a statement handle ($sth). yes, sorry for that. In my code I

Re: retrieve many values

2005-02-22 Thread Ing. Branislav Gerzo
Scott T. Hildreth [STH], on Tuesday, February 22, 2005 at 08:36 (-0600) thinks about: STH Mysql will return all rows by default, you need to turn that off. STH I can't remember what the attribute is, read the DBD::mysql perldoc. I do everything, but I cannot find that. I looked in

Re: retrieve many values

2005-02-22 Thread Ing. Branislav Gerzo
Scott T. Hildreth [STH], on Tuesday, February 22, 2005 at 08:50 (-0600) wrote the following: STH my $sth = $dbh-prepare(QUERY); STH $sth-{mysql_use_result} = 1; thanks a lot, you save me a day! :) -- ...m8s, cu l8r, Brano. [Foiling felons and thwarting thieves. - DarkWing

Re: retrieve many values

2005-02-22 Thread Ing. Branislav Gerzo
Scott T. Hildreth [STH], on Tuesday, February 22, 2005 at 08:50 (-0600) typed the following: STH my $sth = $dbh-prepare(QUERY); STH $sth-{mysql_use_result} = 1; this is indeed nice, but solve problem only half. When I process value I want insert/update it to db. But I get, when

random rows

2005-02-14 Thread Ing. Branislav Gerzo
Hi all, I have one simple question - how I can return 10 random rows from select? For example we have select: Select name, street, date from people order by date desc limit 0,100 Now, I want return 10 random peoples. How to do it ? It is possible via SQL statement, or I have to care about

Statement help

2005-02-07 Thread Ing. Branislav Gerzo
Hello, I have in mysql table kl: ID, value, flow now, when I run in mysql: UPDATE kl SET value = 10, flow = value - 10 where ID = 5; it works. But when I write that in script: my $sth = $dbh-prepare_cached(UPDATE kl SET value = ?, flow = value - ? WHERE ID = ?); $sth-execute( 10, 10, 5 ); I

insert/update/get id

2005-02-01 Thread Ing. Branislav Gerzo
Hello friends, one common problem is: Insert foo to db if foo doesn't exists, get ID at last. I am pretty sure it could be done better way, snippet here: #insert link my $sth = $dbh-prepare_cached(q[ INSERT INTO link SETlink = ? ON DUPLICATE KEY UPDATE link = link ]); $sth-execute(

get one column

2005-01-28 Thread Ing. Branislav Gerzo
Hi all! I have subroutine, that checks, if I already have in DB specified row: sub image_exist { my ($id, $date) = @_; #id is _always_ number my $sth = $mydbh-prepare_cached(select ID from pic where id = ?); $sth-execute($id); my $rows = $sth-fetchall_arrayref(); if (

Parallel::ForkManager DBI memory leak ?

2004-12-29 Thread Ing. Branislav Gerzo
Hi pals, this is my first post to this mailing list. I have one problem, it is maybe for you small, but for me a big problem. If I want improve my scripts I _have_ to use parallel DB access. When I looked around I come to Parallel::ForkManager module, easy to use. When I wrote script, I saw it

Re: Parallel::ForkManager DBI memory leak ?

2004-12-29 Thread Ing. Branislav Gerzo
Moosmann, James [MJ], on Wednesday, December 29, 2004 at 07:07 (-0500) thoughtfully wrote the following: MJ I am really disappointed with Perl's lack of support for any reliable. MJ multithreaded behavior. I keep hoping it gets fixed. But I have waited for MJ 2 years. ahm, I wrote some posts

Re: Parallel::ForkManager DBI memory leak ?

2004-12-29 Thread Ing. Branislav Gerzo
Ron Wingfield [RW], on Wednesday, December 29, 2004 at 10:29 (-0600) wrote the following: RW I know my comments do not provide an immediate solution, but RW this could be a very interesting thread.  Infact, I'm going to be RW writing some IPC intensive code in the near future, and I want to RW