Re: Question2: Informix 4GL Programming
Posted in 2000
Topics: Stored Procedures & SPL, Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL
Chih-Ming Kao wrote: > > Dear all, > I have other short questions about Informix 4GL. > Q1: Why the SQLCA.SQLCODE's use is preferable to the STATUS global variable? > > Q2: Don't konw exactly of set_count() do? Is there any example? Yes, in the manual. Look at the DISPLAY ARRAY command. > Q3: Syntax of Case-when, which following is correct (I get confused from the > book) > Case (p-variable) > When "A" .... > When "B" .... > or > Case p-variable > When "A".... > When "B".... Neither. Use: CASE WHEN p_variable = "A" ... WHEN p_variable = "B" ... : END CASE But that's just me. ;-) > Q4: What is MODE ANSI's deault behavior of handling a Run-time error? > The program continues, logging the error to the error log. > or The program is interrupted, issuing a prompt to the user for further > processing dirction.. > or something else. I wasn't aware that the database logging mode determined the behaviour of run-time errors. However, I have never used a MODE ANSI database. > Q5(from the Informix website): When will opening a database, using the > DATABASE statement between the OUTPUT TO REPORT and FINISH REPORT > statements, cause a run-time error? > A) if the report is a one-pass report > =>B) if your report is a two-pass report > C) if your report contains the REPORT TO statement > D) if the report contains the ORDER EXTERNAL BY statement > > What is two-pass report??? It's a report that takes two passes to complete, namely a report that contains an ORDER BY clause. I suggest you get hold of the fine fine 4GL manuals. There are several of them including the fine 4GL By Example. Your certification experience will be all the better for it. :-) Cheers, -- Mark. +----------------------------------------------------------+-----------+ | Mark D. Stock mailto:mdstock@mydas.freeserve.co.uk |//////// /| | http://www.informix.com http://www.informixhandbook.com |///// / //| | http://www.iiug.org +-----------------------------------+//// / ///| | |What year 2000 bug? year 2000 bug? |/// / ////| | |year 2000 bug? year 2000 bug? year |// / /////| | |2000 bug? year 2000 bug? year 1900 |/ ////////| +----------------------+-----------------------------------+-----------+
> > Q3: Syntax of Case-when, which following is correct (I get confused from the book) > > Case (p-variable) > > When "A" .... > > When "B" .... > > or > > Case p-variable > > When "A".... > > When "B".... > Your second guess seems right as said in the manual, but Mark's suggestion will work, too. > > Q4: What is MODE ANSI's deault behavior of handling a Run-time error? > > The program continues, logging the error to the error log. > > or The program is interrupted, issuing a prompt to the user for further > > processing dirction.. or something else. > > I wasn't aware that the database logging mode determined the behaviour > of run-time errors. However, I have never used a MODE ANSI database. I'm using ANSI databases all the time and I never heard of the feature you described. I think the loggin mode will have no effect on error handling, too. Bye, Chris
Mark D. Stock <mdstock@mydas.freeserve.co.uk> wrote in message news:87vf48$54v$1@news.xmission.com... > > Chih-Ming Kao wrote: > > > > Dear all, > > I have other short questions about Informix 4GL. > > Q1: Why the SQLCA.SQLCODE's use is preferable to the STATUS global variable? > > I think that this is because STATUS can be set by other things, and SQLCA.SQLCODE is specific to SQL. But in either case you should check immediately after the relevant SQL statements. > > Q2: Don't konw exactly of set_count() do? Is there any example? > > Yes, in the manual. Look at the DISPLAY ARRAY command. The "4GL by example" book might be handy for Chih-Ming Kao to work through. > > > Q3: Syntax of Case-when, which following is correct (I get confused from the > > book) > > Case (p-variable) > > When "A" .... > > When "B" .... > > or > > Case p-variable > > When "A".... > > When "B".... > > Neither. Use: > > CASE > WHEN p_variable = "A" > ... > WHEN p_variable = "B" > ... > : > END CASE > > But that's just me. ;-) Do you use EXIT CASE and provide an OTHERWISE clause habitually? I have trouble persuading people to do this. > > Q4: What is MODE ANSI's deault behavior of handling a Run-time error? > > The program continues, logging the error to the error log. > > or The program is interrupted, issuing a prompt to the user for further > > processing dirction.. > > or something else. > > I wasn't aware that the database logging mode determined the behaviour > of run-time errors. However, I have never used a MODE ANSI database. Perhaps checking the manual on WHENEVER ERROR compiler directives would be useful for the original poster? (I've never used MODE ANSI either). I would say that it's best to control the behaviour explicitly (WHENEVER ERROR STOP or CONTINUE or CALL <whatever>) but without the manuals here I can't say honestly if ANSI databases alter the behaviour of 4GL programs in this respect. <snipped> -- Andrew Pearson - un animal avec beaucoup de fonctions interactives. Parlez et riez ensemble. Il connait 800 mots et bruits. Réagit à la lumière et au bruit. Ses mouvements sont très réalistes! Version anglaise.
I have only recently started using triggers and stored procedures, and I found that in the 4GL program the values of SQLCA.SQLCODE is from the last SQL stmnt executed, so if your SQL stmnt triggers a trigger which executes some SQL the status returned is for that SQL rather than for the SQL in the program. I'd have thought this would act more like a local variable, it appears to be acting as per a global. I'm still playing with this but, what's the implication for an insert into a table with a serial column, when the 4GL program examines the SQLCA record to get the serial number generated by the insert will it get the right one? -- --------------------------------------- Tony Flaherty aef@mfs.misys.co.uk Analyst Programmer Misys Financial Systems All statements and opinions are my own, Misys don't pay me enough to have opinions on their behalf . Andrew Pearson wrote in message <38a46da4@news.vo.lu>... > >Mark D. Stock <mdstock@mydas.freeserve.co.uk> wrote in message >news:87vf48$54v$1@news.xmission.com... >> >> Chih-Ming Kao wrote: >> > >> > Dear all, >> > I have other short questions about Informix 4GL. >> > Q1: Why the SQLCA.SQLCODE's use is preferable to the STATUS global >variable? >> > > >I think that this is because STATUS can be set by other things, and >SQLCA.SQLCODE is specific to SQL. But in either case you should check >immediately after the relevant SQL statements. > >> > Q2: Don't konw exactly of set_count() do? Is there any example? >> >> Yes, in the manual. Look at the DISPLAY ARRAY command. >The "4GL by example" book might be handy for Chih-Ming Kao to work >through. >> >> > Q3: Syntax of Case-when, which following is correct (I get >confused from the >> > book) >> > Case (p-variable) >> > When "A" .... >> > When "B" .... >> > or >> > Case p-variable >> > When "A".... >> > When "B".... >> >> Neither. Use: >> >> CASE >> WHEN p_variable = "A" >> ... >> WHEN p_variable = "B" >> ... >> : >> END CASE >> >> But that's just me. ;-) > >Do you use EXIT CASE and provide an OTHERWISE clause habitually? I >have trouble persuading people to do this. > >> > Q4: What is MODE ANSI's deault behavior of handling a Run-time >error? >> > The program continues, logging the error to the error log. >> > or The program is interrupted, issuing a prompt to the user >for further >> > processing dirction.. >> > or something else. >> >> I wasn't aware that the database logging mode determined the >behaviour >> of run-time errors. However, I have never used a MODE ANSI database. > >Perhaps checking the manual on WHENEVER ERROR compiler directives >would be useful for the original poster? (I've never used MODE ANSI >either). I would say that it's best to control the behaviour >explicitly (WHENEVER ERROR STOP or CONTINUE or CALL <whatever>) but >without the manuals here I can't say honestly if ANSI databases alter >the behaviour of 4GL programs in this respect. > ><snipped> > > >-- >Andrew Pearson - un animal avec beaucoup de fonctions interactives. >Parlez et riez ensemble. Il connait 800 mots et bruits. Réagit à la >lumière et au bruit. Ses mouvements sont très réalistes! Version >anglaise. >
Tony Flaherty <aef@mfs.misys.co.uk> a écrit dans le message
news:950539584.21993.2.nnrp-12.c1ed1f69@news.demon.co.uk...
> I have only recently started using triggers and stored procedures,
and I
> found that in the 4GL program the values of SQLCA.SQLCODE is from
the last
> SQL stmnt executed, so if your SQL stmnt triggers a trigger which
executes
> some SQL the status returned is for that SQL rather than for the SQL
in the
> program. I'd have thought this would act more like a local
variable, it
> appears to be acting as per a global.
>
> I'm still playing with this but, what's the implication for an
insert into a> table with a serial column, when the 4GL program examines the SQLCA
record
> to get the serial number generated by the insert will it get the
right one?
>
Yeesh you got me there. I really don't know the details of the
behaviour of SQLCA here... if you need some standard way to insert
rows or get serials back (to avoid the 4GL code having to know which
tables have triggers and which don't) would it possible to do the
inserts via SPs which would use dbinfo() to get the serial and pass it
back to the calling program?
>
> --
> ---------------------------------------
> Tony Flaherty aef@mfs.misys.co.uk
> Analyst Programmer
> Misys Financial Systems
> All statements and opinions are my own,
> Misys don't pay me enough to have opinions
> on their behalf
--
Andrew Pearson - un animal avec beaucoup de fonctions interactives.
Parlez et riez ensemble. Il connait 800 mots et bruits. Réagit à la
lumière et au bruit. Ses mouvements sont très réalistes! Version
anglaise.
> > I'm still playing with this but, what's the implication for an
> insert into a table with a serial column, when the 4GL program examines the SQLCA> record to get the serial number generated by the insert will it get the
> right one?
What about writing the inserting function in ESQLC, binding that one to
your
4GL Code and give the original serial column (using sqlca in ESQLC) as a
return parameter to your 4GL-Calling-Function ?
Hth,
Chris