Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Sergey E. Volkov — — source: Informix-list mailing list archive (1991-1998)
Jens Schacherl <js@jschacherl.de> ''''' '
''''''''':3A103CB5.70F29E32@jschacherl.de...
> Hello all,
>
> I've read all postings about this topic I found with deja but still it's
> not working.
> I'm trying to reset the SERIAL column 'lfdnr' after deleting a
> consecutive number of rows using this code:
>
> int d_basiszahlen(xdate* pdtVon)
> {
> EXEC SQL BEGIN DECLARE SECTION;
> date dateVon;
> long max_nr;
> EXEC SQL END DECLARE SECTION;
> int rc;
>
> dateVon = XDateToLong(pdtVon);
>
> EXEC SQL DELETE FROM basiszahlen WHERE gueltig_von = :dateVon;
> rc = sqlca.sqlcode;
>
> if (rc == 0)
> {
> EXEC SQL SELECT MAX(lfdnr) INTO :max_nr FROM basiszahlen;
> rc = sqlca.sqlcode;
>
> if (rc == 0)
> {
> max_nr++;
> EXEC SQL ALTER TABLE basiszahlen MODIFY lfdnr SERIAL(max_nr);
This must looks like:
EXEC SQL ALTER TABLE basiszahlen MODIFY lfdnr SERIAL(:max_nr);
( But if lfdnr is primary key, and there are any table references to it, all
constraints will be dropped )
Sergey
> rc = sqlca.sqlcode;
> }
> }
>
> return rc;
> }
>
>
> The ESQL compiler gives me a syntax error in the ALTER TABLE statement:
> Error -33051: esqlc - Syntax error on identifier or symbol 'max_nr'.
>
> All examples I found were about modifying the serial column using a
> constant serial value but not a variable. Also I've read that 'serial'
> is a separate data type but I cannot declare 'max_nr' as serial or
> SERIAL (gives another syntax error).
>
> adTHANKSvance, Jens
↪ replying to Sergey E. Volkov
Jens Schacherl — — source: Informix-list mailing list archive (1991-1998)
"Sergey E. Volkov" schrieb:
>
>> [..]
> > EXEC SQL ALTER TABLE basiszahlen MODIFY lfdnr SERIAL(max_nr);
>
> This must looks like:
>
> EXEC SQL ALTER TABLE basiszahlen MODIFY lfdnr SERIAL(:max_nr);
>
> ( But if lfdnr is primary key, and there are any table references to it, all
> constraints will be dropped )
>
> Sergey
>
Thanks Sergey for your answer. I should have mentioned that I've tried
this before (since it's the normal syntax) but this gives me the error:
Error -33051: esqlc - Syntax error on identifier or symbol ':'.
It seems to me that I can only use constant numbers here (this compiles
w/o error).
Any other ideas?
Jens
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.