Problem selecting a column from a view in Sybase using DBI/DBD

Problem selecting a column from a view in Sybase using DBI/DBD

Post by James F. Hranic » Sat, 21 Oct 2000 04:00:00



I've created a view in Sybase similar to the following:

tab1                            view
(                                 (
        col0            --->      col0
        col1            --->      col1
        col2            --->      col2
        date_added
        date_removed
)

tab2
(
        col0
        colA            --->      colA
        date_added      --->         last_updated    
        date_removed
)                                 )

The corresponding SQL would be

create view
(
        col0,
        col1,
        col2,
        colA,
        last_updated
) as
 select a.col0,
        a.col1,
        a.col2,
        b.colA,
        b.date_added
 from   tab1 a,
        tab2 b
 where
        a.col0 = b.col0 and
        a.date_removed is null and
        b.date_removed is null

Essentially, all the columns in the view match the name of the column
in the table they originally came from except "date_added" , which
has been renamed to "last_updated" .

Here are the results from the following queries:

        select col0, col1, last_updated from view
                sqsh    : returns expected results
                DBI/DBD : returns *nothing*

        select col0, col1, colA from view
                sqsh    : returns expected results
                DBI/DBD : returns expected results

When I create another view and keep the name "date_added" instead
of renaming it, here are the following results:

        select col0, col1, date_removed from view
                sqsh    : returns expected results
                DBI/DBD : returns expected results

        select col0, col1, colA from view
                sqsh    : returns expected results
                DBI/DBD : returns expected results

It is only when the column names from table to view differ,
and then only when using DBI/DBD, that I get no results returned.

Does anyone know what's going on?

----------------------------------------------------------------------
| Jim Hranicky, Senior SysAdmin                   UF/CISE Department |
| E314D CSE Building                            Phone (352) 392-1499 |

----------------------------------------------------------------------
         -  Encryption: its use by criminals is far less  -
         - frightening than its banishment by governments -
                      - Vote for Privacy -
--
----------------------------------------------------------------------
| Jim Hranicky, Senior SysAdmin                   UF/CISE Department |
| E314D CSE Building                            Phone (352) 392-1499 |

 
 
 

Problem selecting a column from a view in Sybase using DBI/DBD

Post by Michael Pepple » Sat, 21 Oct 2000 04:00:00


[ description of view definition snipped ]

Quote:> It is only when the column names from table to view differ,
> and then only when using DBI/DBD, that I get no results returned.

> Does anyone know what's going on?

No, but run the perl script with DBI->trace(3), and check the output.
If you don't understand the output you can send it to me...

Michael
--
Michael Peppler         -||-  Data Migrations Inc.

Int. Sybase User Group  -||-  http://www.isug.com


 
 
 

Problem selecting a column from a view in Sybase using DBI/DBD

Post by Larry Coo » Sat, 21 Oct 2000 04:00:00



> I've created a view in Sybase similar to the following:

> tab1                            view
> (                                 (
>         col0            --->         col0
>         col1            --->         col1
>         col2            --->         col2
>         date_added
>         date_removed
> )

> tab2
> (
>         col0
>         colA            --->         colA
>         date_added      --->         last_updated
>         date_removed
> )                                 )

> The corresponding SQL would be

> create view
> (
>         col0,
>         col1,
>         col2,
>         colA,
>         last_updated
> ) as
>  select a.col0,
>         a.col1,
>         a.col2,
>         b.colA,
>         b.date_added
>  from   tab1 a,
>         tab2 b
>  where
>         a.col0 = b.col0 and
>         a.date_removed is null and
>         b.date_removed is null

Shouldn't it be...

create view my_view_name as
select a.col0,
       a.col1,
       a.col2,
       b.colA,
       last_updated = b.date_added
from   tab1 a, tab2 b
where  a.col0 = b.col0
and    a.date_removed is null
and    b.date_removed is null

Quote:> Essentially, all the columns in the view match the name of the column
> in the table they originally came from except "date_added" , which
> has been renamed to "last_updated" .

> Here are the results from the following queries:

(snip)

Is this your problem, or is it that the view is created
coreectly in your database, and you just typed it wrong
in your post?

Larry Coon
University of California


 
 
 

1. Perl Sybase DBD/DBI problem.

Hi,

I'm trying to execute stored procedure which uses print command to
generate output.
I'm using a construction like this:

{
    my ($sth) = $dbh->prepare($sql_stat);
    my ($rv) = $sth->execute();
    do {
            while($data = $sth->fetchrow_arrayref()) {

            }
    } while($sth->{syb_more_results});
    $sth->finish();


Procedure certainly works fine on it's own, being executed from isql or
another procedures.

Is there any way in DBD/DBI to overcome this problem or is the only
solution to use Sybperl?

Thanks

2. Configuration problems

3. problems connecting to a ms sql server (using DBD-Sybase and sybase libs)

4. DB Mmaintenance Plan Stop Working

5. DBI, DBD::Sybase

6. Don't miss this years Maintenance Event!

7. kerberos auth and login to database using perl DBD/DBI

8. Green technology - hypertext?

9. wierd problems with DBI/DBD::pg?

10. Perl 5.003, DBI, DBD and Oracle problem

11. Installing DBD - Oracle - 0.6 Problems (DBI)

12. Oracle and Perl DBI/DBD on Linux Problem