Re: Column names when using selectall_arrayref

2006-05-04 Thread David Kaufman
Hi Bill, "Bill Moseley" <[EMAIL PROTECTED]> wrote: How do I get the column names as a list to match the order of the rows returned when using select/fetchall_arrayref [...] I'm not having luck finding it in the docs. See the "Statement Handle Attributes" section of the DBI docs: http://search.

Re: Column names when using selectall_arrayref

2006-05-03 Thread Jonathan Leffler
On 5/3/06, Bill Moseley <[EMAIL PROTECTED]> wrote: How do I get the column names as a list to match the order of the rows returned when using select/fetchall_arrayref and using an ARRAY slice? I'm not having luck finding it in the docs. I don't know the column names ahead of time -- I'm passed

Re: Column names have spaces in them!!!

2006-02-02 Thread Robert Hicks
Alexander Foken wrote: You could slowly migrate your system, a first step would be to make sure all table and column names match /^[A-Za-z][A-Za-z0-9_]+$/. Next, move the tables and the business logic to a "real" database. Then finally, get rid of ODBC drivers and Access on the clients and swi

Re: Column names have spaces in them!!!

2006-02-01 Thread Ron Savage
On Wed, 1 Feb 2006 15:46:31 -0800, Darren Duncan wrote: Hi Darren > It would be quite natural for such users to make identifiers like > 'Person' and 'Home Address' and 'Home Telephone' and 'Work > Telephone' and so on; it isn't natural for them to say > 'Home_Telephone' and such. I agree. My d

Re: Column names have spaces in them!!!

2006-02-01 Thread Darren Duncan
At 9:30 AM +1100 2/2/06, Ron Savage wrote: On Wed, 01 Feb 2006 13:36:41 +0100, Alexander Foken wrote: Right. But using a restrictive set of characters for table and column names makes things easier. "The column for the number of Just as I raved about back in 2003 :-): Now, I understand th

Re: Column names have spaces in them!!!

2006-02-01 Thread Ron Savage
On Wed, 01 Feb 2006 13:36:41 +0100, Alexander Foken wrote: Hi Alexander > Right. But using a restrictive set of characters for table and > column names makes things easier. "The column for the number of Just as I raved about back in 2003 :-): http://savage.net.au/Ron/html/naming-database-object

Re: Re: Column names have spaces in them!!!

2006-02-01 Thread Tim Bunce
On Wed, Feb 01, 2006 at 02:08:32AM +0100, [EMAIL PROTECTED] wrote: > use backticks instead of double quotes: > > my $sth=$dbh->prepare('select * from taskhours_per_date where `employee > name`=?'); That's not portable. The DBI has a $dbh->quote_identifier method to abstract this and do-the-righ

Re: Column names have spaces in them!!!

2006-02-01 Thread Alexander Foken
Darren Duncan wrote: At 9:44 AM +0100 2/1/06, Alexander Foken wrote: You could slowly migrate your system, a first step would be to make sure all table and column names match /^[A-Za-z][A-Za-z0-9_]+$/. Next, move the tables and the business logic to a "real" database. Then finally, get rid o

Re: Column names have spaces in them!!!

2006-02-01 Thread Darren Duncan
At 9:44 AM +0100 2/1/06, Alexander Foken wrote: You could slowly migrate your system, a first step would be to make sure all table and column names match /^[A-Za-z][A-Za-z0-9_]+$/. Next, move the tables and the business logic to a "real" database. Then finally, get rid of ODBC drivers and Acces

Re: Column names have spaces in them!!!

2006-02-01 Thread Alexander Foken
Robert Hicks wrote: Alexander Foken wrote: You need to pass the quotes to the SQL engine. And by the way, you should either use parameters or the quote function for values: my $sth=$dbh->prepare('select * from taskhours_per_date where "employee name"=?'); $sth->execute('NAME HERE'); Maybe

Re: Re: Column names have spaces in them!!!

