Useless use of a (constant|hash element) in void context?

Fox, Michael Michael.Fox at auspost.com.au
Mon Oct 6 02:02:27 CDT 2003


No - the method is on a database handle, not a statement handle; there is no
need to prepare a select

-----Original Message-----
From: ADFH [mailto:mpm at bachelorguy.com]
Sent: Monday, 6 October 2003 11:09 AM
To: melbourne-pm at pm.org
Subject: Re: Useless use of a (constant|hash element) in void context?


"Fox, Michael" <Michael.Fox at auspost.com.au> wrote:
> Yep, this is the portable way to get metadata for the data to be
> returned by the statement handle, but if you want to get primary key
> info for a table in a portable way then use the primary_key_info and
> primary_key methods 

From: Andrew Creer <ac at mail.market-research.com>
> For MySQL the DBI methods
>  $sth->{NAME}
>  $sth->{TYPE}
>  $sth->{PRECISION}
>  $sth->{SCALE}
>  $sth->{NULLABLE}
> all return arrays of relavent data after you have done a
>  $sth->execute()

So instead of using "SHOW COLUMNS FROM table" I should be doing a
limited "SELECT * FROM table LIMIT 1" and then reading the data shown
above (as it's not always for data that exists in database)..

The problem I have with this is, what does one do when there is no data
in the table... as I'm dealing with data which may potentially be the
first INSERT in the table.

Perhaps being able to fetch the metadata alone for a given table should
become a standardised function available in DBI?

From: Scott Penrose <scottp at dd.com.au>
> Instead, you need here to assign a hashref, which is the only way to 
> assign a hash to a scalar.

So how does one get a reference out of a hash constructor - case of two
line process?

Ie.
	my %temphash=( .... => .... , .... );
	$dbct{$dbr_ref->{'field'}}=\%temphash;

I guess I've always been curious - what's the difference between
prefixing something with an ampersand or a backslash? I'm thinking
ampersand dereferences and backslash generates reference. Is an area I
never quite got (once I figure out this stuff, I think I'll revisit
scoping in Perl then OO then making modules - experience is beginning to
tell me, that just like learning vi :) , things tend to just "click"
after awhile)..

Anthony



Australia Post is committed to providing our customers with excellent service. If we can assist you in any way please either telephone 13 13 18 or visit our website www.auspost.com.au.

CAUTION

This e-mail and any files transmitted with it are privileged and confidential information intended for the use of the addressee. The confidentiality and/or privilege in this e-mail is not waived, lost or destroyed if it has been transmitted to you in error. If you have received this e-mail in error you must (a) not disseminate, copy or take any action in reliance on it; (b) please notify Australia Post immediately by return e-mail to the sender; and (c) please delete the original e-mail.



More information about the Melbourne-pm mailing list