RE: Easy Q: Dummy table?
Posted in 1997
Chad Chervitz wrote:
> I have a need to print CURRENT variables from within a simple SQL file
> being piped to dbaccess. It is so that I can surround a SQL
> statement with two datetime selects to trace how long the SQL
> statement took to run.
>
> Is there a way just to "select CURRENT" so that it gets output along =
with
> the SQL results?
>
> IOW, I'm looking for the equivalent of a tableless
> select in Sybase (i.e., select sysdate()) or a DUMMY table select in
> Oracle (i.e., select to_date("MM-DD-YYY", now) from DUMMY).
>
> Thanks,
> Chad
If you are piping through DB-ACCESS, then you could use this:
cat << EOSQL | dbaccess stores7
!date
SELECT * FROM customer;!date
EOSQL
It works like a charm, and is really really simple. My preference, =
however, is the following:
CREATE PROCEDURE "informix".timestamp( message CHAR(30) )
RETURNING CHAR(80);
DEFINE t_stamp DATETIME YEAR TO SECOND;
DEFINE r_count INTEGER;
DEFINE msg_line CHAR(80);
LET t_stamp =3D CURRENT;
LET r_count =3D DBINFO('sqlca.sqlerrd2');
LET msg_line =3D t_stamp || " " || message || r_count;
RETURN msg_line;
END PROCEDURE
...and having done that once, you can use:
EXECUTE PROCEDURE TIMESTAMP("Some comments about my last SQL...")
Which displays the date-time, your comments, and the number of rows =
processed by the last statement in a reasonably neat format.
HTH,
RET
+------------------------------------------+
| Richard Thomas |
| DBA - Marketing Information Systems |
| Optus Communications |
| email: richard_thomas@yes.optus.com.au |
| Ph: +61 2 9342 7188 |
| "My opinions are my opinions" |
+------------------------------------------+