DBI module weirdness

K

Kurt M. Dresner

I am trying to do the following with a PostgreSQL database.

------------
sql = <<ENDSQLCOMMAND
SELECT s.id, cwajga_magic_number((cwajga_product(r.rating) ^ (1 / 1)), MAX(lastplay.lastheard), 5) as magic
INTO TEMP magic_order
FROM song AS s LEFT OUTER JOIN rating AS r ON s.id = r.song LEFT OUTER JOIN last play ON lastplay.song = s.id
WHERE r.name ILIKE 'omega697'
GROUP BY s.id;

SELECT SUM(magic) as total INTO TEMP magic_tot FROM magic_order;

SELECT id, 100.0*magic/total as percent
FROM magic_order, magic_tot
order by percent;
ENDSQLCOMMAND

handle.execute(sql)
------------

I get the following error:

DBI::programmingError: ERROR: parser: parse error at or near "1" at
character 66

The thing is, when I enter this exact command into the psql command-line
program, it works fine.

cwajga_magic_number and cwajga_product are both plpython functions that
have been put into the database.

Am I doing something wrong? Or is there something wrong with DBI?

-Kurt
 
M

Michael Neumann

I am trying to do the following with a PostgreSQL database.

------------
sql = <<ENDSQLCOMMAND
SELECT s.id, cwajga_magic_number((cwajga_product(r.rating) ^ (1 / 1)), MAX(lastplay.lastheard), 5) as magic
INTO TEMP magic_order
FROM song AS s LEFT OUTER JOIN rating AS r ON s.id = r.song LEFT OUTER JOIN last play ON lastplay.song = s.id
WHERE r.name ILIKE 'omega697'
GROUP BY s.id;

SELECT SUM(magic) as total INTO TEMP magic_tot FROM magic_order;

SELECT id, 100.0*magic/total as percent
FROM magic_order, magic_tot
order by percent;
ENDSQLCOMMAND

handle.execute(sql)
------------

I get the following error:

DBI::programmingError: ERROR: parser: parse error at or near "1" at
character 66

The thing is, when I enter this exact command into the psql command-line
program, it works fine.

cwajga_magic_number and cwajga_product are both plpython functions that
have been put into the database.

Am I doing something wrong? Or is there something wrong with DBI?

Please try version 0.0.20.
There was a bug in the "SQL parser" in previous versions.


Regards,

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,109
Messages
2,570,671
Members
47,262
Latest member
EffiePju4

Latest Threads

Top