2006-01-31 Thread perl
use backticks instead of double quotes: my $sth=$dbh->prepare('select * from taskhours_per_date where `employee name`=?'); Regards, Renee Am 31.01.2006 um 23:58 Uhr haben Sie geschrieben: > Alexander Foken wrote: > > You need to pass the quotes to the SQL engine. And by the way, you > > should

Re: Column names have spaces in them!!!

2006-01-31 Thread Robert Hicks
Alexander Foken wrote: You need to pass the quotes to the SQL engine. And by the way, you should either use parameters or the quote function for values: my $sth=$dbh->prepare('select * from taskhours_per_date where "employee name"=?'); $sth->execute('NAME HERE'); Maybe MS Acesss has other wa

Re: Column names have spaces in them!!!

2006-01-31 Thread John Scoles
Ugg!! first coice is to rebuild the table second choice I found that wrapping the offending field name in [ ] worked with ODBC and OLE but I am not sure how this will workd with DBI? something like this SELECT * FROM taskhours_per_date WHERE [EMPLOYEE NAME] = 'NAME HERE' might work option

Re: Column names have spaces in them!!!

2006-01-31 Thread Alexander Foken
You need to pass the quotes to the SQL engine. And by the way, you should either use parameters or the quote function for values: my $sth=$dbh->prepare('select * from taskhours_per_date where "employee name"=?'); $sth->execute('NAME HERE'); Maybe MS Acesss has other ways to do this, especiall

Re: Column names have spaces in them!!!

2006-01-31 Thread paul . boutros
I believe you want square-brackets for Access: my $sth = $dbh->prepare("SELECT * FROM taskhours_per_date WHERE [EMPLOYEE NAME] = ?"); Paul Quoting Robert Hicks <[EMAIL PROTECTED]>: > I am using the ODBC module to talk to an Access database. In that > database some of the column names have spa

Re: Column Names for Oracle Cursor

2002-11-04 Thread Michael A Chase
On Mon, 4 Nov 2002 19:08:27 +0100 Georg Botorog <[EMAIL PROTECTED]> wrote: > Is there a way to get the column names for a cursor call instead of > ":B1", ":B2", etc? Those names are usually associated with bind variables, not columns. Some example code might make it easier for someone here to fig

Re: Column names and etc..

