Re: [Q] Dates in PRO*C

From: Tim Smith <tssmith_at_netcom.com>
Date: Sat, 31 Dec 1994 02:25:17 GMT
Message-ID: <tssmithD1nLE6.I4D_at_netcom.com>


dedgar_at_fearless.csi.nb.ca (Dale Edgar) writes:
>I can't seem to get dates in or out of a table in PRO*C, although NUMBERS,
>VARCHARS etc all work ok.
 

>How (ie what type) do you declare your normal C variables so that the
>SELECT statement can place the retrived Oracle DATE variable in it. Can
>time_t be used for this?

Oracle always converts data, where at all possible, to/from the type of the host (C) variable you are using. So if you declare a 9 character host variable

char my_date[9];

and SELECT into it, you will get your date info. Of course, if you are using a non-default format mask in your select statement, you might have to declare a longer character array to get all the info.

Something that many people do not know is that you can get the internal Oracle date format into a 7 byte array by using the Pro*C TYPE (or VAR) statement, or, more complicatedly, by using dynamic SQL Method 4.

It's the Pro*C equivalent of doing something like SELECT DUMP(SYSDATE) FROM DUAL in SQL*Plus.

--Tim (tssmith_at_oracle.com) Received on Sat Dec 31 1994 - 03:25:17 CET

Original text of this message