bind params and default values

2003-10-27 Thread sean peters
Hi all, i've been having an issue with binding params. If i have created an 
INSERT  query with a param binding to a particular column, call it column 
A, is there any way that i can use that (prepared) query to get the db 
defined default value into column A?

Im at a loss!
thanks much,

sean peters
[EMAIL PROTECTED]

BTW: i have posted a similar question to perlmonks under the title DBI bind 
params  column defaults

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



RE: bind params and default values

2003-10-27 Thread Dathan Vance Pattishall


---Original Message-
--From: sean peters [mailto:[EMAIL PROTECTED]
--Sent: Monday, October 27, 2003 10:17 AM
--To: [EMAIL PROTECTED]
--Subject: bind params and default values
--
--Hi all, i've been having an issue with binding params. If i have
created
--an
--INSERT  query with a param binding to a particular column, call it
column
--A, is there any way that i can use that (prepared) query to get the
db
--defined default value into column A?
Yes don't put it in your list. Mysql will automatically add the default
on the insert if it is not defined. For example
Col  Default
A - default 'Hi'
B - default 'Lo'
C - default '0'

my $query = 'INSERT INTO made_up_table (B,C) VALUES (?,?)';

$DBI_dbh-prepare($query);

@data = ('NotLo','1');
$DBI_dbh-execute(@data);


Does this help?

--
--Im at a loss!
--thanks much,
--
--sean peters
--[EMAIL PROTECTED]
--
--BTW: i have posted a similar question to perlmonks under the title
DBI
--bind
--params  column defaults
--



- Dathan Vance Pattishall
  - Sr. Programmer and mySQL DBA for FriendFinder Inc.
  - http://friendfinder.com/go/p40688



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



RE: bind params and default values

2003-10-27 Thread Dathan Vance Pattishall


- Dathan Vance Pattishall
  - Sr. Programmer and mySQL DBA for FriendFinder Inc.
  - http://friendfinder.com/go/p40688


---Original Message-
--From: sean peters [mailto:[EMAIL PROTECTED]
--Sent: Monday, October 27, 2003 11:54 AM
--To: Dathan Vance Pattishall
--Subject: Re: bind params and default values
--INSERT INTO my_table (A, B) VALUES ( COALESCE(?, A), COALESCE(?, B) )
--
--I think this should work, but am now wondering how much time this
will
--actually save me. I say this because in this situation, even though
the
--query
--is preparsed, mysql still needs to calculate the coalesce values each
--time.

mySQL currently does not respect prepare, although 5.0 will. So, it will
not save you anytime.

--
--Im really weighing potential time tradeoffs here.
--
--My other thought is to create prepared queries for each combination
of
--fields
--that will show up for my insert queries. Because of the nature of my
--task,
--there should only be about 10-20 queries for each table for each
process,
--which isnt horrible to store, but then my perl script needs to take
the
--time
--to decide which cached query to use, and again, i think that i
haven't
--gained
--anything timewise.

Well remember for your proposal to work in the manner stated above you
will need to have a statement handle, thus you need a connection
established to the mysql server for the 10-20 SQL commands. 10-20
connections remaining persistent can become a problem later on if your
concern about scale.

Also since mysql does not support prepare like Oracle does YET, you
might just be better off looking for speed in other areas such as tuning
the mysql server or looking at your table structure: rem keys etc.







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