Glen Muras [[EMAIL PROTECTED]] wrote:
> Sorry about that.  Not great at writing these things.
> This is the same SQL:
> insert into contacts (contactid, Accountid, Firstname, Lastname)
> 
> I would like to use something like this:
> insert into contacts .+
> 
> 
> What I am trying to do is build up an access list like a router, but in this
> case a list of allowable SQL statements.  But I cannot see how to pass
> through variables that the perl script captured from the user into the SQL
> statements, if they are hard coded in the remote server config file.

I'm still not quite sure what your goal is, but if all you're
trying to do is be able to substitute in variable values into
your sql, you can so it like this:

  my $sql = qq{
     insert into contacts (contactid, Accountid, Firstname, Lastname)
                 values (?, ?, ?, ?)
  };
  my $sth = $dbh->prepare($sql);
  my $rows_affected = $sth->execute($contact_id, $account_id, $first, $last);

Those values($contact_id, $account_id, $first, $last) can be anything
your perl script captured or derived or created, etc.

Of course this doesn't do any error checking, and yours definitely
should.  This is all detailed in the perldocs:

   perldoc DBI

at a command prompt.

HTH.
  
-- 
Hardy Merrill
Senior Software Engineer
Red Hat, Inc.

> 
> 
> Hope that helps
> Glen.
> 
> 
> 
> > My question is about the SQL statement part for a user.
> > I know this is a broad question, but I have done many google searches and
> > perldoc viewing, but I am still unsure....   How does the sql part work?
> > 
> > This is how I understand it, given the following cfg lines:
> > 
> > 'sql' => {
> >     'select1' => 'select * from table1',
> >     'select2' => 'select * from table2'
> > }
> > 
> > >From the client program, you can then only run 'select1' and 'select2'
> SQL
> > statements.
> > 
> > Is there any way to use regex in the 'select * from ...' part? Or does it
> > have to be verbatim SQL statements as I have so far discovered.
> 
> But more descriptive here - *how* do you want to use regex(es) in
> the 'select * from ...' part?  A simple example of what you'd *like*
> to do would be great.
> 
> -- 
> Hardy Merrill
> Senior Software Engineer
> Red Hat, Inc.

Reply via email to