[AMPL 16098] Adding date when writing table

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[AMPL 16098] Adding date when writing table

Andrea Bustillos
Hello forum people,

I'm using AMPL with Oracle as my database, for this I'm using a .run file to define the AMPL tables and the read commands; the write commands are in my main java class. Whem I've finished solving my problem I write the results in tables in Oracle. Specifically, I want to create a typoe of "log" table in Oracle. In here I want to write a registry for each procedure ampl does, for example, reading or writing a table, or solving a problem. The ellements of the table I want to create are:

Date (including hour) | Message | id_regis

So my questions are the following:
1-. Is there a way to usea AMPL to obtain the current date all into seconds, and write it in my table?
2.- Is there a way to ADD a registry to table instead of rewriting the whole thing?
3.- Is there a way to make the "id_regis" field autoincremental?

Thanks in advance for any response.

Andrea Bustillos.

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16114] Adding date when writing table

AMPL mailing list
1-. Is there a way to usea AMPL to obtain the current date all into seconds, and write it in my table?

You can obtain the current date in seconds with "date('%s');". For instance:
ampl: param time symbolic;
ampl: let time := date('%s');
ampl: display time;
time = '1523191219'
In order to write it to your table you should use this value in a parameter that will be written to the database.

2.- Is there a way to ADD a registry to table instead of rewriting the whole thing?

Did the suggestion presented at https://groups.google.com/d/msg/ampl/Z5e49zqlKmM/RBezeVBPAwAJ not work?

3.- Is there a way to make the "id_regis" field autoincremental?

When creating your table in Oracle you can try defining a column that auto-increments. However, I have noticed that this does not seem to work with MySQL, and that may be the case for Oracle as well. One possible workaround is to create a set to be written to the table that you keep updating before writing to the database so that new rows receive incremental ids.

--
Filipe Brandão
[hidden email]
{#HS:555689666-4590#}
On Fri, Apr 6, 2018 at 12:44 AM UTC, <[hidden email]> wrote:
Hello forum people,

I'm using AMPL with Oracle as my database, for this I'm using a .run file to define the AMPL tables and the read commands; the write commands are in my main java class. Whem I've finished solving my problem I write the results in tables in Oracle. Specifically, I want to create a typoe of "log" table in Oracle. In here I want to write a registry for each procedure ampl does, for example, reading or writing a table, or solving a problem. The ellements of the table I want to create are:

Date (including hour) | Message | id_regis

So my questions are the following:
1-. Is there a way to usea AMPL to obtain the current date all into seconds, and write it in my table?
2.- Is there a way to ADD a registry to table instead of rewriting the whole thing?
3.- Is there a way to make the "id_regis" field autoincremental?

Thanks in advance for any response.

Andrea Bustillos.

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.