Need assistance searching records from multiple tables - Please Help!
Hi, I've been trying to solve this problem for several weeks now, and I have exhausted all of my knowledge and experience. I need help, and I hope someone here can give me some direction.
I am using VB 2008, and the CR that comes bundled with VS 2008 Pro. My database is a SQL Server 2005 CE v3.5 (a *.sdf file). I am connecting to the database through a dataset, and I am displaying the report in a CrystalReportViewer.
My dataset consistes of two tables:
1) tblCustomers which has a primary key "CustID", and contains only customer contact and personal information.
2) tblDateVisited which has a primary key of "VisitID", but it also has a column titled "CustID". Basically, every time a customer visits the business, details of that visit are recorded in tblDateVisited, and that record is associated with the customer by their CustID.
Here's what I'm trying to accomplish: I want to be able to display only Customer records when the customer has visited and that visit matches certain criteria. Right now, I am trying to match visits from the "tblVisitDate.PlayerType" column. If the customer has ever had a visit where they matched a particular player type, I want to see those customer records.
I don't know what I'm doing wrong, though. I can search a dataset if I am only querying one table and pulling records from that table. However, whenever I try to add a second table and perform queries on that table to get records from the first table, I can't return any records.
If it helps, I am trying to use one CrystalReportViewer to display multiple reports (user choice) and here's how I'm loading the report into the viewer:
Me.tblCustomersTableAdapter.Fill(Me.dsPlayerTypeReports.tblCustomers)
Me.tblDateVisitedTableAdapter.Fill(Me.dsPlayerTypeReports.tblDateVisited)
Me.ReportFile.SetDataSource(dsPlayerTypeReports.Tables(1))
I am suspicious that my problem is in the Tables(1) method. It confuses me that I can only assign one table as a datasource when I obviously need access to two tables to make this selection work.
Whatever the case, I'm at the end of my rope with this one. I'm not prone to giving up, but I'm at a dead end currently.
Any attempt to assist me with this will be greatly appreciated, successful or not.
Thanks in advance!
-Will
No, I am connected via ADO.NET. I don't think SQL CE can connect through ODBC (or if it can, I haven't been able to figure out how, yet). So this isn't a stored procedure.
When I examine the link, I can only choose an Inner Join or a Left Outer Join. Right Outer and Full Outer are not available. Could this be a problem with the dataset I'm using?
Could you explain what you mean by display all of the records and then choose the selection criteria?
Similar Messages
-
Delete records from multiple table
Hi,
I need to delete records from multiple tables using a single delete statement. Is it possible ? If so please let me know the procedure.
Kindly Help.
Thanks,
Alexander.Hi Tim,
Syntax of DELETE statement does not allow for multiple tables to be specified in this way. Infact, none of the DMLs allow you to specify table names like this.
Technically, there are other ways of deleting from multiple tables with one statement.
1. "Use a trigger":
What was probably meant by this is that you have a driving-table on which you create a on-delete trigger. In this trigger, you write the logic for deleting from other tables that you want to delete from.
This does mean a one-time effort of writing the trigger. But the actual DML operation of deleting from all the tables would be simply triggered by a delete on driving-table.
2. Dynamic SQL:
Write a PL/SQL code to open a cursor with table-names from which you want the data to be deleted from. In the cursor-for loop, write a dynamic SQL using the table-name to delete from that table.
3. Using Foreign-Key constraint with Cascade-Delete:
This I feel is a more 'cleaner' way of doing this.
Having to delete data from multiple tables means that there is some kind of parent-child relationship between your tables. These relationships can be implemented in database using foreign-key constraints. While creating foreign-key constraint give the 'on delete cascade' clause to ensure that whenever data is deleted from parent-table, its dependent data is deleted from child-table.
Using foreign-key constraint you can create a heirarchy of parent-child relationships and still your DELETE would be simple as you would only have to delete from parent-table.
IMPORTANT: Implementing foreign-key constraints would also impact other DML operations that you should keep in mind. -
Hi,
I have a method that has to access records from multiple tables and store them all in a file. It's something like this:
switch (tableId){
case 'A' : query="SELECT * FROM TABLE_A
WHERE ID = '" + tempId + "'";
ResultSet rs = stmt.executeQuery (query);
rs.close();
break;
case 'B' : query="SELECT * FROM TABLE_B
WHERE ID = '" + tempId + "'";
rs = stmt.executeQuery (query);
rs.close();
break;
case 'C' : query="SELECT * FROM TABLE_C
WHERE ID = '" + tempId + "'";
rs = stmt.executeQuery (query);
rs.close();
break;
My problem is that I get an "Invalid cursor" error the second time I enter the loop. I've been reading up on cursors but I still don't know what to do. Can I use ResultSet to return multiple rows from multiple tables? If not, what can I use? Please help!
Thanks in advance.remove the "rs.close()" from the switch statement. use "rs.close()" after your loop ends.
prem -
Sender JDBC Adapter : Fetch records from multiple tables
Hi Friends,
I am using sender JDBC adapter to select few records from DB2 database table.
This scenario is working fine.
Now my requirement is to fetch records from 3 tables. These table are independent to each other. There is no primary key or foreign key.
Please let me know how to write the sql in sender JDBC adapter to fetch records from these 3 tables.
Thanks,
Sandeep Mauryahi sandeep...
if the tables are completely independent and do not share any primary / foreign key relation ship...
why dont u think towards creating a seperate interface for each of them..
or if u still want to select from multiple table at once..the best way would be to write a stored procedure on the sender side which do all the fetching n processing and pass the final resultset to PI
or u can think towards fetching the data from 1 table and then in UDF do lookup from other tables..which again is tricky and performace intensive -
Extracting Records from multiple tables
hi
I have to extract almost 1 lack records from 3 tables.
Please help me in ABAP CODE.
PLease it is very urgent.Which tables are they ? Refer to link below for more hints abt performance.
Re: select query - optimization -
Search a record from Multiple Tables
Is there a pl/sql command or way that searches for a specific record (text, number) in multiple tables? Given that you don't know the column you are searching from.
There is no built in method, but you can roll your own.
I posted one way Re: How to find out a tablename
HTH
John -
Using ResultSet to read records from multiple tables
Im using a ResultSet object to read records from tables.
I have a database with 5 tables. Initially, I got it to work fine with one of those tables. What Im exactly trying to do is check if there is a record in a table which matches a given string, and if it does, display some text on some JTextFields. I got that to work fine with one table.
Problem is, how do I get it to work with all 5 tables at the same time?
i.e. instead of searching through one table, I want it to look through all 5 tables and look for the matches.
Any help greatly appreciated.
ThanksAfter the first interaction with the first table, I
used a stmt.getMoreResults() followed by instructions
to get data from the second table, and so on.
Worked fine.Sounds remarkably inefficient. (Potential for lots of network traffic.)
is this another way of doing it?Sounds more like a document search type of thing than a database query. What about Lucene? Could it help here?
% -
Records from multiple table in Forms using Structure
Hi all,
I thought of bringing records from more than one table to smart forms.I have done the same by using two internal tables but not using with globally declared structure.Is it like this:
1.Create the global structure
2.In driver program create a internal table
3.Pull the data using select statement
4.Pass the internal table to smartforms-> Here I dont understand how.Usually In smartforms we declare internal tables of table type like 'itable type zgkmaster'
How to pass the internal table we created using structure to smartforms?
ThanksHi Gopi,
the procedure u r telling is correct.
create the structure(ex:zstruc) in se11 as the structure of the internal table.
*popluate the data into internal table.
*in smartform, u declare the internal table as that structure i.e itab type zstruc.
i.e in smartforms when u declare internal table, u r telling that ur internal table having the structure similar to the structure ZSTRUC.
In smartforms u can declare the table type using either ...type <db table> or ... type <structure>.
san -
How to Concatenate Multiple Column Records from multiple tables
my question is
there are three tables like A,B,C
i want the data from these tables with the help of relation
select a.simno,b.item_code,c.desc
from A a,B b,C c
WHERE a.ms=b.ms and
b.item_code=c.item_code
and a.ms=c.ms
the output for this query which i am getting is
simno item_code desc
1 i1 abc
1 i2 def
1 i3 xyz
2 i4 gtr
2 i5 poi
but i want the output in this
simno details
1 abc#def#xyz
2 gtr#poi
and so on
if it dispayes the output inthis manner i can save as ".csv" fileHi,
There are different Solutions you can achieve
Refer to Asktom : http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402
SQL> create table test(simno number, itemcode varchar2(5), desc1 char(5))
Table created.
SQL> insert into test(simno,itemcode,desc1) values (1 ,'i1' ,'abc');
1 row created.
SQL> insert into test(simno,itemcode,desc1) values (1 ,'i2' ,'def') ;
1 row created.
SQL> insert into test(simno,itemcode,desc1) values (1 ,'i3' ,'xyz') ;
1 row created.
SQL> insert into test(simno,itemcode,desc1) values (2 ,'i4' ,'gtr');
1 row created.
SQL> insert into test(simno,itemcode,desc1) values (2 ,'i5' ,'poi');
1 row created.
SQL> select simno,wmsys.wm_concat(desc1) CONCAT
2 from test
3 group by simno;
SIMNO
CONCAT
1
abc ,def ,xyz
2
gtr ,poi- Pavan Kumar N -
Choosing most recent records from multiple tables?
Let's say that you have two tables; one contains news
articles with the fields TITLE, ARTICLE, and a timestamp DATE and
the other contains different news articles with the fields TITLE,
DESCRIPTION, and a timestamp DATEPOSTED.
How would you go about selecting the (let's say) five most
recent articles with the corresponding fields? I'm relatively new
to CF but even the experienced guy in our office can't figure it
out. The following code is what we were working with -- which
doesn't quite work the way it should anyway -- but I'm thinking
there
must be an easier (or at least less convoluted) way.Thank you so much! Azadi hit the nail on the head; I hadn't
known the terms to look for so Google hadn't been any help, but
UNION was just the trick for this MySQL query. I had to add a field
to each table in order to tell the link which page to go to since
there's a different one depending on which table the record came
from, but here's the code that works (just in case anyone else does
a search for this problem): -
Problem selecting records from multiple tables
Good day
I am writing a report showing actual vs budget amount per period. The actual amounts are in one table and the budget amount are in another table. In this example it is for vehicle sales. The problem is that in the budget table, there are no records for a particular make if it was not budgeted to make a sale. If I try to get the records using the select expert it matches the key in actual table with key in budget table and retrieve. What happens then is that the records in the actual table get excluded if there was not a record for it in the budget table. How do I then do this selection, i.e. if there is a record in the budget table, then retrieve, otherwise make the budget amount 0?
Thanks
WilhelmThis is always difficult the best way is to use a command and union the two sets of data.
First part uses a left outer join from Actual to Budget and brings back all actual data with and without a budget.
Second parts brings back data from budegt where nothing exists in actual
select (field list) from
Actual a
left outer join Budget b on a.field = b.field
where (any other filter condition)
union all
select (field list) from
budget b
left outer join actual a on b.field = a.field and a.field is null
where (any other filter condition)
You can get the first query from your current report and the modify to build the second unioned query.
Ian -
Delete records from multiple tables and add delay in execution
Dear All,
My Database is Oracle 11gR2 on Linux.
I have to schedule delete in 5 tables. For this i will write a procedure with delete queries and schedule the procedure to run daily in night.
I want to give delay in the execution of delete queries within procedure? How can i add this functionality within a procedure?
I don't want to lock the tables as other queries may be accessing the same table meanwhile.
Looking for your help.
Regards,
ImranDuplicate thread - see https://forums.oracle.com/thread/2553380 for answer.
-
Polling records from mulitiple table(61 Tables) using WCF-SQL adapter
Hi,
I would like get some suggestion from this forum. I've a scenario, in which I need to poll the records from multiple table(61) which are related and may have one to many relationship. what's the best way to poll the records from SQL table to BizTalk.
Thanks in advance..
Regards,
KarthickKarthick,
Write a SQL stored procedure with joins from your 61 tables (!!!) . Use WCF-SQL adapter to invoke the procedures.
Following references shall help you:
Executing Stored Procedures in SQL Server by Using BizTalk Server
Performing Composite Operations on SQL Server by Using BizTalk Server
Bing-Results: biztalk wcf sql
adapter polling stored procedure
I don’t know your exact requirement. Consider using SQL-SSIS for ETL process depending on your requirements. Anyway if your requirement really needs BizTalk, above suggest
should solve your problem.
If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply. -
How to get large no of records from adf table
Hi All,
I'm working on adf.I'm using jdeveloper 11.1.1.5 version.In my adf application i have 1000 records in my adf table.I want to get the 500 selected records from that table at a time.But im not able to get huge number of records.How can i get the records from adf table.Please give me ur valuable suggestions.
Thanks!Hi.
for large record check the oficial doc.
http://docs.oracle.com/cd/E24382_01/web.1112/e16182/bcadvvo.htm#CEGDBJEJ
PAGE_RANGING is the best option for large tables.
and these maybe will help you
Re: Performance scrolling large ADF tables
Re: Expert opinion needed: Best practices to handle huge rowsets on UI -
How can i get all the records from three tables(not common records)
Hi
I have four base tables at R/3-Side. And i need to extract them from R/3-Side.
And i dont have any standard extractor for these tables .
If i create a 'View' on top of these tables. Then it will give only commom records among the three tables.
But i want all the records from three base tables (not only common).
So how can i get the all records from three tables. please let me know
kumarYou can create separate 3 datasources for three tables and extract data to BW. There you can implement business login to build relation between this data.
Maybe you are looking for
-
How do I ignore colours specified on web pages so I can use a screen tinter program?
I have problems with my eyesight and have started using Screen Tinter software to change the colour of background to something more comfortable. I have been told that you can do the same on web pages by going to tools/internet options/accessibility/i
-
Transfering photos with titles, comments, etc between computers
I have a MacBook and an iMac. The iMac is my primary computer and has the larger hard drive. I store all my pictures on the iMac. When I am on the road, I like to update my photos by adding titles, comments, and keywords. Is there a way I can take a
-
Need to delete flag "quantity incomplete" for table COSP (periodic repost)
Hello. Step 1. I writed-off fuel to Internal order(unit of measure Liter ) , Step 2 Posted SKF, Step 3 Execute Actual periodic reposting. The issue is that receivers Internal orders has "empty" field quantity, it is because in table COSP field MUV
-
Firefox application quits unexpectedly on various websites with no pattern. Part of the error message details reads "firefox-bin [770]" It started happening this AM after I visited facebook and got an invite from someone I don't know. I didn't reply.
-
Why does CC not install new update over older version?..