TDBGrid where is the SQL WHERE condition? - sql

I am working on an already started Delphi project where there is a TDBGrid. The grid seems to be filled by a TADOTable that refer to a Bill table in the dataset.
It display a bill by PkBill. I can't seem to find where in the design or in code someone told to load only for this pk.
I need to load multiples Pk at the same time. I'm used to create programmatically a TADOQuery, create a connection, write my SQL code, then do what I want with the result. With those objects/controls, I just don't know where to do that.
Thanks for the help and clarity!

Check TADOTable.MasterSource to see if it's in the Master-Detail relationship.
Or you could check TADOTable.Filtered and TADOTable.Filter to see if it's being filtered by PkBill.

Related

Oracle Application Express SQL Query to show meaningful information

I am trying to write a query that 1) works and 2) shows meaningful information.
However, I can't seem to complete both scenarios. Both bits of code do work to a degree. My SQL query does work by showing all the useful information a user wants but when you click the edit button it doesn't link properly so it won't allow the user to update that row. The other shows only keys and rowid but when you click edit does show the information and allows it to be updated.
So as not to get another down-voted question, I have taken pictures of each scenario to show the problem, but, ultimately, I need to show meaningful information: an id or key isn't meaningful to the vast majority of users.
Here is my code
SELECT APPLICATIONS.APP_ID, APPLICATIONS.SRN, STUDENTS.SURNAME, STUDENTS.FORENAME, APP_STATUS.STATUS, METHODS.METHOD, JOBS.JOB_TITLE, APPLICATIONS.APP_DATE
FROM APPLICATIONS
JOIN STUDENTS
ON APPLICATIONS.SRN = STUDENTS.SRN
JOIN APP_STATUS
ON APPLICATIONS.STATUS_ID = APP_STATUS.STATUS_ID
JOIN METHODS
ON APPLICATIONS.METHOD_ID = METHODS.METHOD_ID
JOIN JOBS
ON APPLICATIONS.JOB_ID = JOBS.JOB_ID;
and here are the pictures of it in action
below is the code that does not show meaningful information but does work.
select "ROWID",
"APP_ID",
"SRN",
"STATUS_ID",
"METHOD_ID",
"JOB_ID",
"APP_DATE"
from "#OWNER#"."APPLICATIONS"
If i knew how to properly use rowid i am sure this is a simple feat but i dont so if i could get any help it would be useful
//edit
who ever renamed this to Application Expression why? what i am using is Apex Application Express it was relevant information that got changed to something wrong which might make it hard for someone with a similar problem to find later.
In the second, simple query, apex can determine which table (and record) you are trying to edit.
In the first query, with the joins, it can't tell which of the five tables in query you want to edit. You probably want to have the edit link pass the primary key of the row from APPLICATIONS to the child page. You would need to build into that page any logic (lists of values etc) that map lookup tables (such as status) to the values needed in the APPLICATIONS table.

How to remove mirrored datasets from MS Access DB?

I am experiencing a problem with mirrored datasets. This situation occured because the data model was switched a few months past and I just got recently assigned to this project, which already had a new application and data model done.
I was tasked with importing all the data from the old MS Access application to the new one and here's where the error has its source. The old data model was written in a way that every dataset was also stored as its mirrored counterpart. Imagine a database table like this:
pk | A | B
1 | hello | world
2 | world | hello
I imported the data via a self made staging process via Excel and VBA coding and that worked fine. The staging was necessary because I wanted to create insert statements and therefore had to map all the old IDs, names, ... to the news ones.
While testing the application after the import was done, I realized that the GUI showed all datasets twice. (The reason for it being shown twice and not once and then once again in mirrored form, is the way we fill the ListBox that shows the results)
I found the reason for that error in the mirrored data and now would like to get rid of it. The first idea I had is rather long and probably over-complicated, that's why I am posting here, in hope of finding a shorter solution.
So, my idea is as follows and would use solely VBA coding:
Filling recordSet with a SELECT * FROM mirroredDataTable
Write a SQL-Statement and check if the recordCount of that statements result is >1 for each record in the recordSet from 1.)
If the resultCount is >1 then one of the IDs in that result is written into a new recordSet or Array
The recordSet / array from 4.) is parsed again and for each ID in there I create a DELETE statement
???
profit
Now I already have an idea for the SQL statement in 2.), but before I begin I'd just like to ensure that there is no "easy" way that I haven't considered yet or just have overlooked.
Would greatly appreciate any help/info/tips you can provide.
PS: It is NOT an option to redesign the whole data model or something among the lines of this (not my decision)
Thanks to #Gord Thompson I was able to solve this issue on a purely SQL basis. See the answer of this subthread for the detailed solution: How to INTERSECT in MS Access?

