Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / Informix Topics / September 2005

Tip: Looking for answers? Try searching our database.

Trouble declaring variables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
wheresjim - 27 Sep 2005 17:34 GMT
I usually use MS SQL Server, but am working on a project where I also
have to integrate with a legacy Informix box.  I do not have write
priveleges to the Informix box, just read only, so I cannot create a
stored procedure.  Basically what I want to do is insert text into my
query results (I know, it would be better to do this in the handling
code on the back end, but I want to see if this can be done).  The code
I use for MSSQL is this:

DECLARE @customstr2 CHAR(4)
SELECT @customstr2 = '.tif'
DECLARE @customstr4 CHAR(40)
SELECT @customstr4 = 'some other text'
SELECT imageid, patid, datecreated, lname, facname, @customstr2 as
customstr2, @customstr4 as customstr4 from imagetable where
imgindex='12345'

I have done some searching and have found that the sql code for
infomrix may look like this, but it doesn't work:

DEFINE CHAR customstr2[4] = ".tif";
DEFINE CHAR customstr4[40] = "some other text";
SELECT imageid, patid, datecreated, lname, facname, customstr2 as
customstr2, customstr4 as customstr4 from imagetable where
imgindex='12345'

Any hints?
Art S. Kagel - 27 Sep 2005 18:47 GMT
You're working too hard:

SELECT imageid, patid, datecreated,lname, facname, '.tif' as customstr2,     
    'some other text' as customstr4
from imagetable
where imgindex = '12345';

Also statement local variables in Informix are only supported in the latest
releases, which your server may not be... (it always helps to post version
information if you can get it: SELECT dbinfo('version','full') from
systables where tabid = 1; )

Art S. Kagel

> I usually use MS SQL Server, but am working on a project where I also
> have to integrate with a legacy Informix box.  I do not have write
[quoted text clipped - 22 lines]
>
> Any hints?
wheresjim - 27 Sep 2005 19:08 GMT
Gahh!

You know it's funny because that's the intuitive way to do this, but it
didn't work when I tried it on MS SQL Server.

Thanks!
Art S. Kagel - 27 Sep 2005 23:07 GMT
> Gahh!
>
> You know it's funny because that's the intuitive way to do this, but it
> didn't work when I tried it on MS SQL Server.

Using SQLServer was your first mistake!  ;-)

Art S. Kagel
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.