Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with fetchrow_array returning list instead of array (PERL,POSTGRES)

Status
Not open for further replies.

mlibeson

Programmer
Mar 6, 2002
311
US
I am using code that works correctly when getting data from MSSQL, but does not work correctly when I get data from POSTGRES on a MAC.

I am running my code on the latest MAC OS X Yosemite.
PERL version 5.18
DBI version 1.631
DBD-Pg version 3.4.2
Postgres version 9.3.5

the line of code is:

while (@results = $sth->fetchrow_array) {

$results[0] should contain 'DOE' and $results[1] should contain 'JOHN' like it does for MSSQL

What I get instead for Postgres is $results[0] = '("DOE","JOHN")' and $results[1] contains nothing

Is there something special I need to do for Postgres?


Michael Libeson
 
I figured it out. PostgreSQL can be so picky.

I modified my program to generate a SQL query based on a FUNCTION (Stored Procedure) in Postgres to call the routine in this format:

SELECT * FROM Function();

Instead of the one giving me a problem like:

SELECT Function();


The " * FROM " changed the result format for the fetchrow_array.


Michael Libeson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top