Re: Newbie question--isqlperl text blob insert
Posted in 1995
Whenever you issue a command to insert into a table without specifying exactly which columns in the table you want inserted into, ISQL defaults to inserting the first value from your VALUES list into the first column name in the table, the second value from your VALUES list into the secon column name in the table, and so forth. What the error message is saying is that one or more of these default pairings is a mismatch in data type. Your example does not show the contents of the file that you are reading in nor does it give the default order of the column names in the Informix table into which you are inserting, so the exact location of the mismatch cannot be identified. However, the solution is to name explicitly the column names into which values from the VALUES list are to be inserted, e.g.: $insert = &isql_open(<<EOI> || die &isql_code; insert into $table(inv_data) (column_name1, column_name_2, ..., column_name_n) values (?) EOI where column_name_1, etc. are the actual column names from your Informix table listed in exactly the same order as that of the values in the VALUES list (i.e., the same as the order of the elements in @ary). Another solution is to order the elements of @ary in the same order as the default order of column names in the Informix database. Then you don't need explicitly to name the columns in the insert statement. Help this hopes. :-) Richard In article <3qvqg7$2mq@bennett.eng.umd.edu>, mkerry@Glue.umd.edu (Michael Kerry) writes: |> Hello, |> |> I have a question relating to isqlperl v1.2, running on a SPARC10 (SunOS4.1.3). |> Frankly, I'm not sure whether this is a perl question or an Informix |> question, as I'm fairly new to both. |> |> What I am trying to do is insert data from an array (obtained by slurping |> lines of a text file using <> ) into a text blob (a column of |> type TEXT). I gather that to do this in ESQL/C one uses the loc_t |> type...How does one do this in isqlperl? |> |> I, naively, tried something like the following: |> |> # Reading the data into the array @ary |> # |> |> $count = 0; |> open(FILE, "datafile") || die "Can't open file! $!\\n"; |> while(<FILE>) { |> $ary[$count++] = $_; |> } |> |> # prepare cursor to insert @ary into 'mydata' table |> # |> |> $table = 'mydata'; |> $insert = &isql_open(<<EOI) || die $isql_code; |> insert into $table(inv_data) values(?) |> EOI |> |> # insert it |> # |> |> &isql_execute($insert, (@ary)) || die $isql_code; |> |> |> That last line is bad, giving the error |> "-1213 Character to numeric conversion error" |> |> Any and all help would be greatly appreciated! |> |> Thanks in advance, |> -MK |> |> -- |> Michael Kerry |"Why is a raven like a writing-desk?" |> mkerry@eng.umd.edu | -The Mad Hatter |> Institute for Systems Research |"Because the notes for which they are noted |> University of Maryland | are not noted for being musical notes." -Sam Loyd -- Richard Baumann (805) 447-8391 International Clinical Safety AMGEN --------------------------------------------------------------- The opinions expressed herein are strictly those of the author.