David Heller
|
| Posted: 07/15/2001, 2:34 PM |
|
Unlike the workarounds ( see "changing type listbox" thread above ) for
MSAccess.
MySql and others have a reliable way to get the just inserted record number
for auto-numbered columns.
I have used the code below, executed immediately after the insert, then pass
the returned value in a form, an http link, or a "location" statement.
$query = "select LAST_INSERT_ID()";
$mysql_result = mysql_query($query, $mysql_link);
$row = mysql_fetch_row($mysql_result);
$id_number = $row[0];
We use this approach to deal with new accounts, or
topic/sub-topic/record-pointer problems.
* In the INSERT form you select a major choice (or new account data).
--- we create the NEW record, get the insert_id and pass it for use in
the update.
--- generate an UPDATE form with "matching" sub-topics or other data.
I haven't been able to find the correct "CC" syntax to code this. Any help
appreciated.
Dave Heller
|
|
|
 |
Alexey Alexapolsky
|
| Posted: 07/16/2001, 1:40 AM |
|
It's not fully CC issue.
I call it an underlying issue. And CC can only do things
that underlying technologies can do. Here are my suggestions
concerning this question.
1) MS access is supposed to be a single user database ,
that's possibly why it doesn't still have a function as last_insert_id.
If you're heavly relying on such thing as last insert id it's strogly
recommended to use some really multi-user DB.
2) If you still considering using MS Access in multi-user environment ,
then the only way in CC is to call "selext max(id) from table" right after
insert ,
in "After insert" event and save this variable in a session for later use.
It's reported by ASP-Access users that this is more or less safe way to
get last id , and those who've used and and I talked with don't report any
errors that happen when another user inserts a record right before your call
to max(id). Stil , that's a kind of risk you pay for using such kind of DB.
--
Alex
CC
David Heller <dave@no_spam.leftcoastart.net> wrote in message
news:9it288$lro$1@news.codecharge.com...
> Unlike the workarounds ( see "changing type listbox" thread above ) for
> MSAccess.
>
> MySql and others have a reliable way to get the just inserted record
number
> for auto-numbered columns.
>
> I have used the code below, executed immediately after the insert, then
pass
> the returned value in a form, an http link, or a "location" statement.
>
> $query = "select LAST_INSERT_ID()";
> $mysql_result = mysql_query($query, $mysql_link);
> $row = mysql_fetch_row($mysql_result);
> $id_number = $row[0];
>
> We use this approach to deal with new accounts, or
> topic/sub-topic/record-pointer problems.
>
> * In the INSERT form you select a major choice (or new account data).
> --- we create the NEW record, get the insert_id and pass it for use in
> the update.
> --- generate an UPDATE form with "matching" sub-topics or other data.
>
> I haven't been able to find the correct "CC" syntax to code this. Any
help
> appreciated.
>
>
> Dave Heller
>
>
>
>
|
|
|
 |
Alexey Alexapolsky
|
| Posted: 07/16/2001, 2:09 AM |
|
Looks like I got wrong your question.
Reanswering now.
Didi you mean answer must be like this ?
In "After insert event" place the following code
query = "select LAST_INSERT_ID()";
$mysql_result = mysql_query($query, $mysql_link);
$row = mysql_fetch_row($mysql_result);
$id_number = $row[0];
set_session("last_id",$id_number);
header("Location: your_secondary_form.php")'
So , we've got the id , and got linked to another form by redirect.
The form the will be shown at your_secondary_form should have variable
id_number
in it's "Form properties"/Input tab (there you must set variable type to
"session") so that to show up the correct record.
You can also pass id through header as "get" parameter.
If anything is still unclear let me know or better submit request to
support.codecharge.com
for a more detailed consideration , preferrably with some ccs file of yours
, for a better demonstration.
--
Alex
CC Support
David Heller <dave@no_spam.leftcoastart.net> wrote in message
news:9it288$lro$1@news.codecharge.com...
> Unlike the workarounds ( see "changing type listbox" thread above ) for
> MSAccess.
>
> MySql and others have a reliable way to get the just inserted record
number
> for auto-numbered columns.
>
> I have used the code below, executed immediately after the insert, then
pass
> the returned value in a form, an http link, or a "location" statement.
>
> $query = "select LAST_INSERT_ID()";
> $mysql_result = mysql_query($query, $mysql_link);
> $row = mysql_fetch_row($mysql_result);
> $id_number = $row[0];
>
> We use this approach to deal with new accounts, or
> topic/sub-topic/record-pointer problems.
>
> * In the INSERT form you select a major choice (or new account data).
> --- we create the NEW record, get the insert_id and pass it for use in
> the update.
> --- generate an UPDATE form with "matching" sub-topics or other data.
>
> I haven't been able to find the correct "CC" syntax to code this. Any
help
> appreciated.
>
>
> Dave Heller
>
>
>
>
|
|
|
 |
|