Querying Data w PL/SQL - selecting 1 row
Initial research done at:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#i45320
Querying Data with PL/SQL - Selecting At Most One Row: SELECT INTO Statement
I am trying to run a simple SELECT COUNT statement in PL/SQL. Can someone please help me with the syntax? Here is my SQL select count(*) statement.
SELECT ITEM_TYPE, count(*)
FROM
APPLSYS.WF_ITEMS
WHERE
ITEM_TYPE = 'GLBATCH' AND
END_DATE is not null
GROUP BY ITEM_TYPE;
Thanks, I tried following some examples found on these forum threads but couldn't seem to find one for something so basic as this.
I am trying to run a simple SELECT COUNT statement in PL/SQL. Can someone please help me with the syntax?in plsql you would declare variables to hold the selected values:
declare
l_item_type applsys.wf_items.item_type%type;
l_cnt integer;
begin
select item_type, count ( * )
into l_item_type, l_cnt
from applsys.wf_items
where item_type = 'GLBATCH' and end_date is not null
group by item_type;
dbms_output.put_line ('Item_type: ' || l_item_type);
dbms_output.put_line ('Count: ' || l_cnt);
end;
Similar Messages
-
Use evdre to query data from a SQL View
Hi all
I believe that it is possible to use evdre to query data from a SQL View. If this is possible then how does one go about setting it up in the evdre options (assuming that the view has already been created)?
Regards,
ByronByron, perhaps this is no longer supported, it might be worth opening up a case at service.sap.com on this. However, I did find the following on Page 11 of the "Usages and Considerations of EVDRE" pdf file. This doc is imbedded in the helpfile for BPC 7 SP5 (which was released in August of 2009, well after note 1315011 was last updated.
It looks like you are limited to one custom view per application, since you have to name the view in a parameter at the APPLICATION level. Go into BPC Administration, login to the application related to the custom view, choose "Set Application Parameters" and enter the name of the view to the Application Parameter called "EVDRE_QUERYVIEWNAME" If it is not listed, go ahead and create it at the bottom of the Application parameter screen.
Also: I interpreted the following info from Page 10 of the same doc:
In your EVDRE, set the following options:
QueryEngine: MANUAL
QueryType: enter either NEXJ OR TUPLE see below:
NEXJ - Use two-dimensional queries using the nonemptycrossjoin function
TUPLE - Use two-dimensional queries using tuples"
And I'm assuming you'd enter a Y for the following two parameters:
QueryViewName
"..to enforce the query engine to use a used-defined SQL view of the fact tables, when trying to read the values using SQL queries. This option is typically used in conjunction with the SQLOnly option (see below). "
Option SQLOnly
"..to enforce the query engine to only execute SQL queries, when reading data. This can be achieved using this option." -
Query data from MS SQL db through Oracle ? By using JAVA ?
Hi folks,
I would like to sync our one table in oracle db with table in different system, stored in MS SQL database.
What would be the easiest option for connection from Oracle to MS SQL db to be able to query data from MS SQL through some Oracle package?
If possible, I would like to keep all "tricky steps" within Oracle database. I heard about option with Java, but so far we have no experience with java in Oracle.
Our database: Oracle 11g Database Standard Edition One
Many thanks,
TomasC:\Users\tomeo>dg4pwd HELIOS
ORACLE Gateway Password Utility
Constructing password file for Gateway SID HELIOS
For user account SYSTEM
OPW-00001: Unable to open password-file (RC=0)
C:\Users\tomeo> -
How do i get the data present in the selected row at run time in Multicolumn list box?
Hi,
I am using multicolumn list box with three columns and i am having OK button.
If the user selects particular row and then press ok then that row datas(that 3 values) has to get update in the file.
Can u tell me how to get that selected row values alone and also how to append the list box value at run time?
Thanks
MeenatchiYou can simply use the Value property of the MLBox to get the row selected & wire it to the Delete from array function with the Itemnames of the MLBox as the Input & Output of the Delate from array function.
See the attached VI.
- Partha
LabVIEW - Wires that catch bugs!
Attachments:
Dbl-click Row to get Data & Delete.vi 41 KB -
Retrieve floating point data with an sql select statement
Hi
I'm quite new to using sql but I have a system working where I can read and write strings to an access database.
Now I want to retrieve a a float, from a field where another field in the same post corresponds to a specified float, with a select statement.
When using strings I wrote
SELECT column_name FROM [table_name] WHERE column2_name='value'
in my query.
But instead of getting the desired value I get an error message telling me that I have a
"Data type mismatch in criteria expression".
I think I understand why but does anybody know what I should have written instead?Is the data type of column2_name String? If it's not, I think the single-quotes you have around 'value' will cause that error.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice -
How query data in pl/sql via ODBC from DB2 on AS400
Hi,
What's the most easy way to do some selects on tables in an external (non-oracle)database via odbc?
I only need selects, no dml-statements like inserts en updates...
Where can I find more information about this subject?
FilipYou need to use Oracle Heterogeneous Services. Firstly you have to obtain and configure DB2 ODBC drivers. I got mine from ibm.com (not free) but I am sure there are some third party vendors out there. I don't know much about DB2 so I can't help you with the configuration (I asked a DB2 DBA to help me with that part).
The rest is just setting up Oracle HS and creating the DB link. The following steps should help but there are much more detailed manuals for Oracle HS on http://tahiti.oracle.com.
Listener Configuration
Add the following entry into the SID_LIST part of the listener. The SID_NAME will be used in the heterogeneous services configuration
(SID_DESC=
(SID_NAME=db2)
(ORACLE_HOME=D:\oracle\ora92)
(PROGRAM=hsodbc)
Restart the listener.
Heterogeneous Service Configuration
Under ORACLE_HOME\HS\admin create the following text file called initDB2.ora (the DB2 part should match the SID_NAME used in the listener configuration).
Put the following line in the text file (the DQ01 is the name of the DB2 ODBC System DSN):
HS_FDS_CONNECT_INFO=DQ01
Client Configuration
The client side refers to an Oracle database that will use the heterogeneous gateway.
TNSNames Entry
Put the following entry in the tnsnames.ora file (the SID part should match the SID_NAME in the listener configuration):
DB2.telkom.co.za =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=cntrra20-esdt00)(PORT=1521))
(CONNECT_DATA=(SID=db2))
(HS=OK)
Database Link
Create a database link that references the new tnsnames.ora entry:
create public database link db2
connect to oratst identified by oracle using 'db2';
Test the database link. -
Oracle's SQL select should have a syntax like this
Oracles SQL is very powerful but lacks a basic thing the LIMIT and OFFSET syntax which
is present in postgres sql, I recommend oracle to support this syntax in future release.
more details of this syntax can be found at :
http://www.postgresql.org/idocs/index.php?sql-select.html
SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
* | expression [ AS output_name ] [, ...]
[ FROM from_item [, ...] ]
[ WHERE condition ]
[ GROUP BY expression [, ...] ]
[ HAVING condition [, ...] ]
[ { UNION | INTERSECT | EXCEPT } [ ALL ] select ]
[ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ]
[ FOR UPDATE [ OF tablename [, ...] ] ]
[ LIMIT { count | ALL } ]
[ OFFSET start ]I've executed the above queries against my table and the results follows :
The structure of the table
Name Null? Type
FATWAID NOT NULL NUMBER(11)
FATWASTATUS NUMBER(1)
SUBJ_NO NUMBER(4)
LANG CHAR(1)
SCHOLAR NUMBER(2)
REVIEWER NUMBER(2)
AUDITOR NUMBER(2)
PUBLISHER NUMBER(2)
SUBSCRIBER NUMBER(2)
ENTRY NUMBER(2)
FATWATITLE VARCHAR2(100)
FATWATEXT CLOB
FATWADATE DATE
TRANSLATE CHAR(1)
SELECTED NUMBER(1)
SUBJ_MAIN NUMBER(4)
I have set timing on and executed each query above, following are the statistics.
First the number of rows in the table.
SQL>set timing on
SQL>select count (*) from fatwa;
COUNT(*)
1179651
Elapsed: 00:00:13.05
The query of Andrew Clarke
SQL>SELECT fatwaid FROM (SELECT fatwaid, rownum as ranking FROM fatwa) r
WHERE r.ranking BETWEEN &OFFSET AND &LIMIT
SQL>/
Enter value for offset: 100000
Enter value for limit: 100009
old 2: WHERE r.ranking BETWEEN &OFFSET AND &LIMIT
new 2: WHERE r.ranking BETWEEN 100000 AND 100009
FATWAID
96592
96593
96594
96595
96596
96597
96598
96599
96600
96601
10 rows selected.
Elapsed: 00:00:12.02
SQL> /
Enter value for offset: 1000000
Enter value for limit: 1000009
old 2: WHERE r.ranking BETWEEN &OFFSET AND &LIMIT
new 2: WHERE r.ranking BETWEEN 1000000 AND 1000009
FATWAID
994621
994622
994623
994624
994625
994626
995769
995770
995771
995772
10 rows selected.
Elapsed: 00:00:12.00
The response time is decreasing because of use of bind variables,
but 12 seconds is a sign of poor performance.
Now a slight modification to Clarke's query
I will add order by clause
SQL> ed
Wrote file afiedt.buf
1 SELECT fatwaid FROM (SELECT fatwaid, rownum as ranking FROM fatwa ORDER BY fatwaid) r
2* WHERE r.ranking BETWEEN &OFFSET AND &LIMIT
SQL> /
Enter value for offset: 100001
Enter value for limit: 100010
old 2: WHERE r.ranking BETWEEN &OFFSET AND &LIMIT
new 2: WHERE r.ranking BETWEEN 100001 AND 100010
FATWAID
100032
100033
100034
100035
100036
100037
100038
100039
100040
100041
10 rows selected.
Elapsed: 00:00:04.00 -- time reduced from 12 to 4 seconds
A time of 4 seconds is acceptable but not good,
response time should be in milli seconds.
SQL> /
Enter value for offset: 1000001
Enter value for limit: 1000010
old 2: WHERE r.ranking BETWEEN &OFFSET AND &LIMIT
new 2: WHERE r.ranking BETWEEN 1000001 AND 1000010
FATWAID
1000032
1000033
1000034
1000035
1000036
1000037
1000038
1000039
1000040
1000041
10 rows selected.
Elapsed: 00:00:03.09 -- this reduction is because of bind variables
The query of Chris Gates
SQL>select fatwaid
2 from ( select a.*, rownum r
3 from ( select *
4 from fatwa
5 --where x = :host_variable
6 order by fatwaid ) a
7 where rownum < &HigerBound )
8 where r > &LowerBound
SQL> /
Enter value for higerbound: 100011
old 7: where rownum < &HigerBound )
new 7: where rownum < 100011 )
Enter value for lowerbound: 100000
old 8: where r > &LowerBound
new 8: where r > 100000
FATWAID
100032
100033
100034
100035
100036
100037
100038
100039
100040
100041
10 rows selected.
Elapsed: 00:00:02.04
This seems to be fast
SQL> /
Enter value for higerbound: 1000011
old 7: where rownum < &HigerBound )
new 7: where rownum < 1000011 )
Enter value for lowerbound: 1000000
old 8: where r > &LowerBound
new 8: where r > 1000000
FATWAID
1000032
1000033
1000034
1000035
1000036
1000037
1000038
1000039
1000040
1000041
10 rows selected.
Elapsed: 00:01:14.02
but this is worst when upper bound is 1 million.
Finally Myers query
SQL> select fatwaid from
2 (select /*+ INDEX(fawtaid pk_fatwa) */ fatwaid, rownum x from fatwa
3 where rownum < &UpperBound )
4 where x > &LowerBound;
Enter value for upperbound: 100011
old 3: where rownum < &UpperBound )
new 3: where rownum < 100011 )
Enter value for lowerbound: 100000
old 4: where x > &LowerBound
new 4: where x > 100000
FATWAID
122418
122419
122420
122421
122422
122423
122424
122425
122426
122427
10 rows selected.
Elapsed: 00:00:00.03 -- too fast
SQL> /
Enter value for upperbound: 1000011
old 3: where rownum < &UpperBound )
new 3: where rownum < 1000011 )
Enter value for lowerbound: 1000000
old 4: where x > &LowerBound
new 4: where x > 1000000
FATWAID
984211
984212
984213
984214
984215
984216
984217
984218
984219
984220
10 rows selected.
Elapsed: 00:00:02.02 -- with 1 million rows also satisfactory but it is not is milliseconds
The same query after using order by clause
SQL> select fatwaid from
2 (select /*+ INDEX(fawtaid pk_fatwa) */ fatwaid, rownum x from fatwa
3 where rownum < &UpperBound ORDER BY fatwaid)
4 where x > &LowerBound;
Enter value for upperbound: 100011
old 3: where rownum < &UpperBound ORDER BY fatwaid)
new 3: where rownum < 100011 ORDER BY fatwaid)
Enter value for lowerbound: 100000
old 4: where x > &LowerBound
new 4: where x > 100000
FATWAID
100032
100033
100034
100035
100036
100037
100038
100039
100040
100041
10 rows selected.
Elapsed: 00:00:00.06
SQL> /
Enter value for upperbound: 1000011
old 3: where rownum < &UpperBound ORDER BY fatwaid)
new 3: where rownum < 1000011 ORDER BY fatwaid)
Enter value for lowerbound: 1000000
old 4: where x > &LowerBound
new 4: where x > 1000000
FATWAID
1000032
1000033
1000034
1000035
1000036
1000037
1000038
1000039
1000040
1000041
10 rows selected.
Elapsed: 00:00:07.03 -- slow
SQL> /
Enter value for upperbound: 1000011
old 3: where rownum < &UpperBound ORDER BY fatwaid)
new 3: where rownum < 1000011 ORDER BY fatwaid)
Enter value for lowerbound: 1000000
old 4: where x > &LowerBound
new 4: where x > 1000000
FATWAID
1000032
1000033
1000034
1000035
1000036
1000037
1000038
1000039
1000040
1000041
10 rows selected.
Elapsed: 00:00:00.06
when I execute the same query again it is bringing records from
the SGA so it is very fast
Now which one to choose from ?
Andrew and Myers queries are good and currently I am using
Myers query.
There should be some technique to do this in the most efficient way.
any input is appreciated. -
Best Practice on querying Data from Database
Hello and I was wondering what is the preferred and best practice for querying data from an SQL database inside a JSP page. Is it using the JSTL library or another method? Thanks
It depends on the size of the application really.
The "correct and preferred" approach in a large MVC app would be to have a seperate class that does all the database access, retrieving the data into java objects.
Check out [url http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html] DAO pattern
You then "save" the data into request/session attributes, and forward to a jsp page to render the result.
Most approaches recommend a separation between JSP (the view) and SQL code.
The JSTL sql tags are provided more for "quick and dirty" code applicable in small applications, or for fast prototyping. That approach is not really robust for large scale applications.
Cheers,
evnafets -
Problem in displaying data onto Form after selecting from table.
Hi there,
I keep hitting this error when I tried to display the data after the selection from table. Using backing beans w data control to do it
Err: java.lang.ClassCastException: java.util.Collections$SingletonList cannot be cast to java.lang.Integer
Table used ArrayList to retrieve out the wanted data. E.g uses A object
To display: selected data to retrieve the selected row to display as a read-only form layout below the table. E.g. need to get A.getName() to match with B object B.getName() then uses the B object to retrieve out the data.
Anyone know how to do it?Hi
use the follwing code
int rowcount = wdContext.node<Name>().size();
while(rs.next())
IPrivate<ViewName>.I<Name>Element tabnode =wdContext.node<Name>().get<Name>ElementAt(i);
tabnode.nodeAuthoriseNode().invalidate();
tabnode.nodeAuthoriseNode().addElement(0,authele);
tabnode.nodeAuthoriseNode().setLeadSelection(0);
wend
Regards
Dhinakar -
How to capture all the rows returned from a sql select query in CPO
Hi,
I am executing an sql select query which returns multiple rows. I need to capture the values of each row to specific variables. How do I proceed.
Thanks,
SwatiThe select activities ("Select from Oracle," Select from SQL Server," etc.) against database already return tables. Use one of the database adapters to do your select, and it will already be in a table form. Just put your query in the select and identify the columns in your result table. The online help or the database adapter guides in the product documentation can help.
-
Oracle SQL Select query takes long time than expected.
Hi,
I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
The query is as follows.
select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
Kindly advice what is going wrong??
Regards,
PurushothamSQL> @/alcatel/omc1/data/query.sql
2 ;
9 rows selected.
Execution Plan
Plan hash value: 3745571015
| Id | Operation | Name |
| 0 | SELECT STATEMENT | |
| 1 | SORT ORDER BY | |
| 2 | NESTED LOOPS | |
| 3 | NESTED LOOPS | |
| 4 | TABLE ACCESS FULL | PARAMETERTABLE |
|* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
|* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
|* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
|* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
Predicate Information (identified by operation id):
5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
6 - access("P1"."ID"="F1"."ID")
7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
8 - access("F1"."ID"="ID")
Note
- rule based optimizer used (consider using cbo)
Statistics
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
0 bytes sent via SQL*Net to client
0 bytes received via SQL*Net from client
0 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
9 rows processed
SQL> -
hi friends,
i've a view called "risk_efforts" with fields user_id,user_name,wknd_dt,week_day,prod_efforts,unprod_efforts.
Name Type
ROW_ID NUMBER
USER_ID VARCHAR2(14)
USER_NAME VARCHAR2(50)
WKND_DT VARCHAR2(8)
WEEK_DAY VARCHAR2(250)
PROD_EFFORTS NUMBER
UNPROD_EFFORTS NUMBER
data is like this:
when there is some data in prod_efforts, unprod_efforts will be null
when there is some data in unprod_efforts, prod_efforts will be null
for example:
USER_ID USER_NAME WKND_DT WEEK_DAY PROD_EFFORTS UNPROD_EFFORTS
G666999 GTest 20100403 TUE null 3
G666999 GTest 20100403 TUE 14 null
now i want to combine these 2 rows into 1 row i.e o/p should be like this
USER_ID USER_NAME WKND_DT WEEK_DAY PROD_EFFORTS UNPROD_EFFORTS
G666999 GTest 20100403 TUE 14 3
i've tried all combinations but couldn't get the query. Please help me with the exact SQL select query.
thanks,
GirishWelcome to the forum.
First read this:
Urgency in online postings
Secondly, it's always helpful to provide the following:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
You have provided #3 and #4. However with no usable form of sample data forum members will often not respond as quickly as they could if you provided #2.
I'm just wagering a guess here but what about this:SELECT ROW_ID
, USER_ID
, WKND_DT
, WEEK_DAY
, MAX(PROD_EFFORTS) AS PROD_EFFORTS
, MAX(UNPROD_EFFORTS) AS UNPROD_EFFORTS
FROM RISK_EFFORTS
GROUP BY ROW_ID
, USER_ID
, WKND_DT
, WEEK_DAY -
Hi All,
I'm new to XMLPublisher so i'll try to explain the best i can the problem i'm having creating a Data Model for my report.
I'm using Database XE and have installed XMLPublisher, as XE is extremely flexible in creating apps i'm having huge trouble finding a reporting solution for my applicaiton. I have created an app to track and control time and expense which i want to generate timesheet, expense sheets, invoice etc from.
Having done some read i think XML is the best approach for me however i'm having huge troubles with my data model.
EXAMPLE:
I have 2 tables to start with, first table holds client information and the second table holds project information. One client can have many projects.
When i create the Data Model using SQL i get the obvious problem that when a client has more then one project my XML structure is incorrect.
SELECT gc.name AS CLIENT,
gp.name AS PROJECT
FROM gte_client gc,
gte_project gp
WHERE gc.client_id = gp.client_id(+)
The above SQL creates the following XML
- <ROWSET>
- <ROW>
<NAME>Symatrix Ltd</NAME>
<NAME>Symatrix Pre-Sales</NAME>
</ROW>
- <ROW>
<NAME>Aston Carter</NAME>
<NAME>MOD</NAME>
</ROW>
- <ROW>
<NAME>Symatrix Ltd</NAME>
<NAME>Fujitsu</NAME>
</ROW>
</ROWSET>
Obvious problem here is the fact that client Symatrix appears twice as there are 2 projects.
I have tried to write SQL/XML and i think i'm beginning to understand the structure of the XML functions however XMLPublisher doesn't appear to understand the syntax when creating a SQL Query for the data model.
I hope all this makes sense.
Kind Regards
GlenHi All,
Ok, so with a little searching through documents and articles on the web i found this information.
http://blogs.oracle.com/xmlpublisher/2006/05/05#a38
this details the exact thing i'm trying to achieve so anyone else who searches this forum with a similar problem check this out.
Regards
Glen -
JSTL sql:query date field has zero time part
I have a little JSP where I am using JSTL to do a query against a table "ph_application" that has a date field "rundate". This field has many different dates and times in it.
Here is the code snippet:
<sql:setDataSource url="jdbc:oracle:thin:@oraprd02:1521:ipp4" user="site" password="pmc_site"/>
<sql:query var="application" sql="select * from ph_application"/>
<c:forEach items="${application.rows}" var="row">
<tr>
<td><c:out value="${row.name}" default=" " escapeXml="false"/></td>
<td><fmt:formatDate value="${row.rundate}" type="both"/></td>
</tr>
</c:forEach>
The resulting date/time output always has a 12:00:00 AM time regardless of what is actually in the table. I have changed the fmt:formatDate to a c:out of the row.rundate.time value and it appears that the time part of the date is actually zero at this point.
Is there an inconsistancy between the oracle date type and what JSTL is expecting (somewhere)?
Any help and/or verification is appreciated.
RichardI'm running this from within JDeveloper 10g.
-
Can I retrieve data from a multiple select query?
I recently have been able to consolidate many queries into one large one, or into large compound queries. I found an instance where I am using a select query in a for loop that may execute up to 400 times. I tried building a huge compound query, and using DB Tools Execute Query vi, followed by the DB Tools Fetch Recordset Data vi. The query executes at the database without an error, but the Fetch Recordset Data vi only returns the first instance. Is there a way to retrieve all the data without having to send up to 400 separate select queries?
Sorry I didn't replt earlier, I was on vacation. The query I am using is to check serial numbers, and determine if they are all valid. The programs purpose is to define a serial number to a pre-existing part number. Our company makes inclinometers and accelerometers, and this entire series of LabVIEW programs is designed to automate the calibration and testing of these units. The part number definitions can contain 3 or 4 hundred parameters, so the database itself consistes of 44 tables with potentially several hundred columns per table. It is designed to not only provide definitions to every part number, but also to store all potential raw unit data to be calculated and formed into a report at any time. The logistics of getting that much data in and out of the database have forced me to do things more effeciently. The actual query in question is to take each serial number either manually entered, or automatically picked, and see if they already exist with the part number they are being defined as. If there are any duplicates, then the program will alert the operator that serial numbers x, y, and z for instance have already been asigned as the part number in question. Currently I run a simple query once for each serial number. This works, but there may be 200 serial numbers assigned. Also the serial numbers can contain upper or lower case letters. By making all the serial number letters into capitals, then into lower case, it could mean up to 400 individual queries going out over the LAN. This is a bandwidth hog, and time consuming. I started experimenting with compound queries. The actual query used is below.
SELECT SERIALNO FROM "maintable" WHERE PARTNO = '475196-001' AND SERIALNO = '3000005';SELECT SERIALNO FROM "maintable" WHERE PARTNO = '475196-001' AND SERIALNO = '3000006';SELECT SERIALNO FROM "maintable" WHERE PARTNO = '475196-001' AND SERIALNO = '3000007';SELECT SERIALNO FROM "maintable" WHERE PARTNO = '475196-001' AND SERIALNO = '3000008';SELECT SERIALNO FROM "maintable" WHERE PARTNO = '475196-001' AND SERIALNO = '3000009'
When I execute this query, SQL Server 2000 has no problem with it, but the DB Tools Fetch Recordset Data vi only returns the first match. I think my answer may lie with OR statements. Rather than sending what amounts to potentially dozens of individual queries, I should be able to chain them into one query with a lot of OR statements. As long as the OR statement is not an exclusive OR statement, I think it should work. I haven't tried it yet, and it may take some time to get the syntax right. The query is built in a for loop with the number of iterations equal to the number of serial numbers being defined. Once I get this working I will alter it to include both upper and lower case letters that can be included in the query. Any suggestiona of how the query should be structured would be most helpful, or another way to achieve what I am trying to accomplish.
SciManStev
Maybe you are looking for
-
Update error: POL - 4008 null buffer for attribute is not allowed
I am attempting to update a column in my Oracle Lite database through JDBC. The statement is: ds = getDataSource(); conn = getConnection(ds); stmt = getStatement(conn); int results = stmt.executeUpdate("UPDATE SYSTEM.PM_PASSENGERS SET CURRENT_STATUS_
-
CHARACTER TO DECIMAL Conversion
hi all , i get data from a flat file for one column i am getting 65900 650 754399 for eg : 65900 i should insert into table as 659.00 for : 754399 i should insert into table as 7543.99 The last two digits should be separated i cant change the datatyp
-
Love the iPhone, Verizon is not the same.
My other half purchased an iPhone for me two weeks ago. I have had zero problems with the iPhone itself and I am very pleased. No freezing, crashing, dropped calls (unless there is little or no signal) it's really helpful to me and my busy life. Up
-
Dear Experts, I need a clarification How does Process message work in PP PI sheet See as i know control recipe is created when process order is released For setting point of control recipe destination and instruction category is assigned in Ma
-
How could I bind a Matrix Colum (EditText)
How can I bind a matrix column to a table with an column e.p Table: xy Colum: zy MatrixcolumID = 5 Thx for regards