Jasmine wrote:

> Hi
>
> Is there any way to pass variables into MySQL statements for execution? I m
> using the DBI package. Thanks!

I think the problem has more to do with the join function

> Heres my snippet and it doesnt work.
>                 dbconnect();
>                 prepare the query for execution
>                 my ($sql01) = join "select description from table where host=", 
> "$abc;";

>perldoc -f join
    join EXPR,LIST
            Joins the separate strings of LIST into a single string with
            fields separated by the value of EXPR, and returns that new
            string. Example:

                $rec = join(':', $login,$passwd,$uid,$gid,$gcos,$home,$shell);

            Beware that unlike "split", "join" doesn't take a pattern as its
            first argument. Compare "split".

You didn't mention what results you got when you tested this.  You should have 
received an error on the line above, since  "$abc;" is a scalar rather than a list.  
If it were in parentheses, with one more element:
my $abc = "First element ";
my $defg = " the rest";
my $sql01 = join "select description from table where host=", ("$abc;", $defg);
print "$sql01\n";

The results would be something like:
First element select description from table where host= the rest

Is that the effect you were looking for?

You probably only need a simple concatenation:

my $sql01 = "select description from table where host=" . "$abc;";

or an implicit concatenation [which you have already done by adding the semicolon at 
the end of the SQL statement]:

my $sql01 = "select description from table where host=$abc;";

Also, you notice I removed the parentheses around $sql01?  That is because join 
returns a scalar--a single value--while the parentheses put the expected return value 
into list context.

Basically, you have the array-to-scalar funnel turned the wrong way here.

Joseph


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

Reply via email to