INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...These forums are an excellent source and example of the way people can help each other..."
Geography
Where in the world do Tek-Tips members come from?
|
617: A blob data type must be supplied within this context
|
|
I want to load text data from the memory not from the file. It's a sensitive info like credit card that I don't want to put in the file and then load. The way I was thinking is create a tmp table with a text data type field within the program. Insert the text in that text datatype field. Then assign it to the text data type variagle by seleting from that temp table after I massage it the way I wanted.
Following is my test code using a sample database and a database table. How can I insert the text datatype variable into the table without doing the load?
DATABASE stores7
define txtblob text
########################################################################## main ##########################################################################
locate txtblob in memory
insert into catalog values (0,302,"HRO","this is a test for anu for text value ", '','varchar value test')
=>>>617: A blob data type must be supplied within this context
select cat_descr into txtblob from catalog where rowid = 10074
end main |
|
Tek-Tips Forums is Member Supported. Click Here to donate.
|
olded (Programmer) |
27 Jun 07 15:05 |
You probably don't want to hear this, but if you plan on locating blob types in memory (instead of a file) in a 4GL program, then you must maniuplate the blob with callable-"C"-functions-from-4GL. This means writing your own or copying others. Unfortunately, this is a read example and not an insert. It's available at the Informix user's group website, http://www.iiug.org under 'software repository', under 4GL. There's more info in a tar download: (look for more discussion at the end of the code): CODE/* ** blob_to_char.c - copy an I4GL TEXT type to an I4GL CHAR type ** Copyright (C) 1993,2003 David A. Snyder ** ** This library is free software; you can redistribute it and/or ** modify it under the terms of the GNU Library General Public ** License as published by the Free Software Foundation; version ** 2 of the License. ** ** This library is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** Library General Public License for more details. ** ** You should have received a copy of the GNU Library General Public ** License along with this library; if not, write to the Free ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <locator.h> #include <string.h>
blob_to_char(arg) int arg; { loc_t *blobp; short charsize, n; char s1[513];
if (arg != 2) fgl_fatal("blob_to_char.c", 30, -1318);
popshort(&charsize); poplocator(&blobp);
if (charsize < 1) charsize = 1; if (charsize > 512) charsize = 512; n = (charsize < blobp->loc_size) ? charsize : blobp->loc_size; strncpy(s1, blobp->loc_buffer, n); s1[n] = '\0'; cr_to_spc(s1);
pushquote(s1, n); return(1); }
cr_to_spc(s) char *s; { while (*s) *s++ = (*s == '\n') ? ' ' : *s; }
1) There's more info about writing these kind of functions in the Informix ESQL (embedded C) manuals, but I haven't looked at it in years. 2) Years ago, Informix provided a very useful paper called "The Taming of the Blob" by Debbie Johnson. I have a hard copy, but I haven't been able to find it on the net. Maybe I can get you a copy. It's for beginners. 3) Years ago, I created a 4GL password process that required inserting a TEXT blob. I have the callable "C" function somewhere. If you want it, I'll dig it up. |
|
Thanks olded, Inserting text blob by calling c function - if you have it yes please send along.
Same problem - trying different option Details on my problem. I have to manually create an xml string about 80000 chars and pass it to "c" function to do the https post using CURL. I tried generating xml through IDS but too complicated for me.
1) trying to pass a whole array of strings from 4gl and then concatenate in C. =========== define resp char(100) xml_str array[5] of char(80)
main
let xml_str[1] = "this is string 1" let xml_str[2] = "this is string 2"
let resp = c_str_append(xml_str[]) =>> Couldn't do this ================
2) Send array of string one by one calling the C function each time and tried to concatenate in C. Hoping the concatenated string will be in memory. But I am losing the reference. xml_str array[5] of char(80)
4gl --------- main
let xml_str[1] = "this is string 1" let xml_str[2] = "this is string 2"
let resp = c_str_append(xml_str[1]) let resp =c_str_append(xml_str[2])
end main --------------- C program char* xmldata=""; char* xmlstring="";
int c_str_append(count) int count; { popquote(xmlstring, 100);
printf("\nxmlstring is = %s", xmlstring); printf("\nxmldata = %s\n", xmldata);
strcat(xmlstring,xmldata);
printf("\nconcatenate data = %s", xmlstring);
return (1); }
Any help would be appreciate. |
|
|
olded (Programmer) |
10 Jul 07 19:20 |
(I'll split my reply into two parts). First, I was unable to find my insert function. I'll post a version of Debbie Johnson's code from "The Taming of the Blob": CODE#include <stdio.h> #include <math.h> #include <string.h> #include <fcntl.h> #include </usr/informix/incl/tools/locator.h>
/* Determine if there is any data stored in the blob. Return TRUE if it is null and FALSE if it isn not NULL Arguments: pos: length of passed string s: string that must be appended or inserted a: blob, text type */
int blob_append(int n) {
loc_t *a; char s[257]; int pos, len, needed;
popint(&pos); popquote(s, sizeof(s)); poplocator(&a); s[pos]='\0';
if((len = strlen(s)) == 0) return 0;
if(a->loc_indicator == -1) needed = len; else needed = a->loc_size + len;
if(a->loc_bufsize < needed) { if(a->loc_buffer == 0) a->loc_buffer = malloc(needed); else a->loc_buffer = realloc(a->loc_buffer, needed);
if(a->loc_buffer == 0) { pushint(1); return(1); } a->loc_bufsize = needed; }
if(a->loc_indicator == -1) { memcpy(a->loc_buffer, s, len); a->loc_size = len; a->loc_indicator = 0; } else { memcpy(a->loc_buffer + a->loc_size, s, len); a->loc_size += len; }
a->loc_currdata_p = a->loc_buffer + a->loc_size; pushint(0); return(1); } In the above code, Johnson isn't type casting the malloc/realloc "C" functions nor is she performing any error checking. You might consider implementing more standard code for production. Here is a test 4GL program calling the "C" function: CODEMAIN
DEFINE string CHAR(50), ret_code INTEGER, len INTEGER, testblob TEXT
LOCATE testblob IN MEMORY
LET string = "this is string 1" LET len = length(string) call blob_append(testblob, string, len) returning ret_code display testblob display "" display "" LET string = "now, append string 2" LET len = length(string) call blob_append(testblob, string, len) returning ret_code display testblob LET string = "another string of variable length" LET len = length(string) call blob_append(testblob, string, len) returning ret_code display testblob
free testblob END MAIN |
|
|
olded (Programmer) |
10 Jul 07 19:40 |
Frankly, I don't know what this means:
>>Details on my problem. I have to manually create an xml >>string about 80000 chars and pass it to "c" function to do the https post using CURL.
I can tell you that your "C" function will never work. You are using uninitialized character pointers:
char* xmldata=""; char* xmlstring="";
These pointers have to either point to character strings defined in your "C" function or dynamically assign space using "C" function malloc.
Finally, concerning my above post. Johnson's blob_append only supports a string of 257 characters:
char s[257];
Increase the size if it doesn't fit you requirements.
|
|
|
 |
|