Re: CONSTRUCT bytes
Posted in 1992
In article <8954@emory.mathcs.emory.edu> jbaker@lexington-emh2.army.mil ("John Baker, Lex-Blue Grass Army Depot") writes: >X-Informix-List-ID: <list.1202> > >How many bytes does the Construct clause (version 4.0) require for the variable >that will hold the selection criteria ("char-variable" in the syntax below)? > > CONSTRUCT char-variable ON column-list FROM field-list > >I'm using CONSTRUCT on just one field of a screen form. The screen field is >char(4) and its corresponding table column is char(1). The "char-variable" >I am using to hold the entered parameters is char(80) in length. I ran the >program and tried several different combinations of search parameters. I >received error #1132 "The destination string of the CONSTRUCT statement is >not large enough." in the situations listed below. > >Granted no one would normally enter 21 or more pipe symbols or the combination >of letters & pipes that I tried, but I used these combinations in an effort to >determine just how many bytes CONSTRUCT needs. This is because earlier, I >defined my "char-variable" field to be char(12), and when I entered A|B|C on >the screen form, I got error #1132. Surely twelve bytes would be enough to >hold A|B|C, but CONSTRUCT says otherwise!!! > >Remember: The char-variable that I'm using with CONSTRUCT is defined in my >4GL program to be char(80) in length. > >So the question is why can't I enter up to 80 characters????? You are building a SELECT statement. "WHERE touchedcolname (= OR MATCHES) VALUE Ie: construct is ADDING the column name to the where clause you are building, plus the applicable relational operator, and finally the value. >And why are there differences between entering just letters vs pipes??? How >many bytes do pipes take up? The pipe symbol is an OR operator for the select statement.. You must keep in mind that the CONSTRUCT statement dynamicly adds column names to your actual select stmt. It also regulates operators for = and MATCHES, and permits comparison operators (><) etc. This means the program is performing some "magic" you are not accounting for here. Now for real fun try searching for a literal "*" char :-( DEFINE WBUF CHAR(512) DEFINE FRMBUF CHAR(120) DEFINE sql_stmt CHAR(650) CONSTRUCT BY NAME WBUF ON table1.col1, table1.col2, table1.col3, table2.col1, table2.col2 LET FRMBUF = "table1" IF WBUF MATCHES "*table2.col1*" OR WBUF MATCHES "*table2.col2*" THEN LET FRMBUF = FRMBUF CLIPPED, ", table2" LET WBUF = WBUF CLIPPED, " AND table2.keycol = table1.keycol" END IF LET sql_stmt = "SELECT DISTINCT keycol FROM ", FRMBUF CLIPPED, " WHERE ", WBUF CLIPPED The above is a two table construct. I use this to illustrate the concept that the construct ADDS things to your variable you may NOT be aware of. In the above, IF a field from table2 was touched during the construct, it includes something on the order of, touchedcolname (= OR MATCHES) VALUE, and if the field was NOT touched, it includes NOTHING about that field. Using a pipe symbol would then read like.. touchedcolname (= OR MATCHES) VALUE 1 OR touchedcolname (= OR MATCHES) VALUE 2. Simply put, make PLENTY of room in the variable. Don "making 4gl perform unnatural acts for cash" Bolton Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post Additional lines of text so this *&^$%*@ BRAIN-DEAD mailer won't reject post