pro*c job retunn zero value


 
Thread Tools Search this Thread
Top Forums Programming pro*c job retunn zero value
# 1  
Old 08-21-2007
pro*c job retunn zero value

below is the sample pro*c code.

i could print ParmKeyValue as ORG_PATH
and CountryCode as HK, but the below query returns 0 records,
but when i hard code the value, it records records
Code:
  SELECT nvl(rtrim(value), ' ')
--                              INTO :OrgFilepath
                              FROM ccsp_sysparm_tbl
                             WHERE parmkey = 'ORG_PATH'
                               AND country = 'HK'
VALUE
====
/prd/ccsp/hk/upload


please help on this.

      SELECT nvl(rtrim(value), ' ')
                              INTO :OrgFilepath
                              FROM ccsp_sysparm_tbl
                              WHERE parmkey = ltrim(rtrim(:ParmKeyValue))
                              AND country = ltrim(rtrim(:CountryCode));[/B][/B][/B]



#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "ccspGlobals.h"
#include <sqlca.h>

EXEC SQL BEGIN DECLARE SECTION;
varchar OrgFilepath[132];
varchar filepath[150];
varchar CountryCode[2+1];
varchar SerInfo[9];
varchar ParmKeyValue[999999999];
EXEC SQL END DECLARE SECTION;



int main(int argc, char *argv[])
{

 if (argc < 4)
 {
  fprintf(stdout,"Incorrect argument");
  fflush(stdout);
        fflush(stdout);
        EXEC SQL        SELECT nvl(rtrim(value), ' ')
                              INTO :OrgFilepath
                              FROM ccsp_sysparm_tbl
                              WHERE parmkey = ltrim(rtrim(:ParmKeyValue))
                              AND country = ltrim(rtrim(:CountryCode));
        fprintf(stdout,"%d ret: %d\n",sqlca.sqlerrd[2],sqlca.sqlcode);
        fprintf(stdout,"\n OrgFilepath [%s]",OrgFilepath.arr);
               OrgFilepath.len=strlen(OrgFilepath.arr);
               OrgFilepath.arr[OrgFilepath.len] ='\0';



        fprintf(stdout,"\n OrgFilepath [%s]",OrgFilepath.arr);

       strcpy(filepath.arr,OrgFilepath.arr);
       strcat(filepath.arr,"/");
       strcat(filepath.arr,CountryCode.arr);
       fprintf(stdout,"filepath[%s] orgfilepath[%s]",filepath.arr,OrgFilepath.ar
r);

    if (InfoBusOutput (CountryCode.arr,SerInfo.arr,OrgFilepath.arr,filepath.arr)
 < 0 )
        {
    printf("\n error in writteing in MQ");
  fflush(stdout);
        return (-1);
        }

    printf("\n writtern in MQ");
  fflush(stdout);
}


Last edited by blowtorch; 08-21-2007 at 07:31 PM.. Reason: code tags
# 2  
Old 08-31-2007
set length

did you set the length of ParmKeyValue and CountryCode varchars before using them. Instead of ltrim/rtrim, set the length of the varchar and use it.
Code:
strcpy(ParmKeyValue.arr,"ORG_PATH"); /*Or strncpy */
ParmKeyValue.len=strlen((char *) ParmKeyValue.arr);

And the use it in the query.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Autosys Job: Job did not start

I have submitted an autosys job and force start it. Autosys hit the job 4 times to restart but it did not start and finally I terminate the job. Any idea why the job did not start. Below is the code I executed. 1214 missun0ap /export/home/bzn97r/develop/dswi/jil$ sendevent -E FORCE_STARTJOB... (0 Replies)
Discussion started by: jnrohit2k
0 Replies

2. Shell Programming and Scripting

autosys job configuration for job failure.

We need to configure autosys that when a job fails continously for 3 times, we need to call another job. Is this possible in Autosys, or can anyone advice on the alternative. (2 Replies)
Discussion started by: sangea
2 Replies

3. Shell Programming and Scripting

Script to Start a Job after finding the Old job completed

Hi Experts, I need a script advice to schedule 12 jobs ( SAS Codes execute back ground ). Algorithem: 1. Script checks first job. 2. Finds first job is done; invoke second job. 3. finds second job is done; invoke third job. .. Request you to please assist. (3 Replies)
Discussion started by: Jerald Nathan
3 Replies

4. UNIX for Dummies Questions & Answers

How to insert child job under a box job?

I have this box job and it contains only one job under it which is to load a file. I want to insert a "File Watcher", "Copy File" to it? Have no clue how to do that...any help plzzz... (4 Replies)
Discussion started by: xejatt
4 Replies

5. Shell Programming and Scripting

Job dependent on other job

Hi All I am trying to run one command ie grep but I want it should execute only after the completion of a shell script has finished. eg Following is my script : java -mx64m $JAVA_OPTS -Dant.home=$ANT_HOME -classpath $_CLASSPATH org.apache.tools.ant.Main -verbose -buildfile /opt/bea/wls... (4 Replies)
Discussion started by: pankajkrmishra
4 Replies

6. Solaris

killing a unix job after the job process gets completed

Hi, Thanks in advance. i need to kill a unix background running job after that job process completes. i can kill a job by giving the following unix command kill -9 processid how to kill the job after the current process run gets completed ? Appreciate your valuable help. Thanks... (7 Replies)
Discussion started by: dtazv
7 Replies

7. Programming

Regarding pro*c

Hi i would like learn pro*c,i need suggestion for which book is so worthful for beginners..my idea about pro*c is,using pro*c we can connect our C/C++ source with Oracle...is that correct or enything else.... Thanks in advace Sarwan (1 Reply)
Discussion started by: sarwan
1 Replies

8. Shell Programming and Scripting

killing unix job after the job process completes

Hi, Thanks in advance. i need to kill a unix background running job after that job process completes. i can kill a job by giving the following unix command kill -9 processid how to kill the job after the current process run gets completed ? Appreciate your valuable help. ... (1 Reply)
Discussion started by: dtazv
1 Replies

9. UNIX for Dummies Questions & Answers

domain logon problem - FreeBSD PDC w/ win2k pro and winxp pro

this is the seventh problem i'm having with samba. for some reason, i cannot logon to the domain. i've created user accounts... and i was able to establish a connection between the samba server (my PDC) and my workstations by logging in as "root." however now when i try to logon it gives... (5 Replies)
Discussion started by: xyyz
5 Replies
Login or Register to Ask a Question