AllExperts > Experts 
Search      

Ingres

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Ingres Answers
Question Library

Ask a question about Ingres
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Jean-Pierre Zuate
Expertise
Any questions about database Ingres (owned by Computer Associates then Ingres Corp) : - Ingres 6.4 - OpenINGRES from 1.0 to 2.0 - IngresII from 2.0 to 2.6 - Ingres R3, Ingres 2006 (Open Source version) - All tool around Ingres : ABF, Report Writer, Replicator, OpenROAD (3.5 to 2006), Ingres/NET Ingres/STAR, ...

Experience
16 years of computing experience as :
- AS400 programmer
- AIX / Ingres administrator and developer (OpenROAD and korn shell)
- Ingres DataBase Administrator
- Ingres expert - Data modelisation - ETL - Reporting - Many of Computer Associates sofwares - ITIL / CMDB / Change Management
 
   

You are here:  Experts > Computing/Technology > Databases > Ingres > update with variables

Topic: Ingres



Expert: Jean-Pierre Zuate
Date: 1/26/2006
Subject: update with variables

Question
I'm writing an UPDATE statement where I must include the name of the column which I want to update in a host variable. That works in the left part of the SET clause, but in the right, the program 'reads' the character chain (the name of the column), not its value, as I want.

UPDATE :arr_tablas.tabla                      
SET :w_ref_col= :w_ref_col + :w_maximo
WHERE cod= :w_max_cod  

w_ref_col is a varchar variable and the column is  integer.

Can you give me one idea about this? Thanks.  

Answer
Hello,

I suppose your SQL is in a C programm (embeded SQL) or ABF. If you look in the R3 doc PDF files and search for "sql prepare" string, you'll find what you want, I think.

Also look at sql prepare, describe and so on in the doc. Those SQL order will permit you to execute a query formatted in a variable, so both value and column name can be dynamic.

The variable content is the query Ingres will execute and should look like this :

UPDATE table_name                
SET column_name = column_name + value
WHERE cod= value

where table_name, column_name and value
are provided by the variables
:arr_tablas.tabla, :w_ref_col, :w_maximo and :w_max_cod.

Hope this clear, and hope this help you. Let me know if not.

Cheers,
Jean-Pierre

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.