NULL TERMINATOR

제품 : PRECOMPILERS
작성날짜 : 1997-06-24
space 가 포함된 char column 을 varchar2 로 변환
=============================================
space 를 제거하기 위해 RTRIM function 을 이용한다.
1) data type 이 varchar2 인 dummy table 을 만든다.
2)insert into dummy select rtrim(char_col) from original_table
을 사용한다.

cvervais wrote:
The null byte at the end of the message is raising the score enough to just cross the spam threshold. Perhaps check with Sun to see if it's possible to disable sending a null at the end of the MILTER data?For inter-operability with sendmail this is something we should be removing. For some reason all other milter data sent by the sendmail client is null terminated except the BODY data so it likely we missed this when developing the libmilter plugin.
I've logged a new bug, feel free to escalate via Sun Support for a backport to MS6.3:
bug #6750733 - "Milter: Extraneous null terminating character at the end of BODY data"
Regards,
Shane.

Similar Messages

  • Quick question about null terminator string!

    Hello,
    I always feel that a char array should end with a "\0".
    But just to clear up something here, if I do:
    char *a[10];
    and I fill out the array with 10 characters, then, should we *always* append the "\0" at the end of this array?
    And if so, should it be appended at a[9] location or a[10] ??? It confuses me a little because since the array is supposed to take 10 characters, then does the compiler save an extra space at the 11th character location for the null terminator string?
    OR
    Is it up to us to make sure we fill the array with up to 9 characters making sure to save the 10th location in the array for the null terminator string?
    So in a nutshell, once we finish up with a char array do we do this:
    a[9] = '\0';
    or this:
    a[10] = '\0';
    I excuse the simple question but this has been haunting me for a while, but thanks for all replies!!!
    r

    Ok, a few misconceptions here.
    I always feel that a char array should end with a "\0".
    This is not strictly true.  This is only true of the data is to be treated as a string.  Often you will use a char array to hold binary data.  Normally such binary data will NOT end in a NUL character.  In fact, most binary data may contain
    NUL characters sprinkled throughout the data.
    char *a[10];
    This is NOT an array of ten characters.  This is an array of ten pointers to characters (or character arrays).  You probably intended
    char a[10];
    You then state
    I fill out the array with 10 characters, then, should we *always* append the "\0" at the end of this array?
    Again, this depends on whether you intend the data to be a string or binary data.  I will assume you mean string from here on out.  For a string, yes you should probably always append a '\0' Of course you don't actually have room for that NUL --
    see the following answer.  (Actually there are some string APIs that let you pass in a number of characters to process and those will work with no terminating NUL, but frankly you are playing with fire when you do that so I would recommend always putting
    the trailing NUL in myself.)
    And if so, should it be appended at a[9] location or a[10]
    The declaration "char a[10]" causes the compiler to reserve *exactly* ten bytes of data for that array.  If you write to location a[10], that is the
    eleventh byte and will cause undefined behavior.  At best you might not notice anything bad.  At worst it could cause any sort of crazy data corruption.  It could easily crash your program.
    You would need to write the NUL character at a[9].   Note that writing NUL at a[9] will overwrite the last byte that you put into that array.
    As a side note here:  This is why you try to always use a proper string class like std::string when using C++ -- it takes care of all of that for you, including growing the string larger if you fill it up.  Then you don't need to worry
    about these pesky details that are easy to get wrong.

  • Quick question about null terminator string in arrays?

    Hello,
    If I do this:
    char volatile xxo_[20];
    memset(xxo_, ' ', 20);
    xxo_[1] = '\0';                                                                             
    Am I not supposed to see the '0' symbolizing the null terminated string in 2nd array location like this:
    xxo_[]= {' ','0',' ',' ',' ',' ',' ',' ',' ',' ' ,' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',} 
    Why am I seeing this?
    xxo_[]= {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' ,' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',} 
    Thanks for all replies!

    Standard debugging paranoia applies.
    Are you running the code you think you are?  Do you need to recompile / rebuild / check your .exe against your source?  Do you just have a corrupt .pdb that needs to be rebuilt?  Nuke your exe and pdbs and start again.
    Try introducing a source code error or something that won't compile to verify that you are running the code you think you are compiling.  And if that works, then alter the program to do something else that you are expecting to work.  For example,
    change the memset ' ' to write an 'x' or something and see if you can observe that in your debugger.
    This is obviously not a standalone reproduction of the problem.  Try to avoid introducing other aspects that might contribute to confusing the issue.  Can you write a simple hello-world-sized program that does just this without all the rest of
    your program?
    char volatile to_[20];
    memset( (void*)to_, ' ', 20 );
    to_[0] = 0;
    Note that without the (void*) this won't compile in Visual C++ because of the
    volatile qualifier.
    What does the disassembly say?  Does the code that was generated logically do what the C code you wrote is intended to do?  Can you generate an assembly listing and examine that for logical flaws?
    Are you building with any kind of optimization settings?  sometimes breakpoints aren't where you think they are in "release mode" or optimized builds because instructions can be reordered and entire blocks of statements may be altered in ways
    that don't affect the final results, but make things a bit mysterious during debugging.
    Can you try a different debugger such as windbg and see if you observe the same thing?

  • Is const jchar * null terminated string in c++?

    hi,
    i read through the complete JNI documentation.
    i searched all possible srcs to know "is const jchar * string returned by method GetStringChars(JString,NULL) to c++ declared in jni.h is NULL terminated or not ?" but i couldn't find it.
    please help me.
    because i am using this const jchar * string directly in my c++ code by just casting it to (const WCHAR *)
    sometimes it is crashing the jvm for no reason sorry! i dont know the reason.

    timberlake1865 wrote:
    i searched all possible srcs to know "is const jchar * string returned by method GetStringChars(JString,NULL) to c++ declared in jni.h is NULL terminated or not ?" but i couldn't find it.No.
    by just casting it to (const WCHAR *)That of course is unlikely to be correct regardless of whether it was null terminated or not.

  • How to distinguish NULL and Empty Strings

    Hi,
    Just to set the context right; I'm an experienced C programmer trying labview for the first time. As such I ran in to a problem being that Labview has no concept of NULL-pointers and more specifically appears to have no concept of the difference between a NULL-string and an empty-string
    I'm trying to make a structure (bundle) of strings (in it's most basic form key-value pairs) which i'd like to (for instance) URI encode in order to send it to a web server. For those who are not familiar with URI encoding; there is a distinguished difference between setting a key to an empty string and setting a key with no value. In C I would use a pointer to an empty string vs a NULL string pointer to symbolize this.
    In essence I need an elegant way to distinguish between a defined but empty string and an undefined string (hmmm this is actually describing the same problem but now in terms of perl).
    Anybody have any pointers (pun not intended) for me ?

    This is a bit depending on the interface you have with your encoder. The whole issue is that LV has no pointers at all (and you will like it, as you will never have any Null-Pointer exeptions and the like).
    Assuming that you use a dll (so the Call Library node).
    Use CString as input -> NULL-Terminated String.
    Use I32 as input and pass 0 -> NULL string.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Converting ASCII text (byte array ending in null) to a String

    Hi all,
    I am trying to convert a null terminated ascii string stored in a byte array to a java String. When I pass the byte array to the String constructor it
    does not detect/interpret the null as a terminator for the ascii string. Is this something I have to manually program in? ie Check for where the null is and then
    pass that subarray of everything before the null to the String constructor?
    example of problem
    //               A   B  C   D   null   F   (note F is junk in the array, and should be ignored since it is after null)
    byte[] asciiArray = { 65, 66, 67, 68, 0,  70 };
    System.out.println(new String(asciiArray, "UTF-8"));
    //this prints ABCD"sqare icon"F

    Why do you expect the null character to terminate the string? If you come from a C or C++ background, you need to understand that java.lang.String is not just a mere character array. It's a full-fledged Java object that knows its length without having any need for null terminator. So Ascii 0 is just another character for String object. To achieve what you want to do, you have to manually loop through the byte array and stop when you encounter a null character.

  • Match Pattern does not function properly when searching for a null character

    I'm using Match Pattern to extract a null terminated string from a response I'm getting from a device on a serial port. The VI is attached and below is a screenshot of the block diagram.
    It works just fine with index set to 0, 1, or 2. When index is 3, I get the output shown below.
    Why is Match Pattern not finding the null character?
    Thanks!
    Solved!
    Go to Solution.
    Attachments:
    Grab Nullterm String.vi ‏15 KB

    I'm a dope, need to remove the wire from the Offset control to the Match Pattern control.
    DUH!

  • Putting a null character in a String?

    Hi,
    I need to send a null character through a nio channel. Specifically, it needs to be decoded from a String into a byte array. Can I append a null character to a String so that getBytes() method will return it? Thanks,
    ranko

    Thanks, I tried that but it doesn't work. I also
    tried appending '\0' and an uninitialized character
    which should by default have a value of a null
    character. I tried creating a String out of a char
    array that has one element containing a null character
    but that did not work either. I guess that since null
    characters end the String, you cannot actually add
    them to the body of the String. Or is there a way?FYI, strings aren't null-terminated in Java.

  • Why does this print a null?

    I have a snippet here that prints one row from a derby DB. The heading row works fine.
    I
                while (!cells[0].isEmpty()) {
                    for (int col = 0; col < colNames.length; col++) //System.out.print(cells[col].remove(0).toString() + "\t");
                        queryResult += cells[col].remove(0).toString() + "\t";
                        //System.out.print(cells[col].remove(0).toString() + "\t");
                    System.out.println("");results to Output window are:
    IDNUM        KANJI        KANA        ROMAJI        ENGLISH       
    null1        &#24859;        &#12354;&#12356;        ai        love    I should mention that the string "queryResult" is passed out as a return value and printed to output (not shown).
    Example 2, I do the same thing with a direct println to Output:
                while (!cells[0].isEmpty()) {
                    for (int col = 0; col < colNames.length; col++) //System.out.print(cells[col].remove(0).toString() + "\t");
                        //queryResult += cells[col].remove(0).toString() + "\t";
                        System.out.print(cells[col].remove(0).toString() + "\t");
                    System.out.println("");Results are:
    IDNUM        KANJI        KANA        ROMAJI        ENGLISH       
    1        &#24859;        &#12354;&#12356;        ai        love       
    nullAgain we get a null, but this time its at the end!
    Running the query in SQL using the Netbeans interface shows no null, nor does examining the table.
    How am I introducing a null in here?
    Thanks

    I don't know, but the results are a little funky. Perhaps the query results contains some control characters, like a carriage return and a null-terminator (\r and \0)? You could check this by not printing the string, but by printing the ASCII code of each individual character.

  • XMLSocket NULL byte generation

    Hi,
    I'm trying to get an external script to communicate with an application instance running on my Flash Interactive Media Server installation.
    I've got the following server side actionscript in my AppStart():
    this.socket = new XMLSocket("test");
    this.socket.onXML = function(object) {
           trace("got xml!");
    this.socket.connect(null, 16005);
    The connection to an open socket on the localhost, port 16005 works fine, but when I try to write some xml to the socket that I accepted the connection on (running on the localhost), I never seem to get the onXML or onData callbacks on the server application instance. One question that I had was regarding the NULL byte. If the FMS application doesn't not receive the NULL byte, does that mean the callback won't happen? If so, can someone tell me how to take something like a Python string and *add* a NULL byte so that the FMS will invoke the proper onXML or onData callback when this data is sent?
    Thanks.

    I can't comment on the Python side, but your assumption is correct that FMS is not delivering the data because it lacks the requisite null termination character.

  • Save null character to excel

    Because MS Excel cells expect null terminated strings, I'm losing data when writing to Excel using active X from LabVIEW. What I am doing is typecasting an array to a string, and storing that string in a single Excel cell. But, if that string has a null character, all data after it is lost. Has anyone overcome this, and if so, how? The reason I want to do this is because my Excel spreadsheet is formatted in the following way
    run1, set1, graph1 array, graph 2 array...graph10array
    run 1, set 2, graph1 array, graph 2 array...graph10array
    run2, set 1, graph1 array, graph 2 array...graph10array
    run n, set n,graph1 array, graph 2 array...graph10array 
    This allows me to search for "run n, set n" and get all the corresponding graph data very easily. Also, unfortunately, using a database is not exactly an option .
    CLA, LabVIEW Versions 2010-2013
    Solved!
    Go to Solution.

    Matt,
    Thanks for your response. The first two are customer driven. Their old format was in a DB and they want to keep that format, but move to excel so they can access other data visually from within Excel. If I was to put the graph stuff in a separate file, i'd then have to map to other files, check to make sure the files are there, etc.
    Encoding and reencoding strings crossed my mind. However, this could potentionally cause "unencoding" of something I don't want to be unencoded. For example, let's say I replace all null characters with a, but then there is an a in the typecasted string which I don't want replaced. It will be replaced anyways. Is there a way around this? I'm thinking maybe do something like replace a null character with the ascii characters NULL. Then use a regex to search and replace. 
    The last one would work and I may just map the data to columns on a different sheet and write all the points.
    Matt W wrote:
    Here's some ideas
    Option1: Don't use excel use tdms instead, combine run and set into the group names, and put the graph arrays into channels, this should be much faster, and easier to deal with 
    Option2: Is there a reason a self contained database wouldn't work. Like the SQLite API for LabVIEW
    Option3: Reencode your strings so they don't contain \0, then unencode them when you read them.
    Option4: Change your format (each sample from the graphs goes into it's on cell)
    CLA, LabVIEW Versions 2010-2013

  • Best way to append null bytes to a byte array?

    I have a fixed length byte array and need to add two null bytes to its end. I have an implementation that I wrote to do this, though I was wondering whether someone could improve on what I have:
    public byte[] appendNullBytes( byte[] bytes ) {
       byte[] copyBytes = new byte[bytes.length+2];
       System.arraycopy(bytes, 0, copyBytes, 0, bytes.length);
       copyBytes[copyBytes.length-1] = 0;
       copyBytes[copyBytes.length-2] = 0;
       return copyBytes
    }

    ajmasx wrote:
    jverd wrote:
    ajmasx wrote:
    jverd wrote:
    Those aren't null bytes, they're zero bytes. A bytes can never have the value null in Java.I was using the term null interchangeably with 'zero', Which is not generally applicable in Java.Well it all depends what you are doing:
    - A null is a zero value.Not in general in Java. Null is null and zero is zero.
    - char c = '\0' defines a null character.Yes, that's the only use of "null" for primitive types.
    - A null pointer is where the address is zero and not pointing to some location in memory.Nope. A null pointer is simply one that doesn't point to any value. Nothing in the spec says it's zero.
    - A null reference is more or less the same thing (there are certain difference in the details).Nope. A null pointer and null reference in Java are the same thing.
    - A null terminated string is one where null defines the end of the string.This does not exist in Java. As the above smartass pointed out, you can put the null character at the end of a String, but that character is part of the String, not a terminator.
    >
    If you are dealing with files and other types of I/O then this concept most certainly exists. Not in Java.
    Just because you are limiting yourself to high-level use of Java, does not mean they aren't present in Java.The fact that null is precisely defined in the JLS and does not include these things means they aren't present in Java.

  • Read to a Null Char?

    Hello Java Forum,
    I read in a char szText[256] is there a way to stop reading at the null char?
    I don't want to read the whole array if I don't have to.
    Thanks

    How else is it going to be done? If there (hypothetically) was a method that read in a null-terminated string, that's what it would have to do if you looked inside it.

  • Copying text to the clipboard in AVDocDidOpen event handler causes Acrobat 9 to crash

    I'm trying to copy the filename of a document to the clipboard in a plugin with my AVDocDidOpen event handler.  It works for the first file opened; however when a second file is opened, Acrobat crashes.  The description in the application event log is: "Faulting application acrobat.exe, version 9.1.0.163, faulting module gdi32.dll, version 5.1.2600.5698, fault address 0x000074cc."
    I've confirmed that the specific WIN32 function that causes this to happen is SetClipboardData(CF_TEXT, hText);  When that line is commented out and remaining code is left unchanged, Adobe doesn't crash.
    Is there an SDK function that I should be using instead of WIN32's SetClipboardData()?  Alternately, are there other SDK functions that I need to call be before or after I call SetClipboardData()
    Bill Erickson

    Leonard,
    I tried it with both "DURING, HANDLER, END_HANDLER" and "try catch," as shown below.  However, it doesn't crash in the event handler; it crashes later, so the HANDLER/catch block is never hit.
    The string that's passed to SetClipboardData() is good, because I'm able to paste it into the filename text box of the print dialog when I try to create the "connector line" PDF.  I also got rid of all the string manipulation and tried to pass a zero-length string to the clipboard but it still crashes.
    Here's the code:
    ACCB1 void ACCB2 CFkDisposition::myAVDocDidOpenCallback(AVDoc doc, Int32 error, void *clientData)
        PDDoc pdDoc = AVDocGetPDDoc(doc);
        char* pURL = ASFileGetURL(PDDocGetFile(annotDataRec->thePDDoc));
        if (pURL)    {
            if (strstr(pURL, "file://") && strstr(pURL, "Reviewed.pdf")) {
                // Opened from file system so copy filename to clipboard for connector line report
                char myURL[1000];
                strcpy(myURL, pURL);
                ASfree(pURL);    // Do this before we allocate a Windows handle just in case Windows messes with this pointer
                pURL = NULL;
                HGLOBAL hText = GlobalAlloc(GMEM_MOVEABLE, 1000);
                if (hText)    {
                    try
                        // Skip path info and go right to filename
                        char *pText = (char *)GlobalLock(hText);
                        char *pWork = strrchr(myURL,'/');
                        if (pWork)    {
                            strcpy(pText, pWork+1);
                        } else {
                            strcpy(pText, myURL);
                        char *pEnd = pText + strlen(pText);    // Get null terminator address
                        // Replace "%20" in filename with " "
                        pWork = strstr(pText, "%20");
                        while (pWork)    {
                            *pWork = ' ';
                            memmove(pWork+1, pWork+3, (pEnd - (pWork+2)));
                            pWork = strstr(pText, "%20");
                        // Append a new file extension
                        pWork = strstr(pText, ".pdf");
                        *pWork = 0;    // truncate the string before ".pdf"
                        strcat(pWork,".Connectors.pdf");
                        GlobalUnlock(hText);     // Must do this BEFORE SetClipboardData()
                        // Write it to the clipboard
                        OpenClipboard(NULL);
                        EmptyClipboard();
                        SetClipboardData(CF_TEXT, hText);     // Here's the culprit
                        CloseClipboard();
                        GlobalFree(hText);
                    } catch (char * str) {
                        AVAlertNote(str);
            if (pURL)
                ASfree(pURL);

  • Calling SQL function in SQL query fails

    Hi There,
    I am trying to execute INSERT INTO XML_DATA (NAME, DATASIZE, DATA) VALUES (?,?,XMLType('?')) using ODBC C
    SQLBindParameter APIs.
    If I execute the INSERT INTO XML_DATA (NAME, DATASIZE, DATA) VALUES (?,?,XMLType('<name>milind</name>')) works fine.
    Can anybody please help me out here?
    Thanks,
    Milind
    /* blob.c
    * The following C code demonstrates how to read an input file, piecewise
    * (in chunks), and write it into a BLOB or LONG RAW column in the database.
    * It then reads that BLOB or LONG RAW data, piecewise, from the database
    * and writes it back to the OS as an output file that you specify.
    * Enter the following SQL statement via SQL*Plus to create the table
    * 'images_data' for use with this sample. Make sure you log into
    * Oracle as a user appropriate for running this example.
    * For BLOB, use the following table:
    * CREATE TABLE images_data (
    * name VARCHAR2(100),
    * imagesize NUMBER,
    * image BLOB);
    * For LONG RAW, use the following table:
    * CREATE TABLE images_data (
    * name VARCHAR2(100),
    * imagesize NUMBER,
    * image LONG RAW);
    * Change the connection information at the beginning of the procedure OpenOra
    * to your DSN, username and password.
    * To run this program, open a Command Prompt and use the following syntax:
    * Syntax: <program_name> <infile_name> <outfile_name>
    * Example call: C:\> blob my_photo.jpg copy_of_my_photo.jpg
    #include "stdafx.h"
    #include <stdio.h>
    #include <io.h>
    #ifndef NUTC
    #include <windows.h>
    #endif
    #include <sql.h>
    #include <sqlext.h>
    #ifdef NUTC
    #include <sys/types.h>
    #include <sys/stat.h>
    #endif
    * Global variables
    HENV hOdbcEnv = NULL; /* Environment handle */
    HDBC hDbConn = NULL; /* Connection handle */
    int sr; /* Return value */
    #define BUFSIZE 32020 /* Chunksize */
    * Connect routine
    void OpenOra()
    char szDSN[] = "XY10g2"; /* Data Source Name (DSN) */
    char szUID[] = "odbc1"; /* Username */
    char szAUTH[] = "pdmuser"; /* Password */
    * Allocate environment handle
    sr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hOdbcEnv);
    if (sr != SQL_SUCCESS)
    printf ("Error allocating environment handle\n");
    * Set the ODBC Version
    sr = SQLSetEnvAttr(hOdbcEnv, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER);
    if (sr != SQL_SUCCESS)
    printf ("Error setting ODBC version\n");
    * Allocate connection handle
    sr = SQLAllocHandle (SQL_HANDLE_DBC, hOdbcEnv, &hDbConn);
    if (sr != SQL_SUCCESS)
    printf ("Error allocating connection handle\n");
    * Connect
    sr = SQLConnect(hDbConn, (UCHAR *)szDSN, SQL_NTS,(UCHAR *)szUID, SQL_NTS, (UCHAR *)szAUTH, SQL_NTS);
    if (sr != SQL_SUCCESS)
    printf("Connection failed\n");
    * Disconnect routine
    void CloseOra()
    * Disconnect and free connection and environment handles
    sr = SQLDisconnect(hDbConn);
    if (hDbConn != SQL_NULL_HANDLE)
    SQLFreeHandle(SQL_HANDLE_DBC, hDbConn);
    if (hOdbcEnv != SQL_NULL_HANDLE)
    SQLFreeHandle(SQL_HANDLE_ENV, hOdbcEnv);
    * Read INFILE into the database and read data back out and save as OUTFILE.
    void readCertImage(char read_name, long filesize, char write_name)
    SQLCHAR iSqlCmd[300] = "INSERT INTO XML_DATA (NAME, DATASIZE, DATA) VALUES (?,?,XMLType('?'))";
    SQLCHAR iSqlCmd1[300] = "SELECT DATA FROM XML_DATA WHERE NAME = ?";
    FILE ifile, ofile; /* File pointers */
    time_t startTime, endTime;
    time_t startTimeIO, endTimeIO;
    int IOtime = 0;
    unsigned char buf[BUFSIZE]; /* Buffer to hold chunk */
    unsigned char buf1[BUFSIZE]; /* Buffer to hold chunk */
    SQLINTEGER type[3]; /* Type of data */
    SQLPOINTER pToken; /* Which column is piecewise */
    HSTMT hstmt = NULL; /* Statement handle */
    long i; /* Byte Counter */
    long count; /* Piecewise Counter */
    long rd; /* Amount to read */
    * Log on
    OpenOra();
    ifile = fopen(read_name, "r"); /* Open the file for reading in ASCII mode */
    * Allocate statement handle
    sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
    if (sr != SQL_SUCCESS)
    printf("Error allocating statement handle\n");
    * Prepare insert statement
    sr = SQLPrepare(hstmt, iSqlCmd, SQL_NTS);
    if (sr != SQL_SUCCESS)
    printf("Error preparing insert statement\n");
    * Bind Parameters
    /* Name of BLOB */
    sr = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0,read_name, strlen(read_name), &type[0]);
    if (sr != SQL_SUCCESS)
    printf("Error binding name variable\n");
    /* Size of BLOB */
    sr = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_NUMERIC, 0, 0,&filesize, 0, &type[1]);
    if (sr != SQL_SUCCESS)
    printf("Error binding length variable\n");
    * As this will be a piecewise insert do not need to pass a buffer here.
    * Instead pass the parameter number for identification purposes.
    /* BLOB data */
    sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)3, 0, &type[2]);
    if (sr != SQL_SUCCESS)
    printf("Error binding data variable\n");
    type[0] = SQL_NTS; /* Null terminated string */
    type[1] = 0; /* Ignored for numbers */
    type[2] = SQL_LEN_DATA_AT_EXEC(filesize); /* Data at execution time */
    time( &startTime );
    * Execute the insert
    sr = SQLExecute(hstmt);
    if (sr == SQL_NEED_DATA)
    printf("\nAbout to perform piecewise insert of data\n\n");
    else if (sr != SQL_SUCCESS)
    printf("Error executing insert statement\n");
    * Retrieve the pointer to the buffer containing the address
    * of the location where the source BLOB will be sent
    sr = SQLParamData(hstmt, &pToken);
    if (sr != SQL_NEED_DATA)
    printf("Error - no piecewise operations required\n");
    * Write the data in BUFSIZE chunks
    i = 0; /* Initialize bytes inserted
    count = 0; /* Initialize pieces/chunks inserted */
    do
    count++; /* Increment chunk number */
    * If remaining bytes to read is greater than BUFSIZE,
    * read another BUFSIZE chunk. Otherwise, read remaining
    * chunk of bytes (which will be less than BUFSIZE)
    if (filesize - i >= BUFSIZE)
    rd = BUFSIZE;
    else
    rd = (filesize - i);
    printf("%5ld:%10ld - About to write %ld bytes to the database\n",count,i,rd);
    * Reads one rd sized chunk of data into buffer from source file (BLOB)
    time( &startTimeIO );
    fread(buf, rd, 1, ifile);
    time( &endTimeIO );
    IOtime = IOtime + (endTimeIO - startTimeIO);
    * Sends the contents of the buffer to the ODBC driver
    SQLPutData(hstmt, buf, rd);
    /* Recalculate total bytes sent */
    if (filesize - i >= BUFSIZE)
    i+= BUFSIZE;
    else
    i+= (filesize - i);
    } while (i < filesize);
    /* Check to see if all data has been sent */
    sr = SQLParamData(hstmt, &pToken);
    if (sr == SQL_NEED_DATA)
    printf("Error - still need data\n");
    printf("%5ld:%10ld - Done writing data\n",++count,i);
    time( &endTime );
    printf("BLOB Write completed StartTime: %d, EndTime: %d, IOTime: %d in seconds.\n", endTime, startTime, IOtime);
    printf("BLOB Write completed in %d seconds.\n", (endTime - startTime) - IOtime);
    fclose(ifile); /* Close the INFILE */
    printf("\nData inserted into database\n\n");
    * Now read the data back. Reuse the previous statement handle.
    SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
    sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
    if (sr != SQL_SUCCESS)
    printf("Error allocating statement handle\n");
    * Prepare select statement, bind variable and execute
    sr = SQLPrepare(hstmt, iSqlCmd1, SQL_NTS);
    if (sr != SQL_SUCCESS)
    printf("Error preparing select statement\n");
    sr = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, read_name, strlen(read_name), &type[0]);
    if (sr != SQL_SUCCESS)
    printf("Error binding name variable\n");
    time( &startTime );
    sr = SQLExecute(hstmt);
    if (sr != SQL_SUCCESS)
    printf ("Error executing insert statement\n");
    ofile = fopen(write_name, "w"); /* Open the file for writing in ASCII mode */
    sr = SQLFetch(hstmt);
    if (sr != SQL_SUCCESS)
    printf ("Error fetching data\n");
    * Read the data in BUFSIZE chunks.
    i = 0; /* Initialize bytes inserted */
    count = 0; /* Initialize pieces/chunks inserted */
    memset(buf, NULL, BUFSIZE);
    do
    * Retrieve a BUFSIZE chunk of data into the buffer
    sr = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, BUFSIZE, &type[2]);
    if (sr == SQL_ERROR)
    printf("Error fetching data\n");
    break;
    time( &startTimeIO );
    count++; /* Increment chunk number */
    /* Determine if this is a full chunk or the last chunk */
    if (filesize - i >= BUFSIZE)
    printf("%5ld:%10ld - About to write %ld bytes to file\n",count,i,BUFSIZE);
    fwrite(buf, BUFSIZE, 1, ofile); /* Write BUFSIZE chunk to file */
    else
    printf("%5ld:%10ld - About to write %ld bytes to file\n",count,i,filesize-i);
    fwrite(buf, filesize-i, 1, ofile); /* Write remaining chunk to file */
    time( &endTimeIO );
    IOtime = IOtime + (endTimeIO - startTimeIO);
    /* Recalculate total bytes retrieved */
    if (filesize - i >= BUFSIZE)
    i+= BUFSIZE;
    else
    i+= (filesize - i);
    } while (sr == SQL_SUCCESS_WITH_INFO);
    printf("%5ld:%10ld - Done writing file\n",++count,i);
    time( &endTime );
    printf("BLOB Read completed StartTime: %d, EndTime: %d, IOTime: %d in seconds.\n", endTime, startTime, IOtime);
    printf("BLOB Read completed in %d seconds.\n", (endTime - startTime) - IOtime);
    fclose(ofile); /* Close the OUTFILE */
    printf("\nData written to file\n");
    * Log off
    SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
    CloseOra();
    * Main routine
    void main(argc, argv)
    int argc; /* Number of command line arguments */
    char argv[]; / Array of command line arguments */
    long filesize = 0; /* Size of INFILE */
    FILE ifile; / Pointer to INFILE */
    #ifdef NUTC
    struct stat statbuf; /* Information on a file. */
    #endif
    /* Check for the proper number of command line arguments entered by user */
    if (argc != 3)
    printf("\nCommand line syntax: <program_name> <infile_name> <outfile_name>");
    printf("\n Example call: blob input.exe output.exe\n");
    exit(1);
    /* Open INFILE */
    if( (ifile = fopen(argv[1], "rb" )) == NULL )
    printf( "\nThe file '%s' could not be opened\n",argv[1]);
    exit(1);
    else
    printf( "\nThe file '%s' was opened successfully\n",argv[1]);
    #ifdef NUTC
    /* Determine length of the INFILE */
    if (fstat(fileno(ifile), &statbuf) == 0)
    filesize = statbuf.st_size;
    else
    filesize = 0;
    #else
    filesize = filelength(fileno(ifile));
    #endif
    printf( "The file is %d bytes long\n",filesize);
    /* Close INFILE */
    fclose(ifile);
    /* Insert and retrieve BLOB */
    readCertImage(argv[1], filesize, argv[2]);
    }

    During binding, strings are generally skipped. As such, you should first try replacing XMLType('?') with XMLType(?). You don't need to specify '?' because the system knows the proper type from your SQLBindParameter call.
    Also, you should try replacing:
    sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)3, 0, &type[2]);
    with
    sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)buf, BUFSIZE, &type[2]);

Maybe you are looking for

  • Po message getting triggered twice

    Hi, recently we have upgraded SRM5.0 to SRM7.0 with ECC6.0 EHP pack4 . we have a problem when we create PO from SRM shopping cart in ECC.PO message is getting triggered twice. Th issue was not there before upgrade. Can anyone please help me resolving

  • Problem with Run_Product.. FRM-41211  Oracle reports team pls respond

    Hi, I am calling run_product built in my form 3 times on when button pressed trigger I am getting error FRM-41211 Integration Error: SSL Failure running another product.. how to solve this problem.. In help it is given check with Run_Product ... but

  • Premiere Pro CC Crashes when loading videos

    Every time I load an MP4 video my PPCC crashes. According to the logs, it's this file where the fault occurs: devenum.dll. It happens the moment I either try to load a file by either click or drag-n-drop. I'm running only 4GB RAM on Windows 7, and I

  • Hide button when page is printed

    I have a page with a button on. How can I hide the button when I print the page on paper? reidarT

  • Hibernate

    Hello .I am Raj...can anybody solve the follwing program please Write a program to list all students in the database with an even student number. Retrieve only objects from the database with an even student number (by the appropriate HQL query) and t