Select only numbers from database
Hi All,
I need to retrieve numerical data's from the database. Data base table has both numerical and text values. now I want to retrieve only numerical data's.
Can any one help me on this,
Thanks and helps will be appreciated.
Hi,
did you try like this ?
SELECT * FROM database INTO t_inter WHERE field1 = crit1.
LOOP AT t_inter into w_intern WHERE field1 CO '0123456789'.
ENDLOOP.
or
LOOP AT t_inter into w_intern.
CHECK w_intern-field1 CO '0123456789'
ENDLOOP.
Regards,
David
Similar Messages
-
Help with this sql. Select only employees from a distinct Org??
Hi guys, simple query.
create table balancetest(emp_id number, balance_id number, balance number, org number);
insert into balancetest values (111, 1, 1, 0);
insert into balancetest values (111, 1, 1, 0);
insert into balancetest values (111, 2, 1, 1);
insert into balancetest values (222, 1, 2, 1);
insert into balancetest values (333, 3, 4, 3);
insert into balancetest values (333, 3, 4, 2);
commit;
SQL> select * from balancetest;
EMP_ID BALANCE_ID BALANCE ORG
111 1 1 0
111 1 1 0
111 2 1 1
222 1 2 1
333 3 4 3
333 3 4 2
6 rows selected.As you can see, emp_id 111 appears on different Org (0 and 1). I need to calculate the balance but the requirement says that I need to retrieve employees appearing only in 1 org.. It won't matter which org is selected (the business rules ensure balance will be the same), as long as if an employee is in multiple org, this employee is selected only once for an org. So, my result will be something like:
EMP_ID BALANCE_ID BALANCE ORG
111 1 1 0
111 1 1 0
222 1 2 1
333 3 4 3
333 3 4 2or,
EMP_ID BALANCE_ID BALANCE ORG
111 2 1 1
222 1 2 1
333 3 4 3
333 3 4 2In other words, an employee must appear only in 1 org in my result.
any ideas? I tried:
select * from balancetest bal1
where not exists ( select bal2.emp_id from
balancetest bal2
where bal2.emp_id = bal1.emp_id
and bal2.org <> bal1.org
);But I guess it won't be that simple!!Hi,
You can find the lowest-numbered org for each employee like this:
SELECT emp_id
, MIN (org) AS min_org
FROM balancetest
GROUP BY emp_id;You can get the results you want by selecting only rows from balancetest that match a row in this the result set above. There are many ways to do that, such as a join:
WITH g AS
SELECT emp_id
, MIN (org) AS min_org
FROM balancetest
GROUP BY emp_id
SELECT b.*
FROM balancetest b
JOIN g ON b.emp_id = g.emp_id
AND b.org = g.min_org; -
Installation: hello, I am trying to install my adobe elements twelve. I have a serial number, which contains no letters (only numbers), from the box. I use a mac. When I try to install it, it says it's unable to validate my serial number. I have already checked the spelling. What should I do?
Does it begin with 1057? If not, it's a redemption code. In which case, see here:
Redemption Code Help
If it is a serial number, go to system preferences>security & privacy>firewall>firewall options and be sure that PSE is allowed to call out. -
Restrict a textInput component to accept only numbers from 0 to 250
I want to restrict a textInput component to accept only
numbers from 0 to 250. I know I can use restrict to some degree but
all I can do is restrict it to 0-9 and use maxChars to 3 which
allows any number from 000-999.
I believe I could use the TextEvent.TEXT_INPUT and then write
some code that will convert that event's text (i.e. the text
entered into textInput component before it is actually added to the
textInput component's text value) such that I do not allow values
greater than 250 but I'm not sure what that code would be. Does
anyone know an easier way to do this?use the change event to monitor the input value and if it's
greater than 250 (after typing the text property as a number),
assign the text property to be "250". -
Selecting the data from database and sending to users using javamail
how to select the records from database table in oracle and send automatically to users using javamail. I am able to send the txt msg. but dont know how to send the selected table data to users automatically.
can anyone suggest how to write the steps with database connection to send msgs containing data to different users
Thank Youusing JDBC..you want to
1. create the connect
2. open the connection
3. query the table for the data
4. loop through the resultset to retrieve rows of data
5. do something with the data
6. email the result
once you have the data, it is up to you to determine the format to send to the user using JavaMail. It is easiest to send plain text
here's a site that give code example (for all steps above relating to JDBC):
http://javaalmanac.com/egs/java.sql/pkg.html -
Dear all experts,
I am able to populate all fields data from database table, using dynamic table creation.
eg,
SELECT * FROM (w_tabname) INTO TABLE <t_itab>.
where w_tabname is the table name given by the user, and t_itab is field symbol.
but some requirement is like that i need to pick up only few fields, <b>which user will give at the runtime.</b>
<b>I can</b> take those fields from file into any internal table,
but the problem is that instead of <b>select *</b>, i need to put selected the fields given by user.
i have tried with field symbol, it is not working (as per my knowledge.)
do i need to create any structures dynamically ?
Can anybody please help in this regards ?
Your help will be surely rewarded with points.
Waiting for reply..
Regards
VinayHi Vinay ,
Adding to the below code , you can use some more fields in the select stmt as below:-
REPORT ychatest.
PARAMETERS : p_field1 LIKE dd03l-fieldname,
P_field2 LIKE dd03l-fieldname,
p_table LIKE dd03l-tabname.
FIELD-SYMBOLS : <fs> TYPE STANDARD TABLE.
SELECT (p_field1) (p_field2) ( FROM (p_table) INTO TABLE <fs>.
Now p_field1 & p_field2 belong to the same table since you have give the user to enter only one table name.
This should work fine.
please try & let me know .
Thanks & Regards,
Daniel -
Select only items from a vendor on PO
Hello,
When I create a Purchase Order from B1 2005, for a certain vendor, I'd like to see only the list with the items bought from that vendor when I select an item, instead of the entire list of items. Is there a configuration for that, or do I have to configure it on my own, by script?
Thank you,
IrinaThanks. I've understood the method, but I have a problem with queries.
I have the following query for what i'm searching:
SELECT T0.ItemCode FROM OITM T0 INNER JOIN OPOR T2 ON T0.ItemCode = T2.ItemCode WHERE T2.CardCode = $[OPOR.CardCode]
but I get the following error:
[SQL Server]"Incorect syntax near OPOR.CardCode".
Also I get errors when I try to run the queries from the SBO_Help.chm samples.
Do you have any idea why?
Thank you,
Irina -
11g p2 / bug - select in navigator from database offline object editor
It is no more possible to use the context menu "Select in Navigator" from the database offline object editor (a package body in my case). I got a message "Command not handled".
This appear in all my packages and body.
After restarting JDev and test again I got this message "Error encountered:
The Offline Database file is missing. Please recreate Offline Database "1" with the correct settings.
This object in file ADMINPROCTABLE.type will be unavailable."
Is it a way to correct this ?I completely reinstall JDev and set it to use subversion ... that resolve the problem and i'm no more in a position to reproduce it.
-
Selecting only columns from a table
Could someone help me with a SQL query to select all the columns in a table as an array?
Hello
if you are on 9i upward, you can define a pl/sql table of the rowtype and use bulk collect to populate that table, otherwise, you can create separate array types for each column:
create table dt_test_tab (id number, col1 varchar2(10));
insert into dt_test_tab values(1, 'X');
insert into dt_test_tab values(2, 'X');
insert into dt_test_tab values(3, 'X');
insert into dt_test_tab values(4, 'X');
insert into dt_test_tab values(5, 'X');
commit;
declare
type tt_TestTab is table of dt_test_tab%rowtype index by binary_integer;
type tt_TestTabid IS TABLE OF dt_test_tab.id%type index by binary_integer;
type tt_TestTabcol1 IS TABLE OF dt_test_tab.col1%type index by binary_integer;
lt_TestTab tt_TestTab;
lt_Id tt_TestTabId;
lt_col1 tt_TestTabcol1;
begin
--use the rowtype array
select
id,
col1
BULK COLLECT INTO
lt_testtab
FROM
dt_test_tab;
--use the individual column arrays
select
id,
col1
BULK COLLECT INTO
lt_id,
lt_col1
FROM
dt_test_tab;
dbms_output.put_line('loop through the rowtype array');
FOR x in lt_TestTab.FIRST..lt_TestTab.LAST LOOP
dbms_output.put_line(to_char(lt_TestTab(x).id)||to_char(lt_TestTab(x).col1));
end loop;
dbms_output.put_line('loop through the two column arrays');
FOR x in lt_Id.FIRST..lt_Id.LAST LOOP
dbms_output.put_line(to_char(lt_Id(x))||to_char(lt_Col1(x)));
end loop;
END; -
How to log in with user credentials from database table
Hello all.
I have a table named users_1 in my database. This table has columns named username, password, email and userid. On userid, I have put a sequence.
Now, I have manually made 1 row in this table, with in it the user credentials.
How can I edit my application so that I can use these credentials to log onto the application?
Please, a step-by-step text would make me rather happy, instead of getting a link with information that I should read. I've read most of it, and it just doesn't make any sense to me, so I prefer a guide-trough.
Thanks..Hi Magali,
You want only user from database can access your application.
follow the steps given below.
Step1 : create function to authenticate users
create or replace FUNCTION "CUSTOM_AUTHENTICATE" (p_username in VARCHAR2, p_password in VARCHAR2)
return BOOLEAN
is
l_password varchar2(4000);
l_stored_password varchar2(4000);
l_count number;
begin
select count(*) into l_count from users_1 where upper(username) = upper(p_username);
if l_count > 0 then
select upper(password) into l_stored_password from users_1 where upper(username) = upper(p_username);
l_password := upper(p_password);
if l_password = l_stored_password then
return true;
else
return false;
end if;
else
return false;
end if;
end;
Step2 : create authentication scheme for your application
Go to Application Builder->select your application->shared component->security->authentication scheme->create
a) custom scheme : Based on a pre-configured scheme from the gallery
b) give some name to your scheme like custom_scheme or something
c)scheme type : database account
d) verify function name = return CUSTOM_AUTHENTICATE
e) go to = Login Page
f) Logout url = f?p=&APP_ID.:101 // here 101 is login page no..so you can set your login page no.
step3 : make this scheme as current scheme
select your scheme and click make current
now try to login into your application from your database users..
Hope this will helps you,
Thanks,
Jitendra -
Hello,
we just installed the patch 10.0.2.0.5 on a 10.0.2.0.3 database and some selects didn't work as before. While changing the select clause, there are diffent counts.
There are 3 tables:
Detail_1 => MASTER_1 <= Detail_2
MASTER_1 has a primary and an unique Key. The 2 detail tables have FK. Now when selecting only columns from the detail tables (joined with master) we get cartesian selects. If i use one column of the master table in the select clause everything is fine.
Here is an example:
CREATE TABLE MASTER_1
( "KUNID" NUMBER NOT NULL ENABLE,
"CUSTOMER_NO" VARCHAR2(20 BYTE),
CONSTRAINT "PK_MASTER1" PRIMARY KEY ("KUNID"),
CONSTRAINT "UK_MASTER1" UNIQUE ("CUSTOMER_NO"));
CREATE TABLE DETAIL_1
( "CUSTOMER_NO" VARCHAR2(20 BYTE),
CONSTRAINT "FK_DETAIL1" FOREIGN KEY ("CUSTOMER_NO") REFERENCES "MASTER_1" ("CUSTOMER_NO"));
CREATE TABLE DETAIL_2
( "KUNID" NUMBER,
CONSTRAINT "FK_DETAIL2" FOREIGN KEY ("KUNID") REFERENCES "MASTER_1" ("KUNID")) ;
INSERT INTO MASTER_1 VALUES(1,'A');
INSERT INTO MASTER_1 VALUES(2,'B');
INSERT INTO DETAIL_1 VALUES ('A');
INSERT INTO DETAIL_1 VALUES ('B');
INSERT INTO DETAIL_2 VALUES ('1');
INSERT INTO DETAIL_2 VALUES ('2');
INSERT INTO DETAIL_2 VALUES ('1');
INSERT INTO DETAIL_2 VALUES ('2');
INSERT INTO DETAIL_2 VALUES ('1');
INSERT INTO DETAIL_2 VALUES ('2');
COMMIT;
SELECT a.*
FROM MASTER_1 b,
DETAIL_1 a,
DETAIL_2 c
WHERE a.CUSTOMER_NO = b.CUSTOMER_NO
AND b.KUNID = c.KUNID
AND a.CUSTOMER_NO = 'A';
The Result on a 10.0.2.0.3.0 Database for different select clauses
SELECT a.* => 3 Row Selected
SELECT b.* => 3 Row Selected
SELECT c.* => 3 Row Selected
The Result on a 10.0.2.0.5.0 Database for different select clauses
SELECT a.* => 6 Row Selected
SELECT b.* => 3 Row Selected
SELECT c.* => 6 Row Selected
So you see, we get different rows only by changing the select clause.
Note: It seemed to be important to have both FK. When deleting one of them - or both - we get the same correct results: 3 rows with any select clause.
IS this a bug or have we to change our sql?
Regards
Rudi ZugreifHi,
thanks for your reply.
The alter session works, but even so I will contact ORacle Suppoer
The explain plan (before alter session):
Explain Plan for 10.2.0.5
SELECT a.* (6 Rows)
MERGE JOIN CARTESIAN
TABLE ACCESS FULL DETAIL_1
BUFFER SORT
TABLE ACCESS FULL DETAIL_2
TABLE ACCESS FULL DETAIL_1
BUFFER SORT
TABLE ACCESS FULL DETAIL_2
SELECT b.* (3 Rows)
NESTED LOOPS
TABLE ACCESS BY INDEX ROWID MASTER_1
INDEX UNIQUE SCAN UK_MASTER1
TABLE ACCESS FULL DETAIL_1
TABLE ACCESS FULL DETAIL_2
HASH JOIN
NESTED LOOPS
TABLE ACCESS BY INDEX ROWID MASTER_1
INDEX UNIQUE SCAN UK_MASTER1
TABLE ACCESS FULL DETAIL_1
TABLE ACCESS FULL DETAIL_2
Explain Plan for 10.2.0.3
SELECT a.* (3 Rows)
NESTED LOOPS
TABLE ACCESS BY INDEX ROWID MASTER_1
INDEX UNIQUE SCAN UK_MASTER1
TABLE ACCESS FULL DETAIL_1
TABLE ACCESS FULL DETAIL_2
HASH JOIN
NESTED LOOPS
TABLE ACCESS BY INDEX ROWID MASTER_1
INDEX UNIQUE SCAN UK_MASTER1
TABLE ACCESS FULL DETAIL_1
SELECT b.* (3 Rows)
HASH JOIN
NESTED LOOPS
TABLE ACCESS BY INDEX ROWID MASTER_1
INDEX UNIQUE SCAN UK_MASTER1
TABLE ACCESS FULL DETAIL_1
TABLE ACCESS FULL DETAIL_2regards
Rudi
Edited by: gogetter on Jul 27, 2010 1:19 AM -
HOWTO?: select a subset from a self defined static list
I have the follwing problem:
I have:
1- a list of numbers (outside of the database)
2- a database table with another list of numbers
I want:
- To select the numbers from the list outside of the database, that are not in the database table.
- It must be formatted into a single query.
- Without building a new table and preferably without loading the values.
Thx in advance guysI have the follwing problem:
I have:
1- a list of numbers (outside of the database)Where? On a piece of paper? In a file? In your head? Recorded as an mp3?
2- a database table with another list of numbers
I want:
- To select the numbers from the list outside of the
database, that are not in the database table.
- It must be formatted into a single query.
- Without building a new table and preferably without
loading the values.
Thx in advance guysWell, lets say they're in a file like
1
2
5
6
and the database table has 1,2,3,4.
Use UTL_FILE to read in the file and then either do a lookup as each value is read in, or get fancy with collections and casting to table. -
Select only the last 12 months
Hi all
I need to write a query that will select only records from the last 12 months, order them by customer ID, and show one column per month, and a Total column where I need to add monthly Values.
The table has the following fields
• YearMonth varchar(6)
• CustomerID varchar(15)
• Value integer
Records example
- 200809, 1, 10
- 200809,2,20
- 200808,1,15
- 200808,2,12
- 200501, ….
I need to write a query and place it in a view that will select only records from the last 12 months, order them by customer ID, and show one column per month, and a Total column where I need to add monthly Values.
The results should display the:
• CustomerID,
• one column per month displaying the Value
• and the total column (sum monthly values for a customer)
My questions are:
• How do I select records only from the last 12 months
• How do I name dynamically the columns, because today October,15 the list will start in November 2007 through October 2008, but next month it will move from December 2007 through October 2008
• How do I create a view with dynamic columns
• How do I create a column totals
Please adviceHi,
user631364 wrote:
... My questions are:
• How do I select records only from the last 12 monthsThere a a couple of things you could mean by "the last 12 months".
Hkandpal showed you one way.
Another is
WHERE yearmonth >= TO_CHAR (ADD_MONTHS (SYSDATE, -11), 'YYYYMM')
AND yearmonth <= TO_CHAR ( SYSDATE, 'YYYYMM')Storing DATEs in a VARCHAR2 column (or in any type of column other than DATE) is a bad idea. At best, it will involve lots of conversions, like those above.
• How do I name dynamically the columns, because today October,15 the list will start in November 2007 through October 2008, but next month it will move from December 2007 through October 2008
• How do I create a view with dynamic columns
How to Pivot a Table with a Dynamic Number of Columns
For example, you want to make a cross-tab output of
the scott.emp table.
Each row will represent a department.
There will be a separate column for each job.
Each cell will contain the number of employees in
a specific department having a specific job.
The exact same solution must work with any number
of departments and columns.
(Within reason: there's no guarantee this will work if you
want 2000 columns.)
PROMPT ========== 0. Basic Pivot ==========
SELECT deptno
, COUNT (CASE WHEN job = 'ANALYST' THEN 1 END) AS analyst_cnt
, COUNT (CASE WHEN job = 'CLERK' THEN 1 END) AS clerk_cnt
, COUNT (CASE WHEN job = 'MANAGER' THEN 1 END) AS manager_cnt
FROM scott.emp
WHERE job IN ('ANALYST', 'CLERK', 'MANAGER')
GROUP BY deptno
ORDER BY deptno
PROMPT ========== 1. Dynamic Pivot ==========
-- ***** Start of dynamic_pivot.sql *****
-- Suppress SQL*Plus features that interfere with raw output
SET FEEDBACK OFF
SET PAGESIZE 0
SPOOL p:\sql\cookbook\dynamic_pivot_subscript.sql
SELECT DISTINCT
', COUNT (CASE WHEN job = '''
|| job
|| ''' ' AS txt1
, 'THEN 1 END) AS '
|| job
|| '_CNT' AS txt2
FROM scott.emp
ORDER BY txt1;
SPOOL OFF
-- Restore SQL*Plus features suppressed earlier
SET FEEDBACK ON
SET PAGESIZE 50
SPOOL p:\sql\cookbook\dynamic_pivot.lst
SELECT deptno
@@dynamic_pivot_subscript
FROM scott.emp
GROUP BY deptno
ORDER BY deptno
SPOOL OFF
-- ***** End of dynamic_pivot.sql *****
EXPLANATION:
The basic pivot assumes you know the number of distinct jobs,
and the name of each one. If you do, then writing a pivot query
is simply a matter of writing the correct number of ", COUNT ... AS ..."\
lines, with the name entered in two places on each one. That is easily
done by a preliminary query, which uses SPOOL to write a sub-script
(called dynamic_pivot_subscript.sql in this example).
The main script invokes this sub-script at the proper point.
In practice, .SQL scripts usually contain one or more complete
statements, but there's nothing that says they have to.
This one contains just a fragment from the middle of a SELECT statement.
Before creating the sub-script, remember to turn off SQL*Plus features
that are designed to help humans read the output (such as headings and
feedback messages like "7 rows selected.", since we do not want these
to appear in the sub-script.
Remember to turn these features on again before running the main query.
• How do I create a column totalsIn SQL*Plus, use the BREAK command.
In SQL, "GROUP BY ROLLUP" or "GROUP BY GROUPING SETS" -
How to get time specification detail from database
Dear All,
How can I get the time specification detail from data base?
Time specification is a 32 bit hexadecimal no type guid_32.
Function wfd_timespec_reload provide the modified time specification detail.
FUNCTION wfd_timespecs_reload
""Local Interface:
*" IMPORTING
*" VALUE(I_LOGSYS) TYPE LOGSYS
*" VALUE(I_AWTYP) TYPE WFD_AWTYP
*" VALUE(IT_TIMESPEC_KEYS) TYPE WFD_KEY_TAB
*" EXPORTING
*" VALUE(ET_TIMESPEC_DETAILS) TYPE WFD_TIMESPEC_TAB
*" VALUE(ET_INVALID_TIMESPECS) TYPE WFD_KEY_TAB
*" VALUE(ET_CHANGED_TIMESPEC_KEYS) TYPE WFD_KEY_TAB
*" VALUE(ET_RETURN) TYPE BAPIRET2_T
This function take time spec from data base not from cache(buffer) so provide the modified time spec in the same session.
I need any newly created time specification detail also. So I can show all the time spec detail in my function module for any user in the same session.
Can anyone provide the sample code for it?
Thanks,
Anup GargYes I can see the pattern.
When I get the set of numbers from database UI doesn't know what is the the list of numbers database has. I need to choose some next available number that is not in database. In the list that u are talking about next available number is 7. Its something similar to when we try to create any mailid, while registration it gives some default id which is not existing which user can choose to create his mailid. How can I get similar feature? -
Getting 10th oldest from database
Getting the oldest persons name from a database is easy.
SELECT name
FROM database
WHERE dob = ( SELECT MIN(dob) FROM database ) ;
but how would you get the 10th oldest or 100th oldest
RegardsHi,
Because of you can have more than one with the same age in database, you need to use dense_rank() function :
SQL> select name,age, rank() over(order by age asc) from age;
NAME AGE RANK()OVER(ORDERBYAGEASC)
TOTO 10 1
TRUC 10 1
TITI 20 3
TUTU 20 3
SQL> With previous code, if I search the second oldest, I found nothing... also the following query can help :
SQL> select name,age, dense_rank() over(order by age asc) from age;
NAME AGE DENSE_RANK()OVER(ORDERBYAGEASC)
TOTO 10 1
TRUC 10 1
TITI 20 2
TUTU 20 2
HTH,
Nicolas.
Message was edited by:
N. Gasparotto
In my queries, I replace yougest by oldest like requirements, sorry.
Maybe you are looking for
-
K9N Platinum doesn't read SPD correctly
K9N Platinum doesn't read SPD correctly. When i put any RAM to my computer and set timings to auto it always set timing to 5-6-5-15 ignoring SPD on RAM/RAMs. Is it only my board problem? or all K9N Platinums? I have 601-7250-020.... i use 1.5 bios,an
-
Passing the values from subreport to master report in JasperReports
Hi All, I want to pass the values from subreport to master report, but my subreport is without any query. Please help me in this regard. its urgent. Thanks & Regards Kris
-
Using Skype Mobile while traveling in Europe
I have a Verizon Samsung Fascinate with Skype installed. I have bought credits. I will soon be traveling to Belgium and France. I have been told by Verizon that my phone will not work in Europe. However, when my husband talked to a representative
-
Transfer only selected data from one .pdf to another using hyperlink
I have a form that has mutiple pages. On one of the forms, I have created a hyperlink to open a different form. My objective is to be able to click on the hyperlink and transfer some of the data from the original form to the hyperlink form. Is tha
-
[svn:fx-trunk] 9178: Fix the build.
Revision: 9178 Author: [email protected] Date: 2009-08-07 15:01:37 -0700 (Fri, 07 Aug 2009) Log Message: Fix the build. removed duplicate line left in comment Modified Paths: flex/sdk/trunk/frameworks/projects/rpc/src/mx/rpc/xml/SimpleXMLE