Copy one database table's contents into another on same database

I'm a bit of a newbie with the workings of phpmyadmin. I have a database and now there are 2 parts within it - the original tables jos_ and the same again but with a different prefix, say let's ****_ that will be the finished database.
This has come about because I am upgrading my Joomla 1.5 site to 2.5. I used a migration tool for the bulk of the new database but one particular piece of information did not transfer because the new database has a different structure.
I want to copy the entire contents of jos_content, attribs, keyref= across to ****_content, metadata, "xreference"."VALUE" if that makes sense. This will save manually typing in the information contained within 1000s of articles.
jos_content, attribs currently contains
show_title=
link_titles=
show_intro=
show_section=
link_section=
show_category=
link_category=
show_vote=
show_author=
show_create_date=
show_modify_date=
show_pdf_icon=
show_print_icon=
show_email_icon=
language=
keyref=41.126815,0.732623
readmore=
****_content, metadata currently contains
{"robots":"all","author":""}
but I want it to end up like this
{"robots":"","author":"","rights":"","xreference":"41.126815,0.732623","marker":""}
Could anyone tell me the SQL string that I would need to run to achieve this please?
If it makes any difference I have manually changed about 300 of these articles already and thought there must be a better way.
Edit: Being nervous of trying this I would like to try and find the exact syntax (if that's the right word) for the SQL Query to run.
The value I want to extract from the source table is just, and only, the numbers next to keyref= and I want them to turn up in the destination table prefixed by "xreference". - so it shows "xreference"."VALUE" with VALUE being the required numbers. There is also an entry - ,"marker":"" that is in the destination table so I guess the Query needs to produce that as well?
Sorry for labouring this but if I get it wrong, maybe by guessing what to put, I don't really have the knowledge to put it all right again....
Thanks.
Please Try it
insert into tableone(column1,column2) select column1,column2 from Tablesecond
if You have not Table another Daabase Then This query
select * into anyname_Table from tablesource

SRSS: Dynamic amount of subreports in a report

it might be possible I'm searching for the wrong keywords, but so far I couldn't find anything useful.
My problem is quite simple: At the moment I get a list of individual Ids through a report parameter, I pass them to a procedure and show the results.
The new request is like this: Instead of showing the list for all individuals at once, there should be a list for each individual id.
Since I'm quite a beginner in srss, I thought the easiest approach would be the best: Create a subreport, copy the shown list, and create a subreport per individual id.
The amount of this IDs is dynamic, so I have to create a dynamic amount of subreports.
Funny enought, this doesnt seem to be possible. This http://forums.asp.net/t/1397645.aspx url doesnt show exactly the problem, but it shows the limit of the subreports.
I even ran trough the whole msdn pages starting http://technet.microsoft.com/en-us/library/dd220581.aspx but I couldnt find anything there.
So is there a possibility, to create a loop like:
For each Individual ID in Individual IDs, create a subreport and pass ONE ID to this?
Or is there another approach I should use to make this work?
I tried to create a 'Fake'-Dataset with no sql query but just for iterating the id list, but it seems the dataset needs a data-source...
As usual, thanks so far for all answers!
Matthias Müller
Or is there another approach I should use to make this work?
You didn't provide much detail about what sort of information needs to be included in the subreport, but assuming it's a small amount of data (say, showing a personnel record), and not a huge amount (such as a persons sales for the last year), a List might be the way to go.
I tried to create a 'Fake'-Dataset with no sql query but just for iterating the id list, but it seems the dataset needs a data-source...
All datasets require a data source, though if you're merely hard-coding some fake return data, any data source will do, even a local SQL instance with nothing in it.

SAP Business One I Query inventory base on user defined field

I am running a query on a product. I need a field that will look at the user defined field which contains another product and check that stock level. Any help would be great.
What is the main objective?
Are you trying to check on that item because that item is the material/component? or act like a substitution?
Using UDF is quite not feasible as you have to get the link to the Item Master Data, and I have not figured out yet how to do that.
But if you are using it as substitution, why don't you use Alternative Item in Inventory > Item Management > Alternative Items? It will show on Sales Quotation for you to display it to customer. Or during Sales Order, you can get it displayed for alternative should your main item is shortage.
If you are using those item as a component, I suggest you use Bill of Material. During Production Order you will be able to see those component's availability in qty, and also you can have more than one, unlike UDF.
Hope this helps.
I think the key part you're missing here is the naming convention which SAP adpots for user defined fields.
Correct me if I'm wrong, but it seems that you're capable of querying these fields from a SQL point of view.
UDFs by defuault, will have their column name prefixed with "U_".
For example, the UDF 'AnotherProduct' will be referred to in SQL as 'U_AnotherProduct'.
Hope this helps, if not, please explain your problem in some more detail.