How to use Update and Insert Value XQuery in PHP - xquery

I am using XML based database to save the records of large scale data in my web application. I know how to fetch all the data or specific data through XML tags in PHP. But I have no idea how I can update the data stored in XML tags using PHP. For instance I want to update the following XML tag by using XQuery from PHP.
<program id="p00547jm">
<time>
<startTime>1003394820</startTime>
<endTime>1003394826</endTime>
<epochStart>2001-10-18T08:47:00</epochStart>
<epochEnd>2001-10-25T08:47:00</epochEnd>
</time>
<completeTitle>in_our_time:_democracy</completeTitle>
<mediaType>audio</mediaType>
I am using following XQuery to update the value of 1 particular XML tag:
$query='for $x in doc("coursework")/bbcPrograms/program
where $x/completeTitle="'.$single_edit_program_title_hidden.'"
and $x/mediaType="'.$single_edit_program_type_hidden.'" and
$x/masterBrand="'.$single_edit_masterbrand_hidden.'" and
$x/service="'.$single_edit_service_hidden.'"
return update value $x/completeTitle[.="'.$single_edit_program_title_hidden.'"] with "'.$single_edit_program_title.'"';
It works correctly when we want to update 1 particular XML tag value. Now I want to make this XQuery work for updating tags values of multiple XML tags. Just as we do normally in SQL. SET id='abc' AND name = 'xyz'...
Please help me how this Xquery can work for multiple tags values update.

Related

PeopleCode to load from CSV file and split 1 field into multiple columns

I am not familiar with Application Engine or PeopleCode but inherited this project when someone left. Seems simple but I'm not sure how to approach it.
I have to load a CSV file that has 5 fields. The last field has multiple values separated by a comma and it is qualified with quotes.
file example:
ID , YEAR, VALUE1 , VALUE2, CODE
87778, 2022, processed, none , 100,40
93332, 2022, processed, none , 60
76633, 2022, error , none , 55,35,9
I have created a File Layout definition and set the qualifier and I can load the file into a staging table but now I want to split the last column (CODE) into individual codes.
I have created 2 PeopleTools Record definitions with a parent/child relationship:
parent Record definition with ID,YEAR,VALUE1,VALUE2, and
child Record definition with ID,YEAR,CODE
I have found that I can use the PeopleCode split function to break the CODE column out into an array containing each value in an element. I'm not sure what the best way to structure the program is though.
Is the staging table necessary?
Or can I use the split function as I read the CSV file in and update the parent/child tables?
Or do I need to keep the staging table and then read out the fields for the parent record and move them to the permanent table and then do the same for the child after using the split function and then loop through the array?
Just looking for some guidance so my first AE project is not a mess.
IMO, there are always multiple ways to achieve the same thing(especially in AE). we choose one based on our requirements and efficiency.
for staging table: In your case, you can ignore the staging table unless you are expecting to load a huge set of data every time or want to do parallel processing. In other words, you can have staging table if you think loading takes a lot of time and you don't want to risk failing that due to other errors.
You can even achieve this whole thing in one peoplecode action without a staging table.
or,
Load the data into staging table and commit.
loop through the data from staging table in AE (having the data in state rec)
Do the transformation as required using peoplecode action
insert data in necessary tables
update status(have a field in staging table) field in staging table, this may come in handy for any analysis/issue in production

Laravel Form input type="text" select data from another table on type type suggest existing data from the table and select

