How to create_record at the top of data block in Oracle Forms Builder? - sql

I would like to be able to create a new record at the top of a datablock?
At the moment I have the following code:
first_record;
create_record;
But this creates the record after the first record.... I would like it at the very top...
Does anyone know how to do this?
Thanks,
WW

This isn't possible in forms at the moment.
To accomplish something like this you should make 2 blocks. The first only containing one record to create records. And when you commit something here it will be queried in the second block.

Related

Noobie problem with using parameters within SQL on Delphi 10.3

I'm sure I'm doing something silly here, but here goes - excuse my noobness.
I'm experimenting with Delphi to try and write a simple app. I'm currently using SQLlite with the chinook demo database, which lists a few artists and albums.
I have managed to connect a ComboBox to a field in the DB to select the artist name.
I then want to fill a grid of the artist albums, using the ComboBox selection as a parameter within that statement:
select * from albums JOIN artists ON albums.artistid = artists.artistid WHERE artists.name=:selection
If I populate 'selection' manually in the parameters tab of the query object, it works fine.
But I need :selection to come from the ComboBox, for which I think I need to do something like:
FDQuery1.ParamByName('selection').AsString := 'ComboBox1.text'
But I can't for the life of me figure out where I would put that bit of code? The docs I am reading say: To put a parameter marker into the SQL text, use the : syntax. Then assign corresponding values using the Params collection.
If I expand out the Params bit under the query I don't see anywhere to put it. Making a new one doesn't seem to give me the option to do that either. If I switch to code view, I don't see a section with my SQL query in it to put it in there manually. Maybe a view thing?
Apologies if this is a really stupid question. Just starting out with Delphi!
The OnSelect event of the combobox is one place to update the query.
procedure TForm1.ComboBox1Select(Sender: TObject);
begin
FDQuery1.ParamByName('selection').AsString := ComboBox1.Text;
FDQuery1.Open();
end;
I generally have a procedure "BuildQuery" on a form which I call when the form is initially displayed (FormShow), or when the dropdowns change (OnSelect) or a "Search" button is pressed.
In that procedure, Clear and re-add your SQL to the query, it will automatically detect and add the parameters as you go.
Then do as you did but without the single quotes, then Open your query.

Get concrete value in Pentaho Report Designer

Let me explain my problem,
in Pentaho Report Designer I want to build such a report, where I have one data set, i.e. one request to database
SELECT code, name FROM EMPLOYEES
and show result of this request not in the form of list, but put every result in appropriate place. i.e. like in below picture
Where field "code" is unique, just one result can be put into red label in picture.
How can I do this in Pentaho Report Designer?
I can solve this problem by creating 3 data set, for each of caption. But what if captions like this will be much more, creating requests for each of this caption will not be so effective.
Hope I could explain my question.
I don't know if I got it right, but If you want to use the values returned by your query, you could create a new formula called "your_formula":
=MULTIVALUEQUERY("name_of_your_query")
This will give you an array with the result of the query. Then you could use another formula to get the 1st result of the array. For example:
=ARRAYLEFT([your_formula])
and get the first result of your query. This way let you use your_formula as parameter. This means you can drag and drop it on your report and use it.
I hope it helps.
Regards,
Tatan.

Adobe Forms records do not flow after first page

I'm kinda stuck with a problem which I have no idea how to fix. I'm doing a nested loop using 2 tables in the form but the output is funny where the records disappear for records more than a page. It shows only one page but not the balance of it. Besides that, there is a blank page before the records as well. Please help me with this.
if the child table has less than 72 records per item, then it's fine.
Thank you Gurus
Use Parallel Cursor for the nested loop and store all values in 1 Final Table.

creating a SQL package to add arguments to views

I am working with a large data set and have created two views that work with this data set. The first (lets call this one View1) looks at the data and pulls certain values, the next view (lets call this one View2) looks at View1 and pulls certain values from that. The way I have it set up right now, if I inserted a WHILE statement into view 1 to restrict the days that are pulled from the large data set, this carries over to View2 as well (since View2 SELECTS FROM View1).
What I want to do is to create a package that will turn the start and end dates into variables so that I can do what the views are doing with dates I pass in instead of hard coding in the start and end dates each time.
I do not have a lot of experience with packages and have tried making one from some documentation I have found online, but to no avail.
Any help is appreciated, thank you!

Query to select items from a list and update table

I've got a query that I ran against a table of stock items to change a field from false to true so that a label would be printed out as per the below.
UPDATE [StockDB].[dbo].[StockItem]
SET [UseDescriptionOnDocs] = 0
Where [UseDescriptionOnDocs] = 1
I have since been told that all of the items do not need this and to only do it for the ones in a list of 1150. From that I need to modify the query, something which I am really struggling with!, so it can only do it per item which are in the format of R368/WASHER/M4/ZINC/PL etc. I thought I may be able to do it using LIKE but it will only do one line? If I could get it to query a list from Excel or CSV that would be great.
Any pointers would be good as I'm an absolute novice with this once you get past the simple stuff like the above!
Thank you.
With MySQL (and others) you can load data from a file to a table. See http://dev.mysql.com/doc/refman/5.1/en/load-data.html to understand and for exemple.
Once you have your items loaded into a SQL table, you just have to do an update + join query. See http://dev.mysql.com/doc/refman/5.1/en/update.html to understand and How can I do an UPDATE statement with JOIN in SQL? for exemples.