Subject RE: [firebird-php] Duplicate numbers
Author Alan McDonald
> Alan McDonald wrote:
>
> >>"INSERT INTO TICKET ( TICKET_ID, TICKET_REF, TICKET_NO, OFFICE, ROOM,
> >>STAFF_ID, INIT_ID, CALLER_ID, APPLET )
> >>VALUES ( $ticid, 'NOW', (SELECT COALESCE(MAX(TICKET_NO)+1, 1) FROM
> >>CURRENT_DAY
> >>WHERE OFFICE = $office AND TICKET_NO BETWEEN 0 AND 9999),
> >>$office, 0, 0, 0, 0, ' ' )";
> >
> > I only see 2 place holders and 6 parameters? am I reading this
> right? I also
> > only see 9 fields with 3 values.
> > something ismissing here $office wold be used for $ticid - no?
>
> It's the PHP ;)
> $ticid and $office are replaced before it goes to Firebird :)
> 9 fields, 9 values, one of which is calculated from the list of todays
> tickets.
>

I'm still fascinated by the syntax
but my parameters are always replaced in the same order as the variables
provided
to put it my way:

"INSERT INTO TICKET ( TICKET_ID, TICKET_REF, TICKET_NO, OFFICE, ROOM,
STAFF_ID, INIT_ID, CALLER_ID, APPLET )
VALUES ( (SELECT COALESCE(MAX(TICKET_NO)+1, 1) FROM CURRENT_DAY, ?, ?, ?, ?,
?, ?, ?, ?
WHERE OFFICE = ? AND TICKET_NO BETWEEN 0 AND 9999), 0, 0, 0, 0, 0, 0, ' ',
0, 0)";

one of these zeros is 'NOW',

9 fields 9 placeholders, 9 parameters in that order.
I can't read from your syntax what goes where ubt it's intersting to know
how it works?
Alan