INSERT the SEQ WITH the question of the Select clause
HelloI have Insert statement that I want to use seq with the select clause, but does not please help in this...
Insert in aaa (rowname, rowid, rowadd)
aa_seq.nextval, empaddress, and Select empname from emp;
Please, do not help to accommodate seq in the insert statement.
Insert into aaa(rid,rowname,rowadd)
select aa_seq.nextval, empname,empaddress from emp;
Do not use as ROWID column name.
Tags: Database
Similar Questions
-
Decimal separator in the SELECT Clause
Hello
I have the following parameters of decimal number:
SQL > select value
2 from v$ nls_parameters
3 where parameter = "NLS_NUMERIC_CHARACTERS;
VALUE
----------------------------------------------------------------
,.
If I show a decimal number, I get a comma as decimal separator
SQL > select 10/100 double;
10/100
----------
1
But if I use a decimal separator in the SELECT clause, I get:
SQL > select 100 * 1.1 double;
100 * 1 1
---------- ----------
1 100
It does not work. But the use of a period as the decimal separator works:
SQL > select 1.1 * 100 double;
1.1 * 100
----------
110
Maybe it's something that I never had to deal with before, but I thought that the number format applied to results of sql, as well as the numbers you have used sql clauses.
Kind regards
Nestor BoscanHi, Nestor,
user594312 wrote:
... I thought that the number format applied to results of sql, as well as the numbers you have used sql clauses.No.; it applies to the results and it can affect implicit conversions, but it does not apply to the SQL code.
The period (or dot, '.') is the decimal separator in literals always digital. There is no way to change this.Think how confusing it would be if it applied to the SQL code. For example:
WHERE num_col IN (1,2)
We compare num_col values 1 or 2? He comes in, what happens if we wanted to do the opposite?
If you really want to use the comma as the decimal separator, you may have to use strings, not numbers, and it could be much less effective.
For example:SELECT 100 * TO_NUMBER ('1,1') -- This assumes your NLS settings are correct FROM dual;
Of course, the effectiveness will not be a problem when you select 1 row of double.
-
Hello
Doc Oracle says the following on the identifiers in the SELECT in PL/SQL clause: there is no possibility of ambiguity in the SELECT clause because any identifier in the SELECT clause must be a database column name.
If we assume that only valid column identifier are allowed in the SELECT clause.
But I tried the following:
DECLARE toto NUMBER := 10; tata NUMBER := 0; BEGIN SELECT toto INTO tata FROM employees WHERE employee_id = 101; DBMS_OUTPUT.PUT_LINE(tata); END; /
And there is no error telling me that toto is not a column in the employees table and the result is the same as: toto: = aunt;
Won't the doc or did I just miss something?
Thanks for your response!
Hello
rep0ne wrote:
Hello
Doc Oracle says the following on the identifiers in the SELECT in PL/SQL clause: there is no possibility of ambiguity in the SELECT clause because any identifier in the SELECT clause must be a database column name.
If we assume that only valid column identifier are allowed in the SELECT clause.
Post a link to this Oracle doc.
But I tried the following:
- DECLARE
- Toto NUMBER: = 10;
- Auntie NUMBER: = 0;
- BEGIN
- SELECT toto IN Auntie FROM Employees WHERE employee_id = 101;
- DBMS_OUTPUT. Put_line (Auntie);
- END;
- /
And there is no error telling me that toto is not a column in the employees table and the result is the same as: toto: = aunt;
...
You're right that toto is an identifier, but this isn't a column name. (Of a subquery) column alias are not database of the names of columns either, nor are the names of the user-defined function.
Also, there is a possibility for ambiguity even if all the names are the database column names.
Won't the doc or did I just miss something?
I can't say until I see the doc you're talking about.
Oracle documentation is sometimes misleading and sometimes just plain wrong. For each mistake outright example that I saw in the docs of Oracle, there might be 20 cases where the meaning is unclear or misleading and maybe 200 where I just read it wrong.
-
How to remove the name of the column in the select clause
Hello guys,.
I want to just delete a column name in the select clause. Because I don't want to write all the names of columns. I hope I am.
In other words, I want the following.
Select * - unwanted_column from table; instead of this Select col1, col2, col3, col4, ........ col 10000 from table;
Hello
There is nothing in SQL, which means "all columns * except *...» ». As others have said, the only way to achieve these results in SQL is to list all the columns you want.
Your front end may have a feature that allows you to hide a specific column. For example, in SQL * Plus, you can use COLUMN... NOPRINT , like this:
COLUMN dname NOPRINT SELECT * FROM scott.dept ORDER BY dname ;
Output:
` DEPTNO LOC ---------- ------------- 10 NEW YORK 40 BOSTON 20 DALLAS 30 CHICAGO
There is a column called dname in the scott.dept table; the query above uses actually. But, because of the order of the COLUMN, SQL * Plus will not display this column.
Published by: Frank Kulash on February 26, 2013 10:10
Example of scott.dept has changed. -
instead of update, I want to incorporate in the select clause
instead of separate update, I want to incorporate in the select clause.
I use the following version
=====================
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
AMT for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
=============================
create table SpendBy AS NOLOGGING
SELECT commodities.commodity_level_1 mkt_sec.
0 AS mkt_sec_id,-instead of update, I want to integrate it in the select clause
Commodities.commodity_level_2 mkt_sub_sec
TO spend,
commodities
WHERE (spend.commodity_id = commodities.node_id)
Update SpendBy set mkt_sec_id = (select node_id from products where commodity_level_2 is null and commodity_level_1 = SpendBy.mkt_sec);
commit;I'm sorry, should have better considered in your code.
A then:
create table SpendBy NOLOGGING AS SELECT c.commodity_level_1 mkt_sec, select node_id as mkt_sec_id from commodities c2 where c2.commodity_level_2 is null and c2.commodity_level_1=c.commodity_level_1, c.commodity_level_2 mkt_sub_sec FROM spend s, commodities c WHERE s.commodity_id = c.node_id;
-
Insert the select statement result in CLOB
Hi, I would like to insert the result of a statement select into a CLOB with a trigger.
Whevner a number is registered my research to trigger how often the number is used in several objects and now my problem I also would like to know the record ID where the number is used.
SELECT 'ITEXT '.
OF 'CHECK_INR '.
WHERE 'USE' > 1
This select records of results 2 How can I insert the result into a CLOB with my trigger?
Thanks in advanceSteven,
It's really a question better suited for another forum because it is not really associated with ApEx. Also, something tells me that you really want to do an UPDATE not an insert. However, here's a quick example...
DECLARE l_orders VARCHAR2(4000); BEGIN FOR x IN ( SELECT * FROM my_orders_table ) LOOP l_orders := l_orders || ', ' || x.order_data_column; END LOOP; l_orders := l_trim(l_orders, ', '); UPDATE some_table SET some_column = l_orders WHERE id = some_id; END;
That's the key. Use VARCHAR2 unless you need CLOB.
Kind regards
Danhttp://danielmcghan.us
http://sourceforge.NET/projects/tapigen -
Subquery in the select clause and not "a group by expression" error.
Hi all
I hope someone out there can help me out with this one. I have a sql query that performs a subquery in the select case combined with an aggregate function and gives me a "not a group by expression.
I created a simplified example
I'm sure he expected me to add the po_number to the group by clause, but this does not work and gives the error "invalid identifier".SELECT COUNT(*) , ai.invoice_num invoice_number , ai.description invoice_description , (SELECT poh.po_header_id FROM po_headers poh , po_distributions pod WHERE pod.po_distribution_id = aid.po_distribution_id AND pod.po_header_id = poh.po_header_id ) po_number FROM ap_invoice_distributions aid , ap_invoices ai WHERE ai.invoice_id = 1476932 AND aid.project_id = 8608 AND aid.task_id = 462202 AND ai.invoice_id = aid.invoice_id GROUP BY ai.invoice_num, ai.description;
Can someone suggest a way for a new concert the query so that I can add po_number to my education by clause.
KrisYou should try either:
SELECT COUNT (*),
AI.invoice_num invoice_number,
have. Description invoice_description,
(SELECT poh.po_header_id
OF po_headers poh,.
pod po_distributions
WHERE pod.po_distribution_id = aid.po_distribution_id
AND pod.po_header_id = poh.po_header_id
) po_number
HELP ap_invoice_distributions.
ap_invoices AI
WHERE ai.invoice_id = 1476932
AND aid.project_id = 8608
AND aid.task_id = 462202
AND ai.invoice_id = aid.invoice_id
Ai.invoice_num GROUP,
have. Description, aid.po_distribution_id;or
SELECT COUNT (*),
AI.invoice_num invoice_number,
have. Description invoice_description,
MAX ((SELECT poh.po_header_id
OF po_headers poh,.
pod po_distributions
WHERE pod.po_distribution_id = aid.po_distribution_id
AND pod.po_header_id = poh.po_header_id
po_number))
HELP ap_invoice_distributions.
ap_invoices AI
WHERE ai.invoice_id = 1476932
AND aid.project_id = 8608
AND aid.task_id = 462202
AND ai.invoice_id = aid.invoice_id
Ai.invoice_num GROUP,
have. Description; -
To generate the sequence in the select clause of the inner query
Hi all
Have the table and the data as below,
I want to generate a sequence number for all the distinct combinations of emp_id and emp_name running
DROP TABLE emp1.
CREATE TABLE emp1 (emp_id NUMBER, emp_name VARCHAR2 (100));
INSERT INTO emp1 VALUES (1, 'Name1');
INSERT INTO emp1 VALUES (2, 'Name2');
INSERT INTO emp1 VALUES (1, 'Name3');
INSERT INTO emp1 VALUES (2, 'Conjoint4');
COMMIT;
Output must be same as below:
EMP_ID EMP_NAME Reference ID 1 Name1 1000 1 Name1 1000 1 Name3 1001 2 Name4 1002 2 Name2 1003 "You cannot invoke CURRVAL and NEXTVAL in the subquery to CREATE."
"MATERIALIZED VIEW, or a SELECT, UPDATE, or DELETE statement;
Steve O'Hearn, Guide to preparing Oracle 1Z0-047
------
-
Calling a function in the select clause.
I'm using Oracle 11 g.
I am trying to write a query like this
SELECT name, age, sal, avg is avg_salary (age)
of the customer
where sal > = avg;
However, I am not able to do. What the query is trying to do is to print the name, age and the remuneration of each customer, as well as the average salary for the age of the customer where the customer pay is higher than the weighted average for his age.
Help, please. Thank you.OK, so what about:
SELECT c.name, c.age, c.sal, avg_salary (c.age) AS avg_sal FROM customer c WHERE c.sal > avg_salary (c.age)
-
Outer join - problem with the name of the table in the select list
Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production
create table (j1)
number of C1,
number of C2);
create table (j2)
number of C1,
number of C2);
insert into values j1 (1, 10);
insert into j1 values (1, 100);
insert into values j1 (1, 1000);
insert into values j2 (1, 2);
insert into values j2 (1, 4);
insert into values j2 (1, 8);
commit;
Select c1, j1.c2, j2.c2 of outer join of j1 j2 using (c1); - DOES NOT
Select c1, j1 j2 (c1) using outer join j2.c2. - WORK
Why?
Hello
Interesting question! Oracle goes very far in trying not to trigger an error.
The OUTER keyword (if used; it is always optional) must be preceded by one of the keywords, right or LEFT. Since neither LEFT, RIGHT, or FULL comes before OUTER in queries in your first message, it does not recognize as keyword OUTER and treats him like a table alias for table j1. Since j1 has an alias, the real table name cannot be used in the SELECT clause. This query is executed:
SELECT c1
outer.c2
j2.c2
External J1
Join the HELP of j2 (c1)
;
There is an INTERNAL join. Add to your sample data:
insert into values of j1 (-1, -10);
insert into values of j2 (-2, -20);
to be specified.
Moreover, USING is short for confUSING. I suggest you use IT for all the join conditions. Everyone (unless they you write or read a manual) does.
-
Hi all
Suppose I have table, whose structure changes frequently on a daily basis.
For example. / / desc my_table gives you after the name of the column the day 1
SQL > my_table DESC;
Output
Name
Age
Phone
Day 2, two other columns are added, viz, address and salary.
SQL > my_table DESC;
Output
Name
Age
Phone
Address
Salary
Now, I want to create a Dynnamic RTF report which made extracting data from all columns from my_table daily. For this, I have defined a simultaneous program with XML output type and include in annex a data/definition of data model that takes XML as input and gives the final result of the conc program in EXCEL layout. I am able to do that for a constant number of columns, but don't know how to do it when the number of columns to display dynamically changes.
For 1 day my XML file should be like this.
<?xml version="1.0" encoding="UTF-8"?> <dataTemplate name="XYZ" description="iExpenses Report" Version="1.0"> <dataQuery> <sqlStatement name="Q2"> <![CDATA[ SELECT Name ,Age ,Phone FROM my_table ]]> </sqlStatement> </dataQuery> <dataStructure> <group name="G_my_table" source="Q2"> <element name="Name" value="Name" /> <element name="Age" value="Age" /> <element name="Phone" value="Phone" /> </group> </dataStructure> </dataTemplate>
And my day 1, EXCEL output RTF model should be like this.
Name age phoneSwapnill 23 12345
For 2 days my XML file should be like this. With 2 new columns selected in the SELECT clause.
<?xml version="1.0" encoding="UTF-8"?> <dataTemplate name="XYZ" description="iExpenses Report" Version="1.0"> <dataQuery> <sqlStatement name="Q2"> <![CDATA[ SELECT Name ,Age ,Phone ,Address ,Salary FROM my_table ]]> </sqlStatement> </dataQuery> <dataStructure> <group name="G_my_table" source="Q2"> <element name="Name" value="Name" /> <element name="Age" value="Age" /> <element name="Phone" value="Phone" /> <element name="Address" value="Address" /> <element name="Salary" value="Salary" /> </group> </dataStructure> </dataTemplate>
And my day 2, exit EXCEL model RTF should be like this.
Name address telephone pay23 12345 Madrid 100000 Swapnill
Now, I don't know below things.
- Make the dynamic XML as we did in the day 1 there are 3 columns in the SELECT statement and the day 2, 5 columns. I want to create a dynamic XML which must not be changed if the new columns are added into my_table. I don't know how to create this query and also create their corresponding items below.
- Make the RTF model dyanamic as day 1 there are 3 exit EXCEL columns and the day 2, 5 columns. I want to create a dynamic RTF model that would display all the columns selected in XML dynamic. I don't know how the RTF will create new XML tags and how it will know where to place them in the report. Means, I can create model RTF day 1, by loading the XML data for 3 columns and place 3 tags XML in the model. But how he will create and place the tags for the new columns the day 2?
Hope so, you got my requirement, it's difficult. Please let me know how I can implement the necessary solution using the RTF dynamically without any manual intervention.
Kind regards
Patricia K.
Post edited by: SwapnilK
Hi guys,.
I was able to solve above the requirement.
I created a procedure that would create & update (attached to the data definition) XML file dynamically for each race. This dynamic XML contains the SQL statement for the data query that is built dynamically. I am updating this XML file using XDOLoader utility to the definition of data. Then run my program customized to generate the excel output.
Exit excel retrieves correct number of columns dynamically (3 on Day1 and Day2 5), with corresponding data records.
Kind regards
Patricia K.
-
Lexical parameters in the WHERE clause in error
Hello
Based on the settings, I need to change the place where the clause of the sql query in the data in the report model. After report params, I added the code as
: p_where1: = 'conditions...' » ;
and in the select clause
Select table.name
where & p_where1
I added the p_where1 as the parameter to use.
But when I say OK to the query in the data model. I am getting error like
ORA-00936: lack of expression
WHERE == >
Can someone help me why I get this error...
Thank you
HCHello
Set the initial value of the parameter as 1 = 1 try.
-Clément
-
Classification of the UNION by the select statement
I have an SQL statement composed of a bunch of different statements of union and I would that they sort by the first Union first, then the second, then third, etc.
SELECT *.
OF SERVICE_ADDRESS
WHERE SERVICE_ADDR_ST_NUM LIKE ('% A %')
UNION
SELECT *.
OF SERVICE_ADDRESS
WHERE SERVICE_ADDR_ST_NUM LIKE ("%B %')
UNION
SELECT *.
OF SERVICE_ADDRESS
WHERE SERVICE_ADDR_ST_NUM LIKE ('%C %')
I tried a bunch of different ways, but I get an error of invalid expression;
Can someone please show me how to sort this, so that all the results come first, then the B and the C?
I left all my other tests cause well, none of them worked lol. It's just the bare bones starting point
Thanks in advanceHello
You can do this more effectively and more easily without UNION, like this:
SELECT * FROM service_address WHERE CASE WHEN street_num LIKE '%A% THEN 1 WHEN street_num LIKE '%B% THEN 2 WHEN street_num LIKE '%C% THEN 3 END > 0 ORDER BY CASE WHEN street_num LIKE '%A% THEN 1 WHEN street_num LIKE '%B% THEN 2 WHEN street_num LIKE '%C% THEN 3 END ;
If you do not want to make the same expression BOX twice, then you can do in a subquery, but then you'd have either display the results or list all service_address columns in the SELECT clause.
-
SQL statement error INSERT The conflicted with the FOREIGN KEY constraint
I recently installed a reporting for vmware vsphere software, but I get a SQL error. I opened a request for assistance with vmware, but so far they have not come up with a solution. The error is caused by: com.microsoft.sqlserver.jdbc.SQLServerException: instruction INSERT The conflicted with the FOREIGN KEY constraint 'FK_CB_VSM_NETWORK_VC_ID '. The conflict occurred in database 'VCChargebackVCC02', table "dbo." " CB_VSM_SERVER', column 'VC_ID '. I don't know a lot about SQL, so I'm lost in the extent of troubleshooting is concerned. If anyone has any ideas I'd love to hear them.
SQL questions are better posed on Technet. They are better equipped to manage the
http://social.technet.Microsoft.com/forums/en-us/categories/
-
I installed the download tool usb/dvd windows 7, but after you have selected the iso file when I insert the USB stick and refrecing, it does show that "no usb drive compatible' what is the problem with my USB
I have sandisk cruzer blade USB key
Hi Rohit,
Thanks for posting your query in Microsoft Community Forum. I understand that your USB drive is having problems of compatibility with your computer, but I would like to learn more about the issue in order to provide you with better assistance.
- You did it any significant hardware or change software on the computer before this problem?
- When do you get exactly the error message?
- Have you tried to connect to any other computer on this flash drives?
- Your USB key works on other computers or have you tried to connect to different USB ports on this computer?
- Is the pen drive getting detected in the case or you are able to access the drive folder in the window of the computer ?
The question may arise if the currently loaded USB driver has become unstable or damaged, or if your PC requires an update for problems that could conflict with a device USB and Windows. This can also occur if your USB controllers may have become unstable or corrupt. So, I would suggest trying the following steps and check if the problem persists.
Method 1:
Please try the fixit (s) provided below which will help you solve common problems associated with devices and USB ports.
- Hardware devices do not work or are not detected in Windows
- Diagnose and automatically fix the Windows USB problems
If method 1 does not work, try Method 2.
Method 2:
Remove and reinstall all USB controllers.
- Open Manager devices by clicking the Start button, click Control Panel, click system and security, and then, under System, clicking Device Manager. If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.
- In the list of the categories of equipment, locate and expand Bus USB controllers.
- Right-click every device under the Bus USB controllers node and then click Uninstall to remove them one at a time.
- Restart the computer and let the USB controllers get reinstalled.
Plug in the removable USB device and test to make sure that the problem is solved.
If the problem persists, go to method 3.
Method 3:
This method will install the latest drivers from device to your USB device.
- Click the Start button, type Windows Update in the search box, and then click Windows Update in the results pane.
- Click find updates. When the scan finished, click optional review updates.
- Click the check box next to the update, and then click install updates.
- If you are prompted, read the license agreement, then click I agree.
- Follow the instructions on the screen to download and install updates.
- If you are prompted, restart your computer.
More information: Update a hardware driver that is not working properly
Hope this information is useful. If the problem still persists, please post back for further assistance, we will be happy to help you.
Maybe you are looking for
-
My additional toolbar with countless buttons on it disappeared.
I added an additional toolbar for FF, a long time ago... Absolutely, I added loads of icons for buttons to it for all kinds of functions. Largely out of all of the customization. Now the entire toolbar has disappeared. He is not here for re-check in
-
Lettering of controls of white labels?
Recently, when I put some controls on a front panel label had white lettering on gray background and is difficult to read. How can we change the labels in black letters. Nothing I've tried works. Attached, is an example of controls with white labels
-
HP photosmart C4200 snprb-0721 windows xp
-
Hello At my current workplace, we have a stand-alone comments wirleless network powered by adsl with 2 access SAP 1600i points. However, only one works and try as we might, we cannot have another run. We tried to run the same configuration as on one
-
Recently, I left my job where I had access to Adobe CC. I try to do some freelance and wanted to buy CC from Adobe. But I think back home (Honduras) and I discovered that Adobe CC was not available for this country. I have however a US address I've u