2002-01-11 Thread Bart Lateur
On Fri, 11 Jan 2002 09:07:15 -0500, Terrence Brannon wrote: >> You can do (very portable): >> >> my $sth = $dbh->prepare("SELECT * FROM $table"); > >its a shame that it is not just as portable to limit the result >set to 1 row... How about 0 rows? my $sth = $dbh->prepare("SELECT *

Re: Column names and etc..

2002-01-11 Thread Michael Peppler
Bart Lateur writes: > [beginners list snipped] > > On Fri, 11 Jan 2002 11:40:03 +0100, Marius Keraitis wrote: > > >Second step is to show every table contents (by clicking on link with table > >name). > >To do this I need to know how many columns is in table, and all names of columns > >

Re: Column names and etc..

2002-01-11 Thread eingb
On 11 Jan 2002, at 9:07, Terrence Brannon wrote: > > On Friday, January 11, 2002, at 07:09 AM, Bart Lateur wrote: > > > [beginners list snipped] > > > > On Fri, 11 Jan 2002 11:40:03 +0100, Marius Keraitis wrote: > > > >> Second step is to show every table contents (by clicking on link > >> with

Re: Column names and etc..

2002-01-11 Thread Terrence Brannon
On Friday, January 11, 2002, at 07:09 AM, Bart Lateur wrote: > [beginners list snipped] > > On Fri, 11 Jan 2002 11:40:03 +0100, Marius Keraitis wrote: > >> Second step is to show every table contents (by clicking on link >> with table >> name). >> To do this I need to know how many columns is i

Re: Column names and etc..

2002-01-11 Thread Bart Lateur
[beginners list snipped] On Fri, 11 Jan 2002 11:40:03 +0100, Marius Keraitis wrote: >Second step is to show every table contents (by clicking on link with table >name). >To do this I need to know how many columns is in table, and all names of columns >in table. You can do (very portable):

RE: Column names and etc..

2002-01-11 Thread Siiskonen, Pekka
Not a real Perl/Oracle hacker, but try if the select clause below produces the data you need: === select OWNER, TABLE_NAME, COLUMN_ID, COLUMN_NAME, DATA_TYPE, DATA_LENGTH, NULLABLE from all_tab_colu

RE: Column Names

2001-11-02 Thread Steve Howard
the use in execute or print or whatever else might be useful. I find it very slick when I need column names. Steve H. -Original Message- From: Scott R. Godin [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 6:28 AM To: [EMAIL PROTECTED] Subject: Re: Column Names In article <

Re: Column Names

2001-11-02 Thread Tim Bunce
On Fri, Nov 02, 2001 at 02:41:05PM -0500, Scott R. Godin wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Tim Bunce) wrote: > > > On Fri, Nov 02, 2001 at 02:18:15PM +0100, Bart Lateur wrote: > > > On Fri, 02 Nov 2001 07:27:49 -0500, Scott R. Godin wrote: > > > > > > >my %db; >

Re: Column Names

2001-11-02 Thread Scott R. Godin
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Michael Peppler) wrote: > > my $rows = $sth->rows; > > # only expecting one row for a unique ID . this should NEVER happen. > >safe_error("invalid number of rows returned from database ($rows) for > > ID $id") > > if $rows

Re: Column Names

2001-11-02 Thread Scott R. Godin
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Tim Bunce) wrote: > On Fri, Nov 02, 2001 at 02:18:15PM +0100, Bart Lateur wrote: > > On Fri, 02 Nov 2001 07:27:49 -0500, Scott R. Godin wrote: > > > > >my %db; > > >$sth->bind_columns( \( @db{ @{ $sth->{NAME} } } ));# magic > > > > > >

Re: Column Names

2001-11-02 Thread Tim Bunce
On Fri, Nov 02, 2001 at 02:18:15PM +0100, Bart Lateur wrote: > On Fri, 02 Nov 2001 07:27:49 -0500, Scott R. Godin wrote: > > >my %db; > >$sth->bind_columns( \( @db{ @{ $sth->{NAME} } } ));# magic > > > >while ($sth->fetch) > >{ > >#... and no worries about which order the

Re: Column Names

2001-11-02 Thread Michael Peppler
Scott R. Godin writes: > the absolute neatest trick I've seen with this, that is so totally > perlish it defies description.. you stare at it for a bit and suddenly > all becomes clear. > >$sth->execute > or die("Cannot Execute SQL Statement: ", $sth->errstr(), "\n"); >

Re: Column Names

2001-11-02 Thread Bart Lateur
On Fri, 02 Nov 2001 07:27:49 -0500, Scott R. Godin wrote: >my %db; >$sth->bind_columns( \( @db{ @{ $sth->{NAME} } } ));# magic > >while ($sth->fetch) >{ >#... and no worries about which order the columns get returned in >#... since you access them via the $db{Colum

Re: Column Names

2001-11-02 Thread Scott R. Godin
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Bart Lateur) wrote: > On Thu, 01 Nov 2001 18:56:18 -0800, Venkataramana Mokkapati wrote: > > >How do I get column names and order of column names > >for a "select * from ..." query. > > If you have > > $sth = $dbh->prepare("select * fro

Re: Column Names

2001-11-02 Thread Bart Lateur
On Thu, 01 Nov 2001 18:56:18 -0800, Venkataramana Mokkapati wrote: >How do I get column names and order of column names >for a "select * from ..." query. If you have $sth = $dbh->prepare("select * from ..."); then try @column_names = @{$sth->{NAME}}; You may have to do an "ex

Re: Column Names

2001-11-02 Thread Simon Oliver
$sth->{NAME} returns a reference to an array of field names for each column e.g. foreach my $column (@{ $sth->{NAME} }) { print $column; } -- Simon Oliver