I am trying out a Camel route that queries a table (with primary key), generates a CSV based on the query response and stores the CSV file in Azure storage container. After successfully storing the file in Azure, I need to update a flag in the table that was queried initially. For this purpose I am setting the primary key as part of the header, but after the azure endpoint is executed, the header values are getting reset. So I am not able to retrieve the initial header and hence the primary key value which I need. What is the ideal way to store a value that is accessible during the entire route?
from("direct:processPayroll")
.setHeader("payrollId",simple("${body.payrollId}"))
.to("sql:classpath:sql/payroll.sql")
.marshal(csvFormat)
.log("${headers}")
.to("azure-storage-blob://staccount/container?blobName=payroll.csv&operation=uploadBlockBlob")
.log("${headers}")
You can store it in the exchange properties. You can add the value using .setProperty("key","value") and retrieve it using $exchangeProperty("key")
Related
I'm creating a React application where my data has the following structure:
interface BookCase {
id: number;
bookShelves: BookShelf[];
}
interface BookShelf {
id: number;
}
Every bookcase and every bookshelf has an id property. I use this for the key attribute and for locating a bookshelf inside the bookShelves array. The id is generated in the backend by the database (With a BigSerial in PostgreSQL) on save.
I now want to create a new bookcase inside my frontend without immediately saving it to the backend. First I want to work with it, perform some operations on it (e.g. place a book on the shelf), and afterwards send the whole batch of changes with the new entities to the backend where it will then be persisted in the database.
Of course I do not yet have an id, although I need one to work on the bookcases. Should I rewrite my application to also accept null for id (I would prefer not to)? Should I just randomly create an temporary id, possibly having duplicates with the ids already present in the database (or for example use a negative value like -1)? Then I would need to replace all the ids afterwards after it has been saved to the database.
With UUIDs I could generate it on the frontend, but I guess there also has to be a common pattern to work with just incrementing integers as the id.
I do not think there is a clear answer here.
Essentially you have a object-relational mapping and there are various ways to handle it. Entity Framework for example just uses the default for the data type. So if the entity does not exist yet the ID will be 0 and any persisted entities have values starting at 1 so there are no conflicts.
One way i usually handle saving is by returning the updated record from the request, so you just replace your old one with that and you have the correct ID value applied automatically.
This one is for the MS Azure Search team, unless someone else has run into this and found a resolution for it.
I'm creating an index which is importing data from a SQL Server Database. I would like to add a field to the index whose value is just "OK" for every document. This field does not exist in the database and we do not want to add it there.
Is it possible to add a hard-coded field to an Azure Search index which auto-populates with the given string (in this case, "OK") for all documents that get imported?
Injecting constant values isn't currently possible with indexers - you would need to add this to the table, or create a SQL query that SELECTs that value, and use that query as your Azure Search datasource.
However, we've seen several customers ask for this, so please vote for this suggestion: Provide field mapping function to inject a constant value into the index. Thanks!
How to check existing Customerid in db using mule esb. I am inserting the data customer table in db, In this customerid is unique. When I insert the data I am unable to find the already existing Customer Id Using mule flow. Please anyone suggest on this. I am getting data as Json format from Rest api.
Pass your select query to database connector.
If there is an existing record you will be getting value out of your query or else you will be returning empty.
use a choice router to check for emptiness.
If result is empty then there is no record exist.
Based on that you can proceed further.
Cheers!
You can do it in below way:
Use the corresponding DBConnector and get the value based on Id, if returns then value is exist.
If you DB is connected with any application and that application has SOAP/ REST services, then by using those as Endpoint in mule, you can check it in muleflow by setting some payload for checking the Uniqueness.
You can first query the db to check if the customerId exist. If its not there then inserts, if its there then use update.
I am attempting to create a form that can import data from another database into access, assign an import ID to all the records, copy that data into a master database, and then delete the imported databases so the only remaining databases are the master databases.
I am getting stuck on assigning the import ID. I would like the user to be able to define it in a form and hit a button that executes assigning the value in the form to all the new sets of data. Since this column is not defined in the original set of data I figured the easiest way to do this would be by setting the default value on the master database before copying the data over. However I cannot find a way to change this value without clicking over to the form and changing it manually, which is the exact opposite of what I need to happen.
The reason that I am trying to add the import ID is that I need to nest child tables in the main table and the existing ID starts at 1 for every database and does not remain unique. I figure that I can use the import ID and the existing ID to create a relationship.
Any help is appreciated!
what are you porting to (another access DB or an mysql/mssql?)
but you should be able to set a field in both databases being a integer and using a form to set that field data to whatever the user enters (remember to parse). After the data is set on our outgoing DB you can just push to your master like normal (unless i have not understood the question?) to drop a database in SQL use
DROP DATABASE database_name
You could also use java or .net to delete the database manually after you run you update
I have an access 'application' (.adp file), when it opens i have it update an admin database with the username and time open. When it closes it updates the admin database with username time closed - these are sperate records in the events table so it looks like
username,dbaction,time
bob,open,13:00
gareth,open,13:05
bob,close,14:00
If the user where to open the db twice there would be 2 open and 2 close actions recorded but no way to establish which database session each of the 2 close events belonged.
What i want to store in this table is a unique identifier to link the open and close actions together with 'each session'. Preferably i would like to use a property ov the application object in vba if something exists. Does it even store the time the db was opened? I could generate my own id when databases are opened and store it in a variable until close, but id prefer to use something in built. Any ideas?
I do this using a hidden unbound form which opens on startup. In that form I insert the record into the table. I then fetch the autonumber ID (or whatever SQL Server calls that field.) of that record and store in a text control. If you do any development and you hit an error and reset the running code you lose all global variables thus I prefer using forms to store these kinds of variables.
In the hidden forms On Close event I then update the same record with the date/time exited. I've been using this technique for well over a decade without any problems.
You could have a global 'Id_session' variable, initiated at startup (random generated uniqueIdentifier for example) that you will store in an 'id_Session' column of your 'event' table. When the database is opened, the record is inserted in the 'event' table, and the record identifier is stored as a global variable. When the database is closed, the existing record is identified (through the id_session value) and updated in the database.
In fact, I do not understand the interest of an inbuilt identifier instead of this solution.
There is likely a method that runs in an access database when it is opened. In this you could generate a random identifier and store it in a global variable. When writing your log line you could include this identifier allow you to trace login and logout.
Update: You can use the code shown here to generate a GUID which is pretty much gauranteed to be unique so this should do what you want. If it doesnt you might need to clarify as I'm not understanding the question.
All these answers seem to me to be too clever by half.
What I do is add an Autonumber field to the table I'm logging these in, and then capture the Autonumber value of the startup event record and store it somewhere in (usually in a hidden field on the app's startup form) for use at shutdown to write the shutdown event with the ID number of the startup event.
is HWND going to be unique for 2 access applications opened at the same time on possibly on the same pc or 2 different pcs?