The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
variable substitution in ksh aoussenko Shell Programming and Scripting 3 06-11-2009 03:17 PM
Sed variable substitution when variable constructed of a directory path alrinno Shell Programming and Scripting 2 07-11-2008 02:24 PM
KSH variable substitution tipsy Shell Programming and Scripting 5 08-14-2006 05:07 PM
awk variable substitution apalex UNIX for Dummies Questions & Answers 1 09-10-2004 06:02 PM
Substitution in a variable spragueg UNIX for Advanced & Expert Users 3 10-18-2001 09:14 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-05-2009
Mary Antony Mary Antony is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 1
DB variable substitution in Pro*C

Hi,

I have declared two DB variables as
EXEC SQL BEGIN DECLARE SECTION;
static long db_sample_date_val;
static int db_sample_time_val;
EXEC SQL END DECLARE SECTION;

and I'm using these varibales in my code as
EXEC SQL
INSERT
INTO sample_tbl(sample_dt)
VALUES (TO_DATE(:db_sample_date_val::db_sample_time_val, 'J:SSSSS'));

I have to use colon infornt of the DB variable for value substitution. But when I execute this query using Pro*C,
I'm getting an SQL Exception because of the two colon being used.

I also tried TO_DATE(':db_sample_date_val::db_sample_time_val', 'J:SSSSS') and
TO_DATE(':db_sample_date_val':':db_sample_time_val', 'J:SSSSS'). But I still get the Exception.

Can anyone help me with this piece of code ?

Thanks in advance!!!
Mary Antony
  #2 (permalink)  
Old 10-05-2009
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
to_date takes a char
Code:
EXEC SQL BEGIN DECLARE SECTION;
static long db_sample_date_val=0;
static int db_sample_time_val=0;
static char something[32]={0x0};
EXEC SQL END DECLARE SECTION;

sprintf(something, "%d:%05d", db_sample_date_val, db_sample_time_val)
EXEC SQL
   INSERT
INTO sample_tbl(sample_dt)
VALUES (TO_DATE(:something, 'J:SSSSS'));
Also, do not neglect checking for sqlca.sqlcode < 0 after every sql operation.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:24 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0