Re: 4GL questions
Posted in 1993
}From: gau@mendel.sing.ingr.com (Gau Lai Choon)
}Subject: 4GL questions
}Date: Wed, 27 Oct 93 10:17:39 SIN
}X-Informix-List-Id: <list.3004>
}
} Hi Everybody,
}
} I am currently developing some customization using 4GL and being a first
} timer in 4GL, I was hit all over -left right centre... Managed to overcome
} many of them, I was still taken back by some, hope that some of you wise
} people can enlighten me ...
}
} Question 1
} ----------
} Is there a built-in function to convert an alphabet to it's ascii
} representation and vice visa. (eq. /065 to-from 'A')
LET x = ASCII(34)
but not vice versa
} Question 2
} ----------
} I wrote a simple function to convert a string (eq 12:00:00) to a
} datetime datatype in hr to second. The function compile and run fine in
} r4gl but was unable to compile in i4gl.
}
} Attached function for ref :
} FUNCTION ch2time(c0)
} {
} This is a function to transfer CHAR(6) string to TIME datatype
} ------------------------------------------------------------------
} Input: CH(6) string with hhmmss
} Output: TIME with hh:mm:ss
} }
} DEFINE t DATETIME HOUR TO SECOND,
} c0 CHAR(6),
} c1 CHAR(8)
}
} LET c1 = c0[1,2],":",c0[3,4],":",c0[5,6]
} LET t = TIME(c1)
} RETURN t
} END FUNCTION
Well, congratulations. You've just found an inconsistency between the C4GL
and FGLPC compilers, dammit. For some reason, FGLPC accepts time as a
built in function which can take arguments, but C4GL (correctly, in my
view, but I'll have to confirm this) expects TIME to be a keyword
representing the current time.
The conversion should be written:
LET t = EXTEND(c1, HOUR TO SECOND)
This works in both versions of the language.
} Question 3
} ----------
} I have a very huge database with many tables. When I try to backup using
} the "dbexport", the utiltiy always terminate with the error message
}
} " Can Not open database table (informix.syscolumns) "
}
} And when I try using the "dbschema" utility, creation of the sql file was
} fine but when I try to download it to another machine, I got the following
} error :
}
} " Cannot open system catalog (syscolumns)
} ISAM error: too many files open "
}
} I can overcome this by breaking up my sql file into smaller files before
} loading.
}
} What limits have I hit ???
} I was not able to backup my data from the tables at this point of time beside
} doing a bulk load.
Whenever you ask a question like this, people cannot do better than guess
unless you let them know which machine you are using, and which versions of
the engines and tools (I4GL and SE) you are using.
Additionally, neither DBSCHEMA nor DBEXPORT is intended for use as a backup
utility. They *can* also be used for backup (or, at least, help with
it), but you have to know exactly what you're up to. Specifically, if you
are using OnLine, you shouldn't even think about using them for routine
backups, and for SE, you must make sure that no-one else is using the
database at all while the backup occurs, as if you don't, the data will
change part way through the backup, which means that the restored database
is self-inconsistent -- and that's typically worse than not having a backup
at all!
} QUESTION 4
} ----------
} I'm using ANSI mode for my database. I have a problem that table cannot be
} recognised by another user beside the dba although connect permission has
} been grant. If my database is created by the user "mis" , then inorder
} that user "beta" can recognise the table, I have to precede the tablename
} with "mis".
} How about my 4GL code ,especially the forms ??? This is my biggest
} problem now...
Don't use ANSI mode unless you absolutely have to. It's a royal pain in
the posterior. Amongst the gotchas, a new one I found yesterday (well
documented though, I4GL Ref Man Vol 2 p7-243) is that when compiled against
a MODE ANSI database, I4GL defaults the WHENEVER ERROR condition to
CONTINUE, not STOP! Uggh.
If you do have to have a MODE ANSI database, then anytime any user runs any
SELECT (or DELETE, INSERT, UPDATE, ...) statement, you must refer to any
tables that the user does not own with "owner".table. Since your program
will be used by more than one user (I assume), that means every table will
have to be qualified by the owner name, everywhere. And as if that wasn't
bad enough, you must get the owner name right. That means you have to be
the ultimate in disciplined when it comes to building the database. Every
table should be owned by the same, adminstrative, login -- your "mis"
sounds about right. And your code will need to use "mis".table everywhere.
Remember that when you upgrade to 5.00 or above, if you omit the quotes
(mis.table), the engine (to be ANSI compliant) will case-convert the owner
name to MIS.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>