Glen,
1) I tried your suggestion about [$moid] but that gives me an error
DBD::DB2::db prepare failed: [IBM][CLI Driver][DB2/6000] SQL0104N  An
unexpected token "SELECT [$moid]" was found following "BEGIN-OF-STATEMENT".
Expected tokens may include:  "<space>".  SQLSTATE=42601
2) I cannot change the $ in the object name since it is generated/required
by another software (A PDM system called VPM). Also since shell scripts
work without any problems it is not easy to justify the change.

Thanks
Sachin



                                                                                       
                                               
                    "Accardo,                                                          
                                               
                    Glen"                To:     "'[EMAIL PROTECTED]'" 
<[EMAIL PROTECTED]>, "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]> 
                    <Glen_Accardo        cc:                                           
                                               
                    @bmc.com>            Subject:     RE: SELECT \$moid  FROM xyz.abc  
                                               
                                                                                       
                                               
                    02/25/2002                                                         
                                               
                    04:01 PM                                                           
                                               
                                                                                       
                                               
                                                                                       
                                               





 It's been a while since I've used DB2, but for most databases '$' is
 not a particularly good character to use in an object name, especially
 as the first character.  For example, the SQL Server 2000 documentation
 says the following for object names:

           The first character must be one of the following:
             - A letter as defined by the Unicode Standard 2.0.
             - The underscore (_), "at" sign (@), or number sign (#).

           Subsequent characters can be:
             - Letters as defined in the Unicode Standard 2.0.
             - Decimal numbers from either Basic Latin or other national
scripts.
             - The "at" sign, dollar sign ($), number sign, or underscore

 All of which means that moid$ is fine, but $moid isn't.  Now, most
databases
 also allow you to bend the rules a bit if you add quotes and brackets and
 such to your SQL.  One solution would be to write the query as:

           SELECT [$moid]  FROM [catenv].[cattabl]

 and see if it works.  Another possibility, and one that may do you more
 good in the long run, is to remove the $ from the column name.

 glen



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 25, 2002 2:36 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: SELECT \$moid FROM xyz.abc



Sorry ! Maybe I was not being clear in my original question.
$moid is the name of the column in the database. It is not being set to
some value in my program.

>>>>>snip>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..

#!/usr/bin/perl -w

use DBI;

my ($dbh, $sth, @rows);
open (WRT_FH , ">/tmp/lst.txt") || die "Cannot create list file: $!";

 $dbh = DBI->connect( "dbi:DB2:VPMDB" , "User" , "passwd" , {
     PrintError => 0,
     RaiseError => 1
     } )  ;
 $sth = $dbh->prepare( 'SELECT $moid  FROM catenv.cattabl');

 $sth->execute();

 while (@rows = $sth->fetchrow() ){

     foreach (@rows){

     print WRT_FH "$_\t";

     }
      print WRT_FH "\n";
 }

 $dbh->disconnect();

close(WRT_FH);

exit;

>>>>>snip>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.




                    [EMAIL PROTECTED]

                    com                  To:     [EMAIL PROTECTED]

                                         cc:     (bcc: Sachin
Raje/HRA/COP/HONDA)
                    02/25/02             Subject:     SELECT \$moid  FROM
xyz.abc
                    12:36 PM









Hello,
Using DBI for DB2.
The column $moid has &char(8)  stored

When I use command line and connect to the database and type: db2 SELECT
\$moid  FROM xyz.abc
I get the required results eg:  40199EAFXXX

When i use DBI-> connect and then try "SELECT \$moid FROM xyz.abc"
I get the binary data stored in that column.

How can I get the referenced data.

Thanks
Sachin





**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
**********************************************************************

Reply via email to