Re: HELP with embedded SQL (pro*C)

From: Kevin Neel <k-neel_at_nwu.edu>
Date: 19 Jan 1994 20:16:34 GMT
Message-ID: <2hk4f2$jl1_at_anaxagoras.ils.nwu.edu>


In article <CJvxEq.Lyv_at_butch.lmsc.lockheed.com> Robert Sechrest Ext 21856,
sechrest_at_zuni.litc.lockheed.com writes:
>Matthew J Carr (carr_at_ist.flinders.edu.au) wrote:
>: What I want to do is query two tables to get the day and time of a
 given
>tutorial( in the tut_booking table) and the starting time from
 another(tutorial table)
>
>: EXEC SQL create view time_ckeck as
>: select distinct t_day,t_time,start_date
>: from tut_booking,tutorial
>: where stud_id = reg_num
>: and tut_booking.tcode = tutorial.tcode; -- join condition
>
>I could be wrong here, but I seem to recall that ALL DDL statements are
 off-limits in
>embedded SQL. If this is the case, it would be mentioned near the place
in the manual

Actually, DDL statements are perfectly legal in Pro*C, though I would use them there
sparingly (note: they are illegal in SQL*Forms 2.3-style triggers). I certainly
wouldn
the view
definition is dynamically calculated (in fact, I have worked on systems with code that
does exactly that) or if the Pro*C program is used to setup (rather than manipulate) a
database. A static view really should be created once and used multiple times.
Recreating it for each use has several drawbacks; it can lead to concurrency problems
-- two users running the same program at once can collide, it is costly and potentially
failure-prone to create and drop the view, ...

On the other hand, the use of the view is perfectly reasonable.

As for why you are having troubles, it
relatively easy to find
out. Add error-checking to your program -- use sqlca.sqlcode, ON ERROR GOTO, ... In fact, I ALWAYS check for errors after every SQL statement (or anything else that can
fail, such as I/O), and print a message (including sqlca.sqlerrm[]) if an error is found. Received on Wed Jan 19 1994 - 21:16:34 CET

Original text of this message