Add additional columns to a select * statement?
is there a way to do something like:select *, table_A.value*.25 from table_A
Thank youEdited by: nwill on January 14, 2010 08:14
'25' is a constant? If I understand you right, you can do this:
select table_A.*, 25 from table_A;
Tags: Database
Similar Questions
-
Get the types of columns in a select statement
Hello
Is there a way to get the types of columns that results in a select statement?
For example to force an analysis on this topic and then look for the types of columns resulting in the view v$?
Best regards
Klaus Mogensen
declare c number; d number; col_cnt integer; rec_tab dbms_sql.desc_tab; col_num number; begin c := dbms_sql.open_cursor; dbms_sql.parse(c, 'select dummy, 33 x, sysdate now from dual', dbms_sql.native); dbms_sql.describe_columns(c, col_cnt, rec_tab); col_num := rec_tab.first; while col_num is not null loop dbms_output.put_line( rec_tab(col_num).col_name || ' ' || case rec_tab(col_num).col_type when 1 then 'varchar2' when 2 then 'number' when 12 then 'date' else '???? ' || rec_tab(col_num).col_type end ); col_num := rec_tab.next(col_num); end loop; dbms_sql.close_cursor(c); end; / DUMMY varchar2 X number NOW date
-
R12 payment process Request Status Report add additional columns to the XML data.
In 11i, we had modified the preliminary report of payment to include additional columns (distributions of invoice). R12, this report is obsolete and Oracle introduced a new report 'Payment process Request Status Report'. This query uses BI Publisher to generate the release of the final report. I can't edit the template for the output XML to the report has not
contains data for distribution invoice account. We need to know how we can modify the XML data to include additional columns.
For the disbursement of funds (payment instructions file) process, Oracle provides extensibility IBY_FD_EXTRACT_EXT_PUB package to build the custom XML element structure that can be added to the extracted XML payment generated by the Oracle payments. Do we have something similar to this report? Are there other options available?
Thank youHello
The same "IBY_FD_EXTRACT_EXT_PUB" package also works for the payment request process status report. Please add the logic to get the distribution data in this package, and you'll see the new XML tags in this report also.
I hope this helps.
Serge -
Query that returns number 1 - Add additional columns based on percentages
I have a query that returns a large number. The return value will always be a single field (a column, a line, a single value).
I need to have also three other columns in the return of this request: one that returns a number that is 50% of the original number, one that returns a number that is 75% of the original number, and one that is double the original number. How is that possible? If anyone can point me to examples, it would be a great help. I got the results mixed by searching, so I'm not sure good practices.
Thank you for the input in advance.
Hello
Whenever you have a question, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the accurate results you want from this data, so that people who want to help you can recreate the problem and test their ideas.
Explain, using specific examples, how you get these results from these data.
If you show what you want to do using commonly available tables, like those of the scott schema, then you don't need to display the sample data; just results and explanations.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: Re: 2. How can I ask a question on the forums?
I'm not sure that understand the question.
If x is a number, then
.50 * x is 50% of this number,
.75 * x is 75% of that number, and
2 * x is to double this figure.
You can get them all in the same query, if you want to. For example:
SELECT ename
sal
.50 * sal AS p_50
.75 * sal AS p_75
2 * sal AS dbl
FROM scott.emp;
Output:
ENAME SAL P_50 P_75 DBL
---------- ---------- ---------- ---------- ----------
SMITH, 800, 400, 600, 1600
1600 800 1200 3200 ALLEN
1250 625 WARD 937,5 2500
JONES 2975 1487.5 2231,25 5950
1250 625 MARTIN 937,5 2500
2850 1425 BLAKE 2137,5 5700
2450 1225 CLARK 1837,5 4900
3000 1500 2250 6000 SCOTT
KING 5000 2500 3750 10000
1500 750 1125 3000 TURNER
1100 550 825 2200 ADAMS
JAMES 950 475 712,5 1900
FORD 3000 1500 2250 6000
1300 650 975 2600 MILLER
Is that what you ask?
-
Cannot change the value in the report url column in the select statement. Help, please
Hi all
I'm moving the value of the column of the report as follows:
And I'm passing the values as follows:select key, num, case when Attachmentcnt(KEY) != 0 then 'f?p=&APP_ID.:91:&SESSION.:'' '':NO::P91_KEY,P91NUM,P91_PREVPG:'
{noformat}
"#KEY #, ' NUM # #', 9' ELSE null.
Fixing of END
from tableA
{noformat}
But I'm not able to understand correct syntax for these column values. Can someone give me help. I appreciate it.
Rgds,
Suma.
Published by: sumak on June 23, 2009 12:11
Published by: sumak on June 23, 2009 12:22Suma,
If you try to generate a column with a URL, try something like the following:
Select the key, num,
-case when Attachmentcnt (KEY). = 0 then
' f ? p = & APP_ID.: 91: & SESSION. : "": NO::P91_KEY, P91NUM, P91_PREVPG:'
|| tableA.key | ',' || tableA.num | ',' || : P91_PREVPG
Another null
end
FROM tableA;But the best way to spend these would include values of checksum against the values of your parameters (to ensure that a user is not hack them). You will need to check the manual of the Apex for more details - see "Understanding Session State Protection".
Good luck
Stew
-
Oracle BPM 12.2.1 workspace how to add additional columns to the DB table tasklist
Hi all
I need to add some required columns to the table from the list of tasks (for example, activity and status of the activity referred to in the task line), I decompiled adflibTaskListTaskflow.jar and found a class named TaskModel.class in this package: oracle.bpel.worklistapp.tasklist.beans.model, if decompile you this class, you can see that at the table from the list of tasks, data are expressed here by using ITaskQueryService now how more columns may add other tables or is there another easier solution?
Hi Hadi,
You can add columns to your table of task list in the workspace by changing the current view, or even create a new (more and icons in pencil). The situation of activity is available in the list of columns.
You can also add columns to the list view based on flexfields tasks that you create.
If you manually change the adflibTaskListTaskflow.jar you can have problems in the future given that libraries can change between versions and of course are not recommended to do.
I have add columns to the list of tasks, and at that time here, we have created a list of custom task based on BPM Middleware. If you follow this method, you will have complete freedom to show what you want.
-
NVARCHAR2 column in the select statement of the query
HelloI have table
xx_test / / DESC
Name of Type Null
-------- -------- --------------
COL1 NOT NULL NVARCHAR2 (100)
COL2 NOT NULL NVARCHAR2 (100)
COL3 NOT NULL NVARCHAR2 (100)
I am able to interview
Select * from xx_test
However if the query as
Select col1 from xx_test
Then it is in error.
ORA-00904: "COL1": invalid identifier
00904, 00000 - '% s: invalid identifier '.
* Cause:
* Action:
Error on line: column 3-131: 13
Let me know how interrogate NVARCHAR2 column and how can we put in WHERE condition?
Thank you
Abhijit
Abhijit,
Now that you have already re-created the table, it would be difficult to find the exact cause. But I suspect it could happen due to the creation of table in a way not recommended the use of quotes.
If you use double quotes while creating the table/column names, you must always use capital letters. Better is not not to use quotes in all. Here is an example of a test that could be the cause of your error.
SQL > drop table test;
Deleted table.
SQL > create table test ("col1" nvarchar2 (200), col2 varchar2 (200));
Table created.
SQL > select Col1 from test;
Select Col1 from test
*
ERROR on line 1:
ORA-00904: "COL1": invalid identifier - it is him you got. Even if there is col1 column in the table, but I'm unable to select due to the bad way to appoint.
SQL > drop table test;
Deleted table.
SQL > create table test ("COL1" nvarchar2 (200), col2 varchar2 (200));
Table created.
SQL >
SQL > select col1 from test;
no selected line
The test case above apply to the tables as well.
Ishan
-
By using the parameter as a column in a select statement inside the stored procedure.
I'm doing a variation of what follows. Can someone tell me how to use the parameter passed in the IN clause correctly? Thank you
Deleted table.drop table test1; drop table test2; CREATE TABLE TEST1 ( COL1 NUMBER ); CREATE TABLE TEST2 ( COL2 NUMBER ); insert into test1 values (1); insert into test2 values (1); commit; create or replace procedure test_sp (col_name varchar2) as var1 number; begin select col1 into var1 from test1 where col1 in (select col_name from test2); end; exec test_sp ('COL2');
Deleted table.
Table created.
Table created.
1 line of creation.
1 line of creation.
Validation complete.
Created procedure.
BEGIN test_sp ("COL2"); END;
Error on line 29
ORA-01722: invalid number
ORA-06512: on-site ".» TEST_SP', line 7
ORA-06512: at line 1You must use dynamic sql statements:
SQL> drop table test1; Table dropped. SQL> drop table test2; Table dropped. SQL> CREATE TABLE TEST1 2 ( 3 COL1 NUMBER 4 ); Table created. SQL> CREATE TABLE TEST2 2 ( 3 COL2 NUMBER 4 ); Table created. SQL> insert into test1 values (1); 1 row created. SQL> insert into test2 values (1); 1 row created. SQL> commit; Commit complete. SQL> create or replace procedure test_sp (col_name varchar2) 2 as 3 var1 number; 4 begin 5 execute immediate 'select col1 from test1 where col1 in (select ' || col_name || ' from test2)' into var1; 6 end; 7 / Procedure created. SQL> exec test_sp ('COL2'); PL/SQL procedure successfully completed. SQL>
SY.
-
Cross tab in the SELECT statement?
Hello
The following SQL statement:
SELECT
T.LASTFIRST, C.COURSE_NAME, CC. COURSE_NUMBER, CC. SECTION_NUMBER, CC. EXPRESSION, ST. SEX, COUNT (CC.) STUDENTID) STUDENTCOUNT
TEACHERS T
JOIN THE CC
ON CC. TEACHERID = T.DCID
JOIN THE COURSE C
ON C.COURSE_NUMBER = CC. COURSE_NUMBER
JOIN STUDENTS ST
ON CC. STUDENTID = ST.ID
WHERE CC. SCHOOLID = 100 AND TERMID > = 1900
T.LASTFIRST, C.COURSE_NAME, CC GROUP. COURSE_NUMBER, CC. SECTION_NUMBER, CC. EXPRESSION, ST. BETWEEN THE SEXES
ORDER OF T.LASTFIRST, CC. COURSE_NUMBER, CC. SECTION_NUMBER, CC. EXPRESSION, ST. BETWEEN THE SEXES
Returns the following dataset:
Abram, American history Michael SOC1000 1 a 2 F 7
Abram, American history Michael SOC1000 1 has 2 M 12
Is there a way to make the count gender for each sex, introduce yourself as a column in the SELECT statement so that there is only ONE row returned by course number with as FEMALECOUNT and MALECOUNT column headers?
I tried to use a statement select count nested inside the original SELECT statement but without success.
JeffYou should be able to use a CASE statement for this in collaboration with the County. COUNTY does not indicate that null instances no I have not specified a part to the CASE ELSE (so the default value is NULL).
COUNT(CASE ST.GENDER WHEN 'F' THEN 1 END) as Female_count, COUNT(CASE ST.GENDER WHEN 'M' THEN 1 END) as Male_count,
Note that you need to remove the Gender of your query column.
-
How to add an imaginary line in the result of the value of a SELECT statement.
Hello all-
I have requirment to add an imaginary line in the result set of a SELECT statement.
For example lets say it is a pay table having the following columns:
Number of Payment_id
status varchar2 (10)
number amount
date of payment_date
so here's the data: -.
Payment_id status amount payment_date
applied 1 100 12/07/2008
2 Reversed 200 01 / 06/2009
Applied 3 300 01 / 07/2009
Here is my SQL
Select * form payment where payment_date > = 01/01/2009
The output will be
2 Reversed 200 01 / 06/2009
Applied 3 300 01 / 07/2009
My desired output is less than
2 Reversed 200 01 / 06/2009
Applied 3 300 01 / 07/2009
reversed-200 2, 01 / 06/2009-(Dummy Row)
Third line here is the imaginary line that I add when the status is "reversed".
I would be very grateful for any help on this...
Thank you
GerardCartesion join against a shadow table is a useful method to create a fictitious line:
with my_tab as (select 1 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all select 1 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all select 1 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all select 2 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all select 2 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/05/2009', 'mm/dd/yyyy') payment_date from dual union all select 2 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all select 2 cust_id, 4 Payment_id, 'Reversed' Status, -400 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all select 2 cust_id, 5 Payment_id, 'Applied' Status, 500 Amount, to_date('01/07/2009', 'mm/dd/yyyy') payment_date from dual), --- end of mimicking your table dummy as (select 'Reversed' col1, 1 rn from dual union all select 'Reversed' col1, 2 rn from dual) select mt.cust_id, mt.payment_id, mt.status, decode(dummy.rn, 2, -1*mt.amount, mt.amount) amount, mt.payment_date from my_tab mt, dummy where mt.status = dummy.col1 (+) order by mt.cust_id, mt.payment_id, dummy.rn nulls first; CUST_ID PAYMENT_ID STATUS AMOUNT PAYMENT_DATE 1 1 Applied 100 07/12/2008 1 2 Reversed 200 06/01/2009 1 2 Reversed -200 06/01/2009 1 3 Applied 300 06/01/2009 2 1 Applied 100 07/12/2008 2 2 Reversed 200 05/01/2009 2 2 Reversed -200 05/01/2009 2 3 Applied 300 06/01/2009 2 4 Reversed -400 06/01/2009 2 4 Reversed 400 06/01/2009 2 5 Applied 500 07/01/2009
Published by: Boneist on January 7, 2009 23:10
NB. You may need to mess around with the order if that is not in the order you want. You did not mention what the rules were for all orders expected, so I composed my own * {;-)Also, I added a (cust_id) identifier to differentiate different types of payments, as is usually the case. Remove unless it is not applicable to your case.
-
Classic report - add the column "select box"?
I have a classic report and you want to add a column with a check box so that the user can select several lines and perform an action on all of the lines (delete selected, for example). Looks like it should be easy and maybe integrated features, but I don't find it. Is there a standard way to do this?
Steve
APEX 5.0
Hello
to add a box to your classic report using apex_item.checkbox like this API function:
select APEX_ITEM.CHECKBOX(p_idx=>1, p_value=>DEPTNO) as select_dept, DEPTNO as DEPTNO, DNAME as DNAME, LOC as LOC from DEPT
You can access the values checked (for example in a process page)
declare v_deleted_depts number := 0; begin FOR i in 1..APEX_APPLICATION.G_F01.count LOOP v_deleted_depts := v_deleted_depts + 1; delete from dept where deptno = APEX_APPLICATION.G_F01(i); END LOOP; :P1_DEPTCOUNT := v_deleted_depts; end;
P1_DEPTCOUNT (hidden) is just for later interaction with this procedure - for example, you want to present your users with a message of success and error custom as "Deleted & P1_DEPTCOUNT. departments. »
Maybe you would like to add an option to check all checkboxes at once. If so, read this blogpost Blog of Carl Backstrom: September 2007.
Kind regards
Pavel
Edit: don't forget to toggle the leak key for special characters not your column "checkbox.
-
How to INSERT a SELECT statement with a GROUP BY clause on a table with an IDENTITY column?
n an application, I intend to truncate and insertion on a 12 c Oracle database, but have found this problem with a
IDENTITY
column. Even if theINSERT... SELECT
statement works on mostSELECT
uses I tried, if this statement was also aGROUP BY
clause, it does not work, delivering a "ORA-00979: not aGROUP BY
expression ' complaint. Some examples of code:create table aux ( owner_name varchar2(20), pet varchar2(20) );
insert into aux values ('Scott', 'dog');
insert into aux values ('Mike', 'dog');
insert into aux values ('Mike', 'cat');
insert into aux values ('John', 'turtle');
create table T1 (
id number generated always as identity,
owner_name varchar2(20),
pet_count number );
select owner_name, count(*) as pet_count from aux group by owner_name; -- works just fine
insert into T1 (owner_name, pet_count) select owner_name, count(*) as pet_count from aux group by owner_name; -- doesn't work
The select statement works by itself, but it fails as an INSERT... SELECT statement.
Appreciate the help!
Looks like a bug. You must open the SR with Oracle. Meanwhile, you could materialize select:
SQL > insert into T1 (owner_name, pet_count)
2 with t as (select / * + materialize * / owner_name, count (*) as pet_count to the owner_name group)
3. Select owner_name, pet_count t
4.3 lines were created.
SQL > select * from t1;
ID OWNER_NAME PET_COUNT
---------- -------------------- ----------
1 John 1
Scott 2 1
3 Mike 2SQL >
Keep in mind index THAT MATERIALIZE is undocumented.
SY.
-
There are two select statement, which are as follows: 1) select project id, the name of ppm.pm_projects project_name and request_id 2) select id, name from request_type_name to kcrt_request_details. There is a column called entity that can store a value i.e. project or request. I want to write a select statement containing a condition that is if the entity name is project and then run the select statement 1 otherwise, if the name of the entity's request, then run the select statement 2. All this must be written in a select statement. Can someone help me how to write this select statement type.
Hello
Hello
2726057 wrote:
... There is a column called entity that can store a value i.e. project or request. ...
In which table is this column? Assuming that it is in a table called entity_table, you can do something like this:
SELECT project AS id
project name AS the name
OF ppm.pm_projects
WHEN THERE IS)
SELECT 1
Of entity_table
Entity WHERE = "Project".
)
UNION ALL
SELECT request_id ID
request_type_name AS name
OF kcrt_request_details
WHEN THERE IS)
SELECT 1
Of entity_table
Entity WHERE = 'ask '.
)
;
This does not have anything on the number of lines is entity_table, or what are the values in the column of the entity. In other words, the query works in all cases. If any line in entity_table entity = 'Project', then the pm_projects data will be included in the result set. If any line in entity_table entity = 'Request', kcrt_request_details data will be included.
I hope that answers your question.
If this isn't the case, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
-
mixture of column type in the select statement
Oracle 11g r2.
tab_test (name varchar2, blob... photo)
(1) select general use *.
Stored procedure: open ref_cursor to some * of table_test...
Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR); Call.Execute ();
It works very well.
(2) enter the name of the column in the select such as
Stored procedure: open ref_cursor to select name, photo table_test...
Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR); Call.Execute ();
ERROR: java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent data types: expected - got BLOB
My question, if I specify the column names in the select statement, including the varchar2 and blob, how can I registerOutParameter (1, OracleTypes.CURSOR);?
Thank you
Scott
PS The number of returned columns, in real case schenario, is a little, so I prefer to specify column names.
Wrong forum. This forum is for questions of sql and pl/sql.
Enter the question ANSWER and the repost in the JDBC forum
When repost you provide the necessary information to help you:
1. information on the full version for Oracle DB
2 version of the JDK
3. the name and version of the JDBC jar file
4. real code that demonstrates the problem
You should also review the info re REF CURSOR in the JDBC Developer's Guide
http://docs.Oracle.com/CD/E16655_01/Java.121/e17657/oraint.htm#i1058743
-
I'm figuring the shape (add) a column (sum) on a pdf file and on the calculation tab, it won't let me select (check) the fields I want to use in the calculation. It won't let me type fields in the box either. I'm doing something wrong?
the mouse click on the name of the field and press the space key
Maybe you are looking for
-
Satellite M50 - 122 insertion of battery running
A business partner of mine can run his laptop with the battery inserted. But it also can, reinsert back while his laptop is running. So I wonder if my Toshiba Satellite M50 122 can do it too?
-
Re: Windows 7 32-bit to 64-bit upgrade
I am a newbie to the forum. I recently gave a series of t60p 2623 with the 7200 T processor and 3 GB of RAM shown and has an ATI X 1300 display adapter. It features 32-bit, XP Professional, and I would like to make a clean Windows 7 Home Premiun or p
-
Try to find the BIOS for Compaq Presario C300 (C350EA) file
I tried winflash BIOS to a Compaq Presario C300 (C350EA) but it failed. The machine still messages, but it can not find a disk hard when you install windows on the CD. The HARD test in the BIOS disk still works, like the rest of the BIOS screen. Now,
-
What is the elevated command prompt
I am running vista and I supported the man-ware problem but I make a point of endpoint not found on my external drives when I try to share the show upward except when I click on them, they say, folder is empty, site says here if after enforcement of
-
HelloI have a copy of the retail of Vista Ultimate, with disks and a touch # valid. I want to install Vista Ultimate on a new computer as a second operating system with windows 7 which is above. Can I buy just an another # key valid microsoft or some