At 07:34 PM 8/10/02 +0300, Hytham Shehab wrote:
>     how can i parse the where clause in an SQL::Statement object instance?
>$statement = SQL::Statement->new("select 1,2,3 from table where x=y");

Hytham,

Although I haven't used SQL::Statement you can certainly do something like:

$condition = $1 if $statement =~ /where (.+)( order by .+){0,1}$/;

I haven't tested this but I expect it to pick up the conditional part of an 
SQL statement which would then be up to you to parse further if needed.

In your example though you have assigned the SQL statement in the code. 
Therefore wouldn't it make more sense if this is really how the code works 
to do something like:

my $cond = 'x=y';
$statement = SQL::Statement->new("select 1,2,3 from table where $cond;");

Then you parse upfront, so to speak. This is how I assemble queries on the 
fly for transactions that need that functionality.

hth,

Marty

--
SIMPL WebSite Creation: http://face2interface.com/Home/Demo.shtml


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to