Getting data from CTE in existing table
HelloI do not understand what is the problem with the following query, when I search on the net I find simular instructions sql... my works (tested separately) etc, I used the loop for only to copy from one table to the other... but when I combine them, it won't...
The code that is in commits some differences, I tried.
with x as (
select
p.id as id, p.naam as pers , c.id as comp, cp.sectorid as sect
from competentiepersoon cp
join persoon p on p.id = cp.persoonid
join competentie c on c.id = cp.competentieid
where sectorid = 14 --c1.id
),
y as (
select t1.comp as comp1, t2.comp as comp2, t1.sect, count(*) as tel
from x t1, x t2
where t1.comp != t2.comp
and t1.id = t2.id
group by t1.comp, t2.comp, t1.sect
),
z as (
select
comp1, comp2, sect, tel / (select count(*) from y where comp1 = y1.comp1 or comp2 = y1.comp1 or comp1 = y1.comp2 or comp2=y1.comp2 ) as match
from y y1
)
--insert INTO competentiematching(competentieid1, competentieid2, sectorid, matching)
--values select comp1, comp2, sect, match from z;
for toInsert in ( select * from z )
loop
insert into competentiematching values(toInsert.comp1, toInsert.comp2,toInsert.sect,toInsert.match);
end loop;
= > Guard giving "lack instruction select".PS Sorry for my English :).
Hello
There is no need to use a LOOP, or even PL/SQL: you can just do an INSERT statement like this:
insert into competentiematching (...) -- List of columns isn't strictly required, but it's a good idea
with x as (
select
p.id as id, p.naam as pers , c.id as comp, cp.sectorid as sect
from competentiepersoon cp
join persoon p on p.id = cp.persoonid
join competentie c on c.id = cp.competentieid
where sectorid = 14 --c1.id
),
y as (
select t1.comp as comp1, t2.comp as comp2, t1.sect, count(*) as tel
from x t1, x t2
where t1.comp != t2.comp
and t1.id = t2.id
group by t1.comp, t2.comp, t1.sect
),
z as (
select
comp1, comp2, sect, tel / ( select count(*)
from y
where comp1 = y1.comp1
or comp2 = y1.comp1
or comp1 = y1.comp2
or comp2 = y1.comp2
) as match
from y y1
)
SELECT ... -- Main query goes here
;
It has no main request after the subquery y1 in the code you have posted.
An INSERT statement like the one above will work in SQL or PL/SQL.
If you do not need to use a loop, the syntax is:
FOR toInsert IN ( )
LOOP
...
END LOOP;
Where I wriote
FOR toInsert IN (
with x as (
select
p.id as id, p.naam as pers , c.id as comp, cp.sectorid as sect
...
)
LOOP
...
END LOOP;
Tags: Database
Similar Questions
-
getting data from two servers?
Experts-
We have two servers for the storage of the tables. 1 history 1. current server Prod
We have same tables in the databases server.
All the info before one month from the date of the day are stored in database tables history server
and the rest in database tables current prod server.
I create reports such as when the user enters a date, OBIEE must check if the date is in a month (30 days) the date today or earlier at 30 days, on this basis, it must get data from historical Server database tables / running production database server.
How can I implement this?
I need to create two clusters of connction (RPD records) and develop the same model twice? (One for the historical paintings and one for prod tables?)
or can I use the technique of fragmentation? If so, can you give me an idea hwow to implement the Fragmentation of this requirement?
Thank you for your help in advanceYou must use the fragmentation of this requirement. It is not difficult once you understand the basic principle. Nico article read here for details:
http://gerardnico.com/wiki/dat/OBIEE/fragmentation_content
The only non-standard bit for you will be to define the criteria of fragmentation on your sources of logical table. This is the part that says BI server to hit source.
After return here if you get stuck.
Paul
-
How can I add data file to an existing table on Oracle RAC ASM with no OMF? Thank you!
How can I add data file to an existing table on Oracle RAC ASM with no OMF? Thank you!
Hello
So I guess you have some files in ASM, see your first existing file structure
Select file_name
from dba_data_files;
and to add to an existing table, the example below (even if you're better sticking with OMFs!)-is that what you are looking for?
SQL > create tablespace TEST1
2 datafile '+ DATA' size 1 M;
Created tablespace.
SQL > select file_name in dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+Data/orcl2/datafile/users.259.859820983
+Data/orcl2/datafile/undotbs1.258.859820983
+Data/orcl2/datafile/SYSAUX.257.859820983
+Data/orcl2/datafile/system.256.859820981
+Data/orcl2/datafile/example.269.859821049
+Data/orcl2/datafile/Test1.271.859843053
6 selected lines.
SQL > alter tablespace TEST1
2 Add datafile ' + DATA / mynewfile01.dbf ' size 2 m;
Tablespace altered.
SQL > select file_name in dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+Data/orcl2/datafile/users.259.859820983
+Data/orcl2/datafile/undotbs1.258.859820983
+Data/orcl2/datafile/SYSAUX.257.859820983
+Data/orcl2/datafile/system.256.859820981
+Data/orcl2/datafile/example.269.859821049
+Data/orcl2/datafile/Test1.271.859843053
+ DATA / mynewfile01.dbf
Thank you
-
How to get data from one or several times of perticuler dates
(1) how can we get data from one or more dates perticuler.
for example. date of 01/01/2011 and time is 00:00:00 to 23:59:59
and
(2) how can we get data from one or more dates perticuler.
from date 01/01/2011 to 01/02/2011 date and time e.g. is from 00:00:00 to 23:59:59.
can we?Hello
Use a WHERE clause to include only certain lines.
For example:SELECT * FROM table_x WHERE dt BETWEEN TO_DATE ( '01/01/2011 00:00:00' , 'DD/MM/YYYY HH24:MI:SS' ) AND TO_DATE ( '01/01/2011 23:59:59' , 'DD/MM/YYYY HH24:MI:SS' ) ;
In this example, the first date (before the keyword AND) and second (after the keyword AND) lie on the same calendar day. It's just a coincidence, they can be on different dates.
The first date must not be later than the date of the second; If this is the case, you will get 0 found lines.I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using. -
Write data from a CSV to table
Hi all
I have a CSV (Comma Separated Values) file and I want to write its data to the table.
How can I get data from a CSV file.Knani suggested, you can use external Tables or Sql Loader
You can check this link for example on Sql Loader http://surachartopun.com/2007/10/example-sql-loader-some-data-into.html -
Hello world
How can I get data from excel inside my program? I'm using labview 8.2. I have tried to find the solution for this but seems that the solutions are not suitable. Can someone help me? Thank you.
Hi jieah,
Inside of the attachment nijams don't you see this?
-
Y510 unable to get data from the camera.
Hello
I have a Y510 with Windows Vista 32 bit, 3 GB RAM, only 5 weeks. I get this message when I try to use Veriface, "unable to get data from the camera. The camera may have been disconnected or busy. I reinstalled Vista of the State in which the laptop came, but it does not work. I also updated the bios and install other updates were available. I would appreciate any advice.
Thank you
Peter
I wish it was as easy as press Fn + Esc, I looked through an another Y510 our office and managed to find a process that must be set to Auto, the process is KtmRm. This process cannot be disabled, handicapped, or on a time delay, it must be AUTOMATIC.
-
Loading data from SQL to Essbase table
Hello
I'm loading data from SQL to Essbase table by using a rules file. Number of rows in the source table is 7 million. I use the SUNOPSIS MEMORY ENGINE as area transit, LKM SQL for SQL and SQL IKM for Hyperion Essbase (DATA).
Question:
1 can I not use any other LKM as MSSQL for MSSQL (PCBS) to load data to the staging instead of LKM SQL for SQL? What I have to change the transit area then? Loading data using LKM SQL for SQL seems quite slow.
2 it is mandatory to use LKM SQL for SQL, can someone please tell me what I can change to make this quick support parameters?
3. is it compulsory to use the SUNOPSIS MEMORY engine loading data from SQL server to Essbase?
Thank you...
(1) Yes, I highly recommend watching using a KM which uses native as database technology these will usually be more efficient than the generic (like LKM SQL for SQL) KM especially when large volumes of data are involved. Your staging will change depends on where you organize data for example if you are using a SQL server specific KM as - MSSQL for MSSQL (PCBS) - you must have a lay-by available on a MSSQL database and have access to the utility of PCBS.
(2) it is not mandatory to use this KM you can use a KMs supported by your database technology
(3) it is absolutely not obligatory to use the SUNOPSIS MEMORY engine. This should only be used when you have relatively small amounts of data, as well as all the processes in memory, or in the case where you have no other relational technology to perform the staging on. However, in your case to use wherever you are processesing these large volumes of data you should be staged on a physical such as SQL Server or Oracle database if they are available.
-
Get data from a member of the region partitioned customer
Hello
I have a partitioned area, this region is in all 3 members, is it possible to get data from this region but only from 1 member of the customer, if so how?
What is your definition of the region on the server? The three members have given? You set redundant copies? In addition, if the optimizeForWrite() of the service method returns false, the function will run the smallest number of nodes.
Follow these steps:
The redundant copies of the value = 1
Returns true for optimizeForWrite()
Make sure that all members contain primary buckets
Perform function like you do above
Barry
-
Get data from a dBASE - .dbf.
Hello everyone - Hello work Sunday: (.) I need to get data from legacy applications that run the dbase program. You'll need to auto data. If you have an idea, please tell me. Thanks to you, NIC.>
Hello everyone - Hello work Sunday: (.)
I do not work yet--it's sad that :)
I need to get the data from the old application
running the program dbase. You'll need to auto data. If you have an idea, please
say to me.Have a look here http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:711825134415.
It worked for me, with a bit of difficulty – mainly because of my own stupidity... If you have
no problem, post back.HTH,
Paul...
Thanks to you, NIC.
-
How can I get data from each associated XMLnode in movieclips separated when you click a line in the combobox?
A sample of XML is like this:
<>planter
< Lauvtre >
< Botanisk_navn > Acer campestre < / Botanisk_navn >
< Norsk_navn > Naverlonn < / Norsk_navn >
Gronn < Farge > < / fan >
H4 < Herdighet > < / Herdighet >
< Hoyde > 10-15 m < / Hoyde >
< / Lauvtre >
I have a combobox where it shows the botanical name and the Norwegian name. But the rest of the info in movieclips seem separate.
Someone has an idea how to do this? Can I use the trace function maybe? Here is my AS3 code so far:
var loader: URLLoader = new URLLoader();
loader.addEventListener (Event.COMPLETE, onLoaded);
list.addEventListener (Event.CHANGE, itemChange);
function itemChange(e:Event):void
{
your. Text = list.selectedItem.data;
TB. Text = list.selectedItem.label;
}
var xml;
function onLoaded(e:Event):void
{
XML = new XML (e.target.data);
var it: XMLList = xml. Planter.Lauvtre;
for (var i: uint = 0; i < il.length (); i ++)
{
list.addItem ({data: it.}) Farge.Text ([i]) + "\n"+ it.» Herdighet.Text ([i]) + "\n" + it. Hoyde.text ([i]),
label: it. Botanisk_navn. Text() [i] + "\n"+ it.» Norsk_navn. Text() [i]});
}
}
Loader.Load (new URLRequest ("lauvtre.xml"));
Thank you!
Rheus.
I don't know what you're trying to do. but, if you want to fill one combobox with the botanical names and when one is chosen, the other use of logins:
var loader: URLLoader = new URLLoader();
loader.addEventListener (Event.COMPLETE, onLoaded);
list.addEventListener (Event.CHANGE, itemChange);
function itemChange(e:Event):void {}
var selectedObj:Object = a [list.selectedIndex]
trace (selectedObj ['fan'], selectedObj ['Botanisk'], etc);
}
var xml;
var a: Array = [];
function onLoaded(e:Event):void {}
XML = new XML (e.target.data);
var it: XMLList = xml. Lauvtre;
for (var i: uint = 0; i
list.addItem({label:il[i].child('Botanisk_navn').toString()});)
a [i] = {'Fan': it [i].child('Farge').toString (), 'Herdighet': it [i].child('Herdighet').toString (), "Hoyde": he [i].child('Hoyde').toString (), 'Botanisk':il[i].child('Botanisk_navn').toString(),'Norsk_navn':il[i].child('Norsk_navn').toString()};}
}
}
Loader.Load (new URLRequest ("test.xml"));
-
How to select data from a remote database table?
Hi friends,
I think I've seen before a sqlplus program that can select data from a remote database table?
Witnessed: IP, SID, PORT
The following is correct?
(I am connected to a local database)
SELECT COUNT (*) IN THE EMP@IP:SID/PORT;
Thank you very much
Ms. KSalvation;
I think, that you can create dblink wihtout any problem yet, it's a PROD. After your selection, you can drop dblink
Respect of
HELIOS -
Getting data from tables msql and e-mailing the result
Here is some code that I'm eager to collect data from two tables msql and send by email to a user. (This is to remind the user of their user name and password in a weak security situation - that they have submitted their email address)
I glued some elements of other pages together, hoping it will do what I want.
At present, it fails with the message
"You have an error in your SQL syntax. Check the manual for your version of the MySQL server for the right syntax to use near Test "in line 1", after posting $org as requested (as a test)
I would be grateful if someone can debug this problem, or otherwise advise.
<? php require_once('.. /.. / Connections/tormented3.php');? >
<? PHP
now, the recordset to email a link to the training
$colname_rstSix = "1";
If (isset($_GET['email'])) {}
$colname_rstSix = (get_magic_quotes_gpc())? $_GET ['email']: addslashes($_GET['email']);
}
@mysql_select_db ($database_tormented3, $tormented3);
$query_rstSix = sprintf ("SELECT ck_organisation FROM chk_sixmonth WHERE ck_email = ' %s", $colname_rstSix);
$rstSix = mysql_query ($query_rstSix, $tormented3) or die (mysql_error ());
$row_rstSix = mysql_fetch_assoc ($rstSix);
$totalRows_rstSix = mysql_num_rows ($rstSix);
Recordset to the end
$org = $row_rstSix ["ck_organisation"];
echo $org; temporary test. Yes, it sends a correct text to monitornow recordset to the Organization link to access details
@mysql_select_db ($database_tormented3, $tormented3);
$query_rstPword = sprintf ("SELECT username, passwords password organization FROM WHERE = ' %s", $org);
$rstPword = mysql_query ($query_rstPword, $tormented3) or die (mysql_error ());
$row_rstPword = mysql_fetch_assoc ($rstPword);
$totalRows_rstPword = mysql_num_rows ($rstPword);Start with routine e-mail
$start = "your information to update access the website of the mental health of Torbay.
Your host username";// set up the e-mail header
$username = $row_rstSix ["username"];
$pword = $row_rstSix ["password"];
$message. = '$start $username. Your password is $pword\n please update your entries. « ;
If (mail ($email "Recall information Access",
$message, "in: . ((" [email protected] \r\n")) { }
header ('location:http://www.sample.org.uk "") ;// Redirect to the page if the email has been sent successfully
"exit";
} else {}
$error == ' < style p = "color: red;" > an error has occurred, your email could not be sent. Please try again < /p > ';
}? >
Thank you very much.
I assumed that your first successful query because SELECT... ck_organisation your $org echo printed what you expected.
Isn't the second query SELECT... Organization which is a failure? Have you tried the echo method or die in this query? Or is it the one that displays "the query is empty?
Try changing the following code snippet and we'll see what happens. I've added a couple more conditions where you can send them to the form. I added also oblique (') around the domain names in the second query, just in case any of those are reserved words in MySQL (I don't get them, but they are available in the MySQL online documentation).
mysql_select_db($database_tormented3, $tormented3); $query_rstSix = sprintf("SELECT ck_organisation FROM chk_sixmonth WHERE ck_email = '%s'", $colname_rstSix); $rstSix = mysql_query($query_rstSix, $tormented3) or die(mysql_error()); $totalRows_rstSix = mysql_num_rows($rstSix); if (!$totalRows_rstSix) { // no record exists with email $colname_rstSix // Alert user and let them try again. exit; } $row_rstSix = mysql_fetch_assoc($rstSix); //end recordset $org = $row_rstSix['ck_organisation']; echo $org; //temporary test. Yes, it does send correct text to monitor //now recordset to link organisation to access details // mysql_select_db($database_tormented3, $tormented3); // not needed. Still selected from above $query_rstPword = sprintf("SELECT `organisation`, `username`, `password` FROM `passwords` WHERE `organisation` = '%s'", $org); echo "$query_rstPword
"; $rstPword = mysql_query($query_rstPword, $tormented3) or die(mysql_error()); $totalRows_rstPword = mysql_num_rows($rstPword); if (!$totalRows_rstPword) { // no record in passwords with $org // Decide what you want to do in this situation. // exit; ??? } $row_rstPword = mysql_fetch_assoc($rstPword);--
Mark A. Boyd
Keep-on-Learnine :-) -
How to get data from an Excel file exist using report generation tools
I try to use the Excel vi get the data of the report generation tool, but I can't understand how to activate a path can be explored in the right type for the VI. I tried to use the new Report.vi, but this does not work unless you use a template. It will not open an existing excel file and make an open report to extract data from.
Essentially, I have a bunch of excel files that have data in them, and I want a VI allows to analyze the data. I'm going to pull in all the data directly from the excel file so I don't have to reproscess them all in text so I can use the more standard datasheet live but to convert even the excel file programtically in labview I still need to be able to open the excel file and get the data?
I found my problem. It turns out that only not to have had a problem with the tool box new report vi. I had accidentally wired an input control of path of folder instead of an input control of path of file to it. Changing the file type took care of her and I was able to access excel files, I tried using the new report VI to extract the file, and Excel Get Data to extract the data.
-
How to get data from a database table and insert into a file
Hello
I'm new to soa, I want to create an xml with the data from database tables, I'll have the xsd please suggest me how to get the data in the tables and insert in a file
concerningin your bpel process, you can use the db adapter to communicate with the database.
with this type of adapter, you can use stored procedures, selects, etc to get the data from your database into your bpel workflow.When did it call in your bpel to the db adapter process it will return an output_variable with the contents of your table data, represented in a style of xml form.
After that, you can use the second card (a file synchronization adapter) to write to the content of this variable in output to the file system
Maybe you are looking for
-
After updating the firmware, I can't open virtual store or Weather Channel
After the update as described http://aps2.toshiba-tro.de/kb0/OPT0502VS0000R01.htm I can't open virtual store, The Weather Channel, Radeo, organizer, calculator - writes the error message.Before you upgrade everything worked, just did not have access
-
My system cannot find or open my programs - error code: 2
I have another problem and I need some help there. My system cannot find or open my programs, it says error code: 2 Can anyone help?
-
I have just boughed spectrum HP 360 but I want to reverse the direction of travel of the 2 finger, is it possible? I am unable to find it.
-
can I assign vCPU 32 if the physical host is to have 20 hearts that hyperthreading is disabled
Dear team,I just want to confirm I can assign 32vCPUs to a virtual machine, if a physical host is to have total 20cores and hyperthreading is disabled.Please let me know assign vcpus VM is depend on the version of ESXi or VM HW version or is it depen
-
Class could ' t found third-party native library problem
HelloI have a question in my Android Adobe AIR plugin.I followed steps below to create the plugin.1. I created my nativeExtention of java code successfully,2 - successfully created JavaScript library3 - successfully created .ane file with the followi