NewbieQ: DBI query with $strings 
Author Message
 NewbieQ: DBI query with $strings

Hi,

if this is a FAQ, pls RTFM me with detailed info where to find the
answer 8-)

I'm running postgresql and try to do something like:

select relname from pg_class where (relkind='r') and (relname ~ '^$var')
  order by relname

$var has proper value but the select doesn't find any record.
When replacing $var with a value, it works.
I read s'thing about variables in SQL handles have to be declaired, but
can't find any information on.

Second question: where to find a list of reg expressions accepted by SQL?

Sorry for the anon post due to i'm under spam attack.

Thx, Jens



Thu, 27 Jan 2005 20:35:28 GMT  
 NewbieQ: DBI query with $strings

Quote:

> Hi,

> if this is a FAQ, pls RTFM me with detailed info where to find the
> answer 8-)

> I'm running postgresql and try to do something like:

> select relname from pg_class where (relkind='r') and (relname ~ '^$var')
>   order by relname

You want double quotes around ^$var to get interpolation.

--
Cheers
Ron Savage

http://savage.net.au/index.html



Fri, 28 Jan 2005 16:53:06 GMT  
 NewbieQ: DBI query with $strings

Quote:

> You want double quotes around ^$var to get interpolation.

I tried all kind of quotes. Double quotes end in an error message:

my $select="ava1_xy";
.
.
SELECT relname FROM pg_class where (relkind='r') and
(relname~"^$select") order by relname;

ERROR:  Attribute 'ava1_xy' not found

Thx, Jens



Sat, 29 Jan 2005 07:17:10 GMT  
 NewbieQ: DBI query with $strings
Try -
$sql="select relname from pg_class where (relkind='r') and (relname ~
'^$var')
   order by relname"

But, you may have to double up special characters within the sql statement.


Quote:
> Hi,

> if this is a FAQ, pls RTFM me with detailed info where to find the
> answer 8-)

> I'm running postgresql and try to do something like:

> select relname from pg_class where (relkind='r') and (relname ~ '^$var')
>   order by relname

> $var has proper value but the select doesn't find any record.
> When replacing $var with a value, it works.
> I read s'thing about variables in SQL handles have to be declaired, but
> can't find any information on.

> Second question: where to find a list of reg expressions accepted by SQL?

> Sorry for the anon post due to i'm under spam attack.

> Thx, Jens



Sun, 06 Feb 2005 05:11:01 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Quoting a query string for DBI?

2. DBI:CSV queries return only 1 row

3. DBI:CSV queries return only 1 row

4. Dynamic Queries with DBI

5. DBI query results question...

6. DBI query does not fetch all data

7. DBI query to Informix takes 20sec to end

8. DBI and MS Access Query problem

9. DBI Query - counting rows

10. DBI and MA Access Query problem

11. Killing a query with DBI/DBD

12. DBI - Creating an array of results from a query

 

 
Powered by phpBB® Forum Software