How can i create a form like the one on linkedin. On form input type when i type is going to fect data from a database if not existis is going to create it and fetch d and store to another table
on form input type, immediately get result: This can be done by AJAX. Laravel support Vue which can do this easily:
1a. call a function in the mounted() part.
1b. the function call itself by putting setTimeout(this.functionName,1000) at the end.
1c. in the function, check if the text in the text box is changed. if yes, make a request by axios.get('blablabla').then(response=>{//put the response into vue dataArrayName in data part});
1d. the html template is auto-updated by v-for="dataArrayName"
looks like the search is done by comparing char by char from the beginning of the string to the data.
if you press enter, pass the search string to the controller, use some logic to determine whether it is needed to create row in database

jdbcDatatable id possible values

In the schema.icc-schema schema definition xml file, in the jdbcDatatable tag there is an id attribute which looks like a serial number (3362e2cc-a588-492a-af9a-ea3b0e788ec4 in my case).
This id is used later in a multiLevelDimension tag to identify the table source via the dataTableId tag.
Is the id any arbitary string, or has it to conform to a special format? In other worlds, may I use an id like "foodmart-store" or "foodmart.store", to ease the migration of a Mondrian scheme into a icCube schema?
You can use any format as long as it is unique (better within the schema).

Creating own Report in Odoo: t-field for date, Customer ID etc.?

First of all I'm kinda new to Odoo and I'm trying to understand some Basic logic. I created my own Report based on the Basic Report of Odoo.
There are a lot of fields like t-field="o.date_invoice" or t-field="o.partner_id etc. which work really fine but where can I find all functions? Is there any list?
For Example I Need a Field for the order date and for the print date or for a Customer ID.
With a t-field attribute you can access and print fields from the actual model or from a related model, for example with the following element you can print the content of the phone column (field) of the actual record:
<span t-if="o.phone"
t-field="o.phone" />
Explanation of t-field in the documentation:
The t-field directive can only be used when performing field access
(a.b) on a "smart" record (result of the browse method). It is able to
automatically format based on field type, and is integrated in the
website's rich text edition.
Check this link for further information if you want to build reports and this one, where you can read about some the elements that you can use in Qweb
In addition, you can check here a list of some attributes that you can use in a Qweb template

Read a CSV file that have indefinite number of columns every time and create a table based on column names in csv file

I have a requirement to load the csv into DB using oracle apex or pl/sql code, but the problem is they are asking to load the csv file which will not come with same number of columns and column names .
I should create table & upload data dynamically based on the file name and data that i'm uploading.
For every file i need to create a new table dynamically and insert data that are present in csv file.
For Example:
File1:
col1 col2 col3 col4 (NOTE: If i upload File 1, Table should be created dynamically based on the file name and table should contain same column name and data same as column headers of csv file . )
file 2:
col1 col2 col3 col4 col 5
file 3:
col4 col2 col1 col3
Depending on the columns and file name i need to create table for every file upload.
Can we load like this or not?
If yes, Please help me on this.
Regards,
Sachin.
((Where's the PL/SQL code in this solution!!??! Bear with me... the
answer is buried in here somewhere... I introduced some considerations
and assumptions you will need to think about before going into the
task. In the end, you'll find that Oracle APEX actually has a
built-in solution that satisfies exactly what you've specified... with
some caveats.))
If you are working within the Oracle APEX platform, you will have some advantages. APEX Version 4.2 and higher has a new page element called "Data Loading". The disadvantage however is that the definition of the upload target is fixed and not dynamic. You will need to know how your table is structured prior to loading the data.
One approach to overcome this is to build a generic, two-column table as your target, which will serve for all uploads. Column 1 will be your file-name and column two will be a single clob data type, which will contain the entire data file's contents including the header row. The "Data Loading" element will give the user the opportunity to verify and select this mapping convention in a couple of clicks.
At this point, it's mostly PL/SQL backend work doing the heavy lifting to parse and transform the data uploaded. As far as the dynamic table creation, I have noticed that the Oracle package, DBMS_SQL allows the execution of DDL SQL commands, which could be the route to making custom tables.
Alex Poole's comment is important as well, you will need to make some blanket assumption about the data type or have a provision to give more clues about what kind of data is contained. Assuming you can rely on a sample of existing data values is not good... what if all the values in your upload are null? I recommend perhaps a second column in the data input with a clue about the type of data for each column... just like the intended header names, maybe: AAAAA = for a five character column, # = for a numeric, MM/DD/YYYY = for a date with a specific masking.
The easier route:
You will need to allow your end-user access to a developer-role account on a workspace of your APEX server. It is not as scary as you think. With careful instruction and some simple precautions, I have been able to make this work with even the most non-technical of users. The reason for this is that there is a more powerful upload tool found under the following menu item:
SQL Workshop --> Utilities --> Data Workshop
There is a choice under "Data Load" --> "Spreadsheet Data"
The data load tool will automatically do the following:
Accept a CSV formatted file through a browse function on your client machine
Upload the file and parse the first record for the column layout (names)
Allow the user to create a new table from the uploaded file, or to map to an existing one.
For new tables, each column data type can be declared and also a specific numeric/date mask if additional conversion from the uploaded data is necessary.
Delimiter type, optional enclosures (like double quotes), decimal conventions and currency types can also be declared prior to parsing the uploaded file.
Once the user has identified all these mappings and settings, the table is created with the uploaded data. Any errors in record upload are reported immediately afterwards with detailed feedback on the failed records.
A security consideration to note:
You probably do not want to give end users access to your APEX server's backend... but you CAN create a new workspace... just for your end users... create a new database schema for receiving their uploads, maybe with some careful resource controls. Developer is the minimum role needed... but even if the end users see the other stuff there won't be access to anything important from an isolated workspace.
I have implemented the isolated workspace approach on a 4.0/4.1 release APEX platform a few years back, and it worked nicely. Our end user had control over the staging and quality checking of her data inputs (from excel spreadsheet/csv exports collected from a combination of sources). I suppose it may have been even better to cut her out of the picture entirely and focused on automating the export-review-upload process between our database and her other sources. In this case, the volume of data involved was not great enough (100's to 1000's of records) and the need for manual review and edit of the exported data was very important prior to pushing it into the database... so the human element was still important in this case - it is something you'll want to think about now.

Resources