Need help with query that uses 'SELECT INTO'
Hi guys,
I am trying to duplicate the values of a table to another by using the script below:
ACCEPT TBSNAME CHAR PROMPT 'Tablespace name>'
PROMPT Connect As System
Connect system
CREATE TABLE FREESPACE
TABLESPACE_NAME VARCHAR(20) NOT NULL,
CONSTRAINT FREESPACE_PKEY PRIMARY KEY(TABLESPACE_NAME),
TOTAL_FREE_STORAGE NUMBER(10) NOT NULL
) TABLESPACE USERS;
SELECT TABLESPACE_NAME,
SUM(BLOCKS) TOTBLOCKS
INTO FREESPACE
FROM SYS.DBA_FREE_SPACE
WHERE TABLESPACE_NAME = UPPER('&TBSNAME')
GROUP BY TABLESPACE_NAME;
However, when I execute this script, I was prompted with the 'missing keyword' error which happens at the third line of the select statment. Any idea what's missing here?
Thanks in advance.
If you mean "fill up the table FREESPACE" by using "select...into..." then it is totally wrong. You cannot do it in plsql also.
Use this:
insert into freespace(tablespace_name,total_free_storage)
SELECT TABLESPACE_NAME,SUM(BLOCKS) TOTBLOCKS
FROM SYS.DBA_FREE_SPACE
WHERE TABLESPACE_NAME = UPPER('&TBSNAME')
GROUP BY TABLESPACE_NAME;
Message was edited by:
Yas
Similar Messages
-
Need help with query joining several tables into a single return line
what i have:
tableA:
puid, task
id0, task0
id1, task1
id2, task2
tableB:
puid, seq, state
id0, 0, foo
id0, 1, bar
id0, 2, me
id1, 0, foo
id2, 0, foo
id2, 1, bar
tableC:
puid, seq, date
id0, 0, 12/21
id0, 1, 12/22
id0, 2, 12/22
id1, 0, 12/23
id2, 0, 12/22
id2, 1, 12/23
what i'd like to return:
id0, task0, 12/21, 12/22, 12/22
id1, task1, 12/23, N/A, N/A
id2, task2, 12/22, 12/23, N/A
N/A doesn't mean return the string "N/A"... it just means there was no value, so we don't need anything in this column (null?)
i can get output like below through several joins, however i was hoping to condense each "id" into a single line...
id0, task0, 12/21
id0, task0, 12/22
id0, task0, 12/23
id1, task1, 12/23
is this possible fairly easily?
Edited by: user9979830 on Mar 29, 2011 10:53 AM
Edited by: user9979830 on Mar 29, 2011 10:58 AMHi,
Welcome to the forum!
user9979830 wrote:
what i have:...Thanks for posting that so clearly!
Whenever you have a question, it's even better if you post CREATE TABLE and INSERT statements for your sample data, like this:
CREATE TABLE tablea
( puid VARCHAR2 (5)
, task VARCHAR2 (5)
INSERT INTO tablea (puid, task) VALUES ('id0', 'task0');
INSERT INTO tablea (puid, task) VALUES ('id1', 'task1');
INSERT INTO tablea (puid, task) VALUES ('id2', 'task2');
CREATE TABLE tablec
( puid VARCHAR2 (5)
, seq NUMBER (3)
, dt DATE -- DATE is not a good column name
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 0, DATE '2010-12-21');
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 1, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 2, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id1', 0, DATE '2010-12-23');
INSERT INTO tablec (puid, seq, dt) VALUES ('id2', 0, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id2', 1, DATE '2010-12-23');This way, people can re-create the problem and test their ideas.
It doesn't look like tableb plays any role in this problem, so I didn't post it.
Explain how you get the results from that data. For example, why do you want this row in the results:
PUID TASK DT1 DT2 DT3
id0 task0 12/21/2010 12/22/2010 12/22/2010rather than, say
PUID TASK DT1 DT2 DT3
id0 task0 12/22/2010 12/21/2010 12/22/2010? Does 12/21 have to go in the first column because it is the earliest date, or is it because 12/21 is related to the lowest seq value? Or do you even care about the order, just as long as all 3 dates are shown?
Always say what version of Oracle you're uisng. The query below will work in Oracle 9 (and up), but starting in Oracle 11, the SELECT ... PIVOT feature could help you.
i can get output like below through several joins, however i was hoping to condense each "id" into a single line... Condensing the output, so that there's only one line for each puid, sounds like a job for "GROUP BY puid":
WITH got_r_num AS
SELECT puid
, dt
, ROW_NUMBER () OVER ( PARTITION BY puid
ORDER BY seq -- and/or dt
) AS r_num
FROM tablec
-- WHERE ... -- If you need any filtering, put it here
SELECT a.puid
, a.task
, MIN (CASE WHEN r.r_num = 1 THEN r.dt END) AS dt1
, MIN (CASE WHEN r.r_num = 2 THEN r.dt END) AS dt2
, MIN (CASE WHEN r.r_num = 3 THEN r.dt END) AS dt3
, MIN (CASE WHEN r.r_num = 4 THEN r.dt END) AS dt4
FROM tablea a
JOIN got_r_num r ON a.puid = r.puid
GROUP BY a.puid
, a.task
ORDER BY a.puid
;I'm guessing that you want the dates arranged by seq; that is, for each puid, the date related to the lowest seq comes first, regardless of whther that date is the earliest date for that puid or not. If that's not what you need, then change the analytic ORDER BY clause.
This does not assume that the seq values are always consecutive integers (0, 1, 2, ...) for each puid. You can skip, or even duplicate values. However, if the values are always consecutive integers, starting from 0, then you could simplify this. You won't need a sub-query at all; just use seq instead of r_num in the main query.
Here's the output I got from the query above:
PUID TASK DT1 DT2 DT3 DT4
id0 task0 12/21/2010 12/22/2010 12/22/2010
id1 task1 12/23/2010
id2 task2 12/22/2010 12/23/2010As posted, the query will display the first 4 dts for each puid.
If there are fewer than 4 dts for a puid, the query will still work. It will leave some columns NULL at the end.
If there are more than 4 dts for a puid, the query will still work. It will display the first 4, and ignore the others.
There's nothing special about the number 4; you could make it 3, or 5, or 35, but whatever number you choose, you have to hard-code that many columns into the query, and always get that many columns of output.
For various ways to deal with a variable number of pivoted coolumns, see the following thread:
PL/SQL
This question actually doesn't have anything to do with SQL*Plus; it's strictly a SQL question, and SQL questions are best posted on the "SQL and PL/SQL" forum:
PL/SQL
If you're not sure whether a question is more of a SQL question or a SQL*Plus question, then post it on the SQL forum. Many more people pay attention to that forum than to this one. -
Need help with query that can look data back please help.
hi guys i have a table like such
CREATE TABLE "FGL"
"FGL_GRNT_CODE" VARCHAR2(60),
"FGL_FUND_CODE" VARCHAR2(60),
"FGL_ACCT_CODE" VARCHAR2(60),
"FGL_ORGN_CODE" VARCHAR2(60),
"FGL_PROG_CODE" VARCHAR2(60),
"FGL_GRNT_YEAR" VARCHAR2(60),
"FGL_PERIOD" VARCHAR2(60),
"FGL_BUDGET" VARCHAR2(60)
)and i have a data like such
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','1','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','1','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','0');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','14','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','2','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7470','4730','02','10','2','200');I bascially need to get the total of the budget column. however its not as simple as it sound(well atleast not for me.) the totals carry over to the new period. youll noticed the you have a period column. basically what im saying is that
fgl_grant_year 10 period 1 = for account 7600 its $100 and $100 for period 2 you see 100 dollars again this is not to be added this is the carried over balance. which remains $100.
so im trying to write a query that basically does the following.
im given a period for the sake of this example lets say period 1 i get nothing else. I have to find the greates grant year grab the amount for period 14(which is the total from the previous year) and add it to the amount of the current period. in this case period 1 grnt_year 11
so the expected outcome should be $700
240055 240055 7240 4730 02 10 14 200
240055 240055 7600 4730 02 10 14 100
240055 240055 7600 4730 02 11 1 400keep in mind that im not given a year just a period.
any help that you guys can offer would be immensely appreciated. I have been trying to get this to work for over 3 days now.
finally broke down and put together this post
Edited by: mlov83 on Sep 14, 2011 8:48 PMFrank
wondering if you can help me modify this sql statement that you provided me with .
table values have been modified a bit.
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','00','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','0');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','1','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7200','4730','02','10','1','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7600','4730','02','10','1','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','14','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','2','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','11','2','600');i need to take one more thing into consideration. if the greatest year has a value on period 00 i need to ignore the period 14 and the current period total would be
the current period +(current period - greatest year 00)
hope that makes sense so in other words with the new data above. if i was querying period two of grant year 11. i would end up with $800
because the greatest year is 11 it contains a period 0 with amount of $400 so my total should be
period 2 amount $ 600
period 0 amount $ 400 - period 2 amount of $600 = 200
600+200 = $800
if i query period 1 of grant 360055 i would just end up with 800 of grnt year 10.
i have tried to modify that query you supplied to me with no luck. I have tried for several day but im embarrased to say i just can get it to do what im trying to do .
can you please help me out.
Miguel -
Need Help With Redirect That Uses Session Variable
I am new to dynamic sites, php, and developer toolbox, but I have been able to create a login site using the different form wizards fairly easily (in CS3 with Developers toolbox).
<br />
<br />I am trying to set a server behavior on a page that redirects the user to a new page if a session variable matches a recordset.
<br />
<br />I was using an extension (PHP Sessions - http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=681308 ) that worked great, but when I installed developers toolbox, it stopped working (get error message about runtime/MX environment).
<br />
<br />Ive been struggling for days and this is what Ive come up with so far:
<br />------------------------------------
<br />session_start();
<br />if (!isset($HTTP_SESSION_VARS[$_SESSION['kt_firstname']]) || $HTTP_SESSION_VARS[$_SESSION['kt_firstname']] = $row_Recordsetfname['firstname']) {
<br /> header ("Location: ../firstname/firstname1.php");
<br />}
<br />------------------------------------
<br />
<br />It redirects regardless of the match. Any ideas on what I can do to get this working? Here is all of the code (with block from above inserted) up until the doc type:
<br />------------------------------------
<br /><?php require_once('../Connections/project1.php'); ?>
<br /><?php<br />// Load the tNG classes<br />require_once('../includes/tng/tNG.inc.php');<br /><br />// Make unified connection variable<br />$conn_project1 = new KT_connection($project1, $database_project1);<br /><br />//Start Restrict Access To Page<br />$restrict = new tNG_RestrictAccess($conn_project1, "../");<br />//Grand Levels: Any<br />$restrict->Execute();<br />//End Restrict Access To Page<br /><br />if (!function_exists("GetSQLValueString")) {<br />function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") <br />{<br /> $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;<br /><br /> $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);<br /><br /> switch ($theType) {<br /> case "text":<br /> $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br /> break; <br /> case "long":<br /> case "int":<br /> $theValue = ($theValue != "") ? intval($theValue) : "NULL";<br /> break;<br /> case "double":<br /> $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";<br /> break;<br /> case "date":<br /> $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br /> break;<br /> case "defined":<br /> $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br /> break;<br /> }<br /> return $theValue;<br />}<br />}<br /><br />// FELIXONE - 2002 SB by Felice Di Stefano - www.felixone.it<br />session_start();<br />if (!isset($HTTP_SESSION_VARS[$_SESSION['kt_firstname']]) || $HTTP_SESSION_VARS[$_SESSION['kt_firstname']] = $row_Recordsetfname['firstname']) {<br /> header ("Location: ../firstname/firstname1.php");<br />}<br /><br />$colname_Recordsetfname = "-1";<br />if (isset($_SESSION['kt_user_name'])) {<br /> $colname_Recordsetfname = $_SESSION['kt_user_name'];<br />}<br />mysql_select_db($database_project1, $project1);<br />$query_Recordsetfname = sprintf("SELECT firstname FROM registration WHERE user_name = %s", GetSQLValueString($colname_Recordsetfname, "text"));<br />$Recordsetfname = mysql_query($query_Recordsetfname, $project1) or die(mysql_error());<br />$row_Recordsetfname = mysql_fetch_assoc($Recordsetfname);<br />$totalRows_Recordsetfname = mysql_num_rows($Recordsetfname);<br /><br />$colname_Recordset1 = "-1";<br />if (isset($_SESSION['kt_user_name'])) {<br /> $colname_Recordset1 = $_SESSION['kt_user_name'];<br />}<br />mysql_select_db($database_project1, $project1);<br />$query_Recordset1 = sprintf("SELECT `Date` FROM registration WHERE user_name = %s", GetSQLValueString($colname_Recordset1, "text"));<br />$Recordset1 = mysql_query($query_Recordset1, $project1) or die(mysql_error());<br />$row_Recordset1 = mysql_fetch_assoc($Recordset1);<br />$totalRows_Recordset1 = mysql_num_rows($Recordset1);<br />?>
<br />
<br />------------------------------I am new to adobe toolbox... I ve created a ligin page but not sure how to pass the session variable. I am trying to direct successful login to a page like... index.php?id=filter
<br />
<br />been struggling all day with this. Please help!!!
<br />
<br /><?php require_once('Connections/comm.php'); ?>
<br /><?php<br />// Load the common classes<br />require_once('includes/common/KT_common.php');<br /><br />// Load the tNG classes<br />require_once('includes/tng/tNG.inc.php');<br /><br />// Make a transaction dispatcher instance<br />$tNGs = new tNG_dispatcher("");<br /><br />// Make unified connection variable<br />$conn_comm = new KT_connection($comm, $database_comm);<br /><br />// Start trigger<br />$formValidation = new tNG_FormValidation();<br />$formValidation->addField("kt_login_user", true, "text", "", "", "", "");<br />$formValidation->addField("kt_login_password", true, "text", "", "", "", "");<br />$tNGs->prepareValidation($formValidation);<br />// End trigger<br /><br />// Make a login transaction instance<br />$loginTransaction = new tNG_login($conn_comm);<br />$tNGs->addTransaction($loginTransaction);<br />// Register triggers<br />$loginTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "kt_login1");<br />$loginTransaction->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);<br />$loginTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}");<br />// Add columns<br />$loginTransaction->addColumn("kt_login_user", "STRING_TYPE", "POST", "kt_login_user");<br />$loginTransaction->addColumn("kt_login_password", "STRING_TYPE", "POST", "kt_login_password");<br />$loginTransaction->addColumn("kt_login_rememberme", "CHECKBOX_1_0_TYPE", "POST", "kt_login_rememberme", "0");<br />// End of login transaction instance<br /><br />// Execute all the registered transactions<br />$tNGs->executeTransactions();<br /><br />// Get the transaction recordset<br />$rscustom = $tNGs->getRecordset("custom");<br />$row_rscustom = mysql_fetch_assoc($rscustom);<br />$totalRows_rscustom = mysql_num_rows($rscustom);<br /><br />?>
<br />
<br />
<br />
<br />
<br />
<br />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<br />
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<br />
<script src="includes/skins/style.js" type="text/javascript"></script>
<br /><?php echo $tNGs->displayValidationRules();?>
<br />
<br />
<br />
<br /><?php<br /> echo $tNGs->getLoginMsg();<br />?>
<br /><?php<br /> echo $tNGs->getErrorMsg();<br />?>
<br />
<form method="post" id="form1" class="KT_tngformerror" action="%3C?php%20echo%20KT_escapeAttribute(KT_getFullUri());%20?%3E">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table cellpadding="2" cellspacing="0" class="KT_tngtable">
<tr>
<td class="KT_th">
<label for="kt_login_user">Username:</label>
</td>
<td>
<input type="text" name="kt_login_user" id="kt_login_user" value="<?php echo KT_escapeAttribute($row_rscustom['kt_login_user']); ?>" size="32" />
<br /> <?php echo $tNGs->displayFieldHint("kt_login_user");?> <?php echo $tNGs->displayFieldError("custom", "kt_login_user"); ?></td>
</tr>
<tr>
<td class="KT_th">
<label for="kt_login_password">Password:</label>
</td>
<td>
<input type="password" name="kt_login_password" id="kt_login_password" value="" size="32" />
<br /> <?php echo $tNGs->displayFieldHint("kt_login_password");?> <?php echo $tNGs->displayFieldError("custom", "kt_login_password"); ?></td>
</tr>
<tr>
<td class="KT_th">
<label for="kt_login_rememberme">Remember me:</label>
</td>
<td>
<input <?php if (!(strcmp(KT_escapeAttribute($row_rscustom['kt_login_rememberme']),"1"))) {echo "checked";} ?> type="checkbox" name="kt_login_rememberme" id="kt_login_rememberme" value="1" />
<br /> <?php echo $tNGs->displayFieldError("custom", "kt_login_rememberme"); ?></td>
</tr>
<tr class="KT_buttons">
<td colspan="2">
<input type="submit" name="kt_login1" id="kt_login1" value="Login" />
<br /></td>
</tr>
</table>
<br />
<a href="forgot_password.php">Forgot your password?</a>
<br /></form>
<br />
<p> </p>
<br />
<br /> -
Need help with jsp that uses a java program
Hi, sorry for my english but i am italian.
I've got a problem: i use java builder and i have a java program(this program has got a main and includes libraries) about graphich on tree, this program visualizes these trees and makes operations on these.
Now i must use JSP so that a client can see this program (this program is on the server) and can interact with it.
I can't use applet.I must use only jsp.
Who can tell me how can i start???
Thanks.If you are not allowed to use an applet, then you are limited by what can be achieved with HTML in a browser.
You would have to figure out how to render it with HTML, then program your jsp to write out this html programatically. -
Query off of Oracle using WinSql - Need help with query
I am trying to query off of Oracle using program WinSql.
I have a table(tticpr200110) that has the following sample data:
ITEM CODE T$AMNT
23500076 ACL .0049
23500076 APM 0
23500076 APO .0093
23500076 EXP .0001
23500076 RES .0072
and what I want it to look like is:
ITEM ACL APM APO EXP RES
23500076 0.0049 0 0.0093 0.0001 0.0072
(actually I need the last 2 columns added together to be MATL-but can deal with that down the road).
Seems simple enough, but I don't know to put into the columns.
Any help would be GREATLY appreciated as soon as possible would be even better.My table - tticpr200110 when it runs I get the following sample data for part number 23500076:
The first coloumn ITEM is the part number.
The second column CODE is 1 of 5 different cost codes
The third column is the cost for that code for that part.
ITEM CODE AMNT
23500076 ACL 0.0049
23500076 APM 0.0000
23500076 APO 0.0093
23500076 EXP 0.0001
23500076 RES 0.0072
I want to make a query that makes the data look like this:
ITEM ACL APM APO EXP RES
23500076 0.0049 0.0000 0.0093 0.0001 0.0072
(similar to a pivot table in excel or acess)
I hope this helps better.
Thanks! -
Need help with querying pl/sql collections
hi all,
i have a requirement wherein i look thru a number of records and then updates. then i need to check if these records were successfully updated. i have the following code but it doesn't work on the part where i query the collection.
declare
type ap_invoices_all_tbl is table of ap_invoices_all%rowtype;
ap_invoices_all_rec ap_invoices_all_tbl;
cursor cai is
select *
from ap_invoices_all ai
where source = 'XXX';
begin
open cai;
fetch cai bulk collect into ap_invoices_all_rec;
for i in 1..ap_invoices_all_rec.count loop
begin
dbms_output.put_line('Invoice Status: ' || ap_invoices_pkg.get_approval_status( ap_invoices_all_rec(i).invoice_id, ap_invoices_all_rec(i).invoice_amount, ap_invoices_all_rec(i).payment_status_flag, ap_invoices_all_rec(i).invoice_type_lookup_code));
exception
when no_data_found then
null;
end;
end loop;
for j in ( select * from ap_invoices_all ai
where invoice_id in ( select invoice_id
from ap_invoices_all_rec ))
loop
dbms_output.put_line('Invoice Number: ' || j.invoice_num);
end loop;
end;i do understand that i cannot use select statement directly on a collection but i just wanted to show what i'm trying to achieve.
any suggestions on what i should do?
thanks
allenYou can not use locally defined collection(pl/sql) in SELECT statement directly, instead use Objects defined in schema.
For example:
SQL> CREATE OR REPLACE TYPE emp_rec IS OBJECT (
2 v_sal NUMBER(7,2),
3 v_name VARCHAR2(35),
4 v_empno NUMBER(4),
5 v_deptno NUMBER(2)
6 )
7 ;
8 /
Type created.
SQL> CREATE OR REPLACE TYPE emp_tab IS TABLE OF emp_rec;
2 /
Type created.
SQL> CREATE OR REPLACE TYPE dept_rec IS OBJECT (
2 v_deptno NUMBER,
3 v_dname VARCHAR2(50)
4 )
5 ;
6 /
Type created.
SQL> CREATE OR REPLACE TYPE dept_tab IS TABLE OF dept_rec;
2 /
Type created.
SQL> CREATE OR REPLACE TYPE emp_dept_rec IS
2 OBJECT (
3 v_sal NUMBER,
4 v_name VARCHAR2(35),
5 v_deptname VARCHAR2(30)
6 );
7 /
Type created.
SQL> CREATE OR REPLACE TYPE emp_dept_tab_type IS TABLE OF emp_dept_rec;
2 /
Type created.
SQL> set serverout on
SQL> DECLARE
2 l_emp_dept_tab emp_dept_tab_type; --emp_dept_tab_type declared in database
3 l_emp_tab emp_tab; --emp_tab declared in database
4 l_dept_tab dept_tab; --dept_tab declared in database
5
6 CURSOR e1 IS
7 SELECT emp_rec(sal, ename, empno, deptno) FROM emp; --Note the type casting here
8
9 CURSOR d1 IS
10 SELECT dept_rec(deptno, dname) FROM dept; --Note the type casting here
11 BEGIN
12 OPEN e1;
13
14 FETCH e1 BULK COLLECT
15 INTO l_emp_tab;
16
17 OPEN d1;
18
19 FETCH d1 BULK COLLECT
20 INTO l_dept_tab;
21
22 SELECT CAST(MULTISET (SELECT em.v_sal, em.v_name, dep.v_dname
23 FROM TABLE(l_emp_tab) em, TABLE(l_dept_tab) dep
24 WHERE em.v_deptno = dep.v_deptno) AS emp_dept_tab_type)
25 INTO l_emp_dept_tab
26 FROM DUAL;
27 FOR i IN 1 .. l_emp_dept_tab.COUNT LOOP
28 dbms_output.put_line(l_emp_dept_tab(i)
29 .v_sal || '--' || l_emp_dept_tab(i)
30 .v_name || '--' || l_emp_dept_tab(i).v_deptname);
31 END LOOP;
32
33 END;
34 /
1300--MILLER--ACCOUNTING
5000--KING--ACCOUNTING
2450--CLARK--ACCOUNTING
3000--FORD--RESEARCH
1100--ADAMS--RESEARCH
3000--SCOTT--RESEARCH
2975--JONES--RESEARCH
800--SMITH--RESEARCH
950--JAMES--SALES
1500--TURNER--SALES
2850--BLAKE--SALES
1250--MARTIN--SALES
1250--WARD--SALES
1600--ALLEN--SALES
PL/SQL procedure successfully completed.
SQL> -
Hi,
Good day everyone! I need help writing a query. I have this table with the following data in them...
ACCT_CODE FSYR YTD_AMT
A123 11 100
A456 11 200
A123 10 50
A456 10 100I want the output to look like this:
ACCT_CODE CURRENT_YEAR(11) PRIOR_YEAR(10)
A123 100 50
A456 200 100The user will input the fiscal year and based on that input, I want to get the prior year value as well.
Thank you for all your help!!
Edited by: user5737516 on Jun 29, 2011 6:48 AM
Edited by: user5737516 on Jun 29, 2011 6:50 AMuser5737516 wrote:
Hi,
Good day everyone! I need help writing a query. I have this table with the following data in them...
ACCT_CODE FSYR YTD_AMT
A123 11 100
A456 11 200
A123 10 50
A456 10 100
I want the output to look like this:
ACCT_CODE CURRENT_YEAR PRIOR_YEAR
A123 100 50
A456 200 100
The user will input the fiscal year and based on that input, I want to get the prior year value as well.
Thank you for all your help!!what is prior year? -
Need Help with IMG+PHP Database+Selective Display
The problem is really a lot simpler than I made it sounds to
be, though I fear the answer might be vice versa.
I need to have pictures appear when they exist. That's all.
Here is where I am at:
I have created a php database for a news announcement page.
In that database, I have a column named "img" whose default value
is "null"
Whenever I actually have a picture corrosponding to a
particular news, the "img" column will change to the file name of
that image, which I will then extract.
So basically... if news A, img = null... no picture. news B
img = b... then yes picture. very simple concept for database.
Here's what I can't do.
When I read the database from DW, how can I make it so that
when it reads a "null" it won't insert a picture and vice versa? I
figure it definitely has to do with the "if" statement (duh...)
I know how to make text do that effect...
<? if $row_data['text'] != null
echo("i have data");
?>
but how do i do it with an image? I tried putting the image
tag to replace the entire "echo" line, but that's apparently not
how you do it. I tried putting it inside "echo", but that doesn't
seem to be it either.
also, as a premise, all pictures are associated with only 1
particular news.
which i wrote something similar to this:
<img src="<?php echo $row_data['img']; ?>.jpg"
width="200" height="200" />
Um, basically... I need THAT to fit into the IF statement. So
thanks in advance.if (!is_null($row_data['img']))
echo '<img src="',$row_data['img'],'.jpg" width="200"
height="200" />';
Let's break that down into the following:
echo '<img src="' ;
echo $row_data['img'] ;
echo '.jpg" width="200" height="200" />' ;
When you string multiple echoes together use a comma between
them,. so now
we have:
echo '<img src="',$row_data['img'],'.jpg" width="200"
height="200" />';
(You may also use a period, but my understanding is the
period is less
efficient.)
I only have single quotes in my PHP statements. The double
quotes you see
are part of what will be the rendered HTML.
You may generally use the single quote or double quote
interchangeably with
few exceptions such as having double quotes as part of the
text or vice
versa among others. You can probably escape the characters
too, but lets
keep this simple for now.
If I misspoke I am sure Micha will be sure to correct me.
IMO The best thing to do is learn by trial and error, and
your best resource
on the net for PHP is probably the php website. www.php.net
"Bih Wang" <[email protected]> wrote in
message
news:gr3p0m$293$[email protected]..
> thanks so much!
>
> is how i interpret the code correct?
>
> if (!is_null($row_data['img'])) ---> if img is false
> echo <--- maybe i been using this without
understanding it correctly...
> echo
> means to display on screen but not limited to text
right?
>
> and the rest is where you lost me... i don't get the
punctuations
>
> bracket double quote (" is for text right?
> so single quote ' means to accept a php function or html
code?
>
> so can i do this?
> '<div bob>blah'
> and have div bob appear only when the conditions are
met?
>
> and external data is define by comma?
> such as... if i pre-define value "x"
> so i can do img src=',x,'.jpg?
>
> thanks again! is there a tutorial i can read for these?
>
> -
Problems with query that uses date as filter .
I have an application and it's have a form automatically generated by Apex, through a View. That view use instead of triggers to update , insert and delete, because the view use many tables..
But always that I run a query using filters, setting a period of date, some dates show data, but the majority not, even if they have data on the database.
I even looked for the datas in the table on Object's Browser and filter by the dates that has the problem and they showed the values registered on these dates.
But I don't have a idea why it doesn't show these values when I run the query.
Exemple of query used : select * from coresp where data_2 between '22/05/09' and '22/05/09';
this query return two lines, but in object's browser return more than 100 lines .
Edited by: user9537971 on 09/06/2009 07:01
Edited by: user9537971 on 09/06/2009 07:01Hi,
You need to make sure that SQL knows that these are dates by using the TO_DATE() function:
select * from coresp where data_2 between TO_DATE('22/05/09','DD/MM/YY') and TO_DATE('22/05/09','DD/MM/YY')Andy -
Need help with union of two selects
select 1 selects items for a timespan.
But if there is nothing found at one date,
the date is not returned so I want a union with a calendar table
Both selects work but how to make the union?
Thanks for any help!
select 1:
SELECT COUNT(*) COUNT,
fb_operation prodstep,
kalenderwoche datum
FROM stoerung,
kalender
WHERE str_kommenzeit > to_date('13.06.2006', 'dd.mm.yyyy')
AND str_kommenzeit < to_date('11.07.2006', 'dd.mm.yyyy')
AND to_char(str_kommenzeit,'dd.mm.yyyy') = to_char(fulldate,'dd.mm.yyyy')
GROUP BY fb_operation,
kalenderwoche
ORDER BY fb_operation,
kalenderwoche
select 2:
SELECT kalenderwoche datum
from kalender
WHERE fulldate > to_date('13.06.2006', 'dd.mm.yyyy')
AND fulldate < to_date('11.07.2006', 'dd.mm.yyyy')THANKS A LOT!
I tested it and it gave me good results
the problem I still have is that then I expand the Date to
to_date('11.12.2006') I just get the weeks
that contain data. But I need all weeks that are selected, if there is
no data the other fields shall be null or 0.
This is much too difficult for me perhaps you can also help me with this!
select * from
(SELECT COUNT(*) COUNT,
fb_operation prodstep,
kalenderwoche datum
FROM stoerung,
kalender
WHERE str_kommenzeit > to_date('13.06.2006', 'dd.mm.yyyy')
AND str_kommenzeit < to_date('11.12.2006', 'dd.mm.yyyy')
AND to_char(str_kommenzeit,'dd.mm.yyyy') = to_char(fulldate,'dd.mm.yyyy')
GROUP BY fb_operation,
kalenderwoche
ORDER BY fb_operation,
kalenderwoche) A,
(SELECT kalenderwoche datum
from kalender
WHERE fulldate > to_date('13.06.2006', 'dd.mm.yyyy')
AND fulldate < to_date('11.12.2006', 'dd.mm.yyyy') ) B
where A.datum = B.datum (+) -
Need Help With Military DTD Using FrameMaker 8
Fellow Forum Members,
I hope someone out there with experience in using Department of Defense DTDs with FrameMaker can contribute to this thread.
Attached is the MIL STD 400051-2 DTD that needs to play with FrameMaker. Does anyone out there know where I could find FrameMaker templates already setup that comply and play with the MIL STD 400051-2 DTD standard? If the Department of Defense is freely distributing the MIL STD 400051-2 DTD, shouldn't somebody in the Department of Defense also be providing MIL STD 400051-2 FrameMaker Templates for free that are already setup? I would greatly appreciate if anyone out there could provide an online source where I could download MIL STD 400051-2 FrameMaker templates.
Lastly, can anyone out there clarify what the purpose of the entities are inside the "Charant" and "Boilerplate" folders? The Department of Defense does not provide a readme file that define what the "Charant" and "Boilerplate" folders are about.
Any info will be greatly appreciated. Thanks.I'll answer the specifics that I know about your questions, but please look at the post from Srini for additional info:
1) Do i need to do full export using SYS/SYSTEM user.
exp80 system/manager file=c:full.dmp log=c:\full.txt full=y consistent=yA full export will move as much information (metadata/data) as possible. In order to do a full export/import, you need to do this from a
privileged account. A privileged account is one with EXP_FULL_DATABASE for export and IMP_FULL_DATABASE for import.
2) Will there be any data corruption while export.The data in the objects that you are exporting is being read, nothing is written to user data. I'm not sure what this is available in 8.0.6,
but if you need a consistent export, look to see if consistent=y is available in 8.0.6. All this means is that the dump file created will have
consistent data in it.
3) Is export/import the only method of migration/upgradation.If you are changing hardware, the only supported way from 8.0 to 10.2.0.4, that I know of, is using exp/imp.
Hope this helps.
Dean -
Need help with database migration using export/import
Hi,
I am planning to do a database migration from 8.0.6 to 10.2.0.4. I am using export/import. Please answer some of my queries:
1) Do i need to do full export using SYS/SYSTEM user.
exp80 system/manager file=c:full.dmp log=c:\full.txt full=y consistent=y
2) Will there be any data corruption while export.
3) Is export/import the only method of migration/upgradation.
Please help
Thanks.I'll answer the specifics that I know about your questions, but please look at the post from Srini for additional info:
1) Do i need to do full export using SYS/SYSTEM user.
exp80 system/manager file=c:full.dmp log=c:\full.txt full=y consistent=yA full export will move as much information (metadata/data) as possible. In order to do a full export/import, you need to do this from a
privileged account. A privileged account is one with EXP_FULL_DATABASE for export and IMP_FULL_DATABASE for import.
2) Will there be any data corruption while export.The data in the objects that you are exporting is being read, nothing is written to user data. I'm not sure what this is available in 8.0.6,
but if you need a consistent export, look to see if consistent=y is available in 8.0.6. All this means is that the dump file created will have
consistent data in it.
3) Is export/import the only method of migration/upgradation.If you are changing hardware, the only supported way from 8.0 to 10.2.0.4, that I know of, is using exp/imp.
Hope this helps.
Dean -
Need help with reading XML using File Adapter
I have created a simple BPEL process that uses a file adapter to read files containing XML messages of a simple xsd schema. But when reading the xml, I get the following error message:
[2010/03/01 23:43:13] Invalid data: The value for variable "Receive_1_Read_InputVariable", part "revision-report" does not match the schema definition for this part.The invalid xml document is shown below: More...
[2010/03/01 23:43:13] "{http://schemas.oracle.com/bpel/extension}invalidVariables" has been thrown. less
-<invalidVariables xmlns="http://schemas.oracle.com/bpel/extension">
-<part name="code">
<code>
9710
</code>
</part>
-<part name="summary">
<summary>
Invalid xml document.
According to the xml schemas, the xml document is invalid. The reason is: Error::cvc-complex-type.4: Attribute 'doc' must appear on element 'revision-report'.
Error::cvc-complex-type.4: Attribute 'model' must appear on element 'revision-report'.
Error::cvc-complex-type.4: Attribute 'pubdate' must appear on element 'revision-report'.
Error::cvc-complex-type.2.4.b: The content of element 'revision-report' is not complete. One of '{"http://xmlns.oracle.com/xmlfile":alternategroup}' is expected.
Please make sure that the xml document is valid against your schemas.
</summary>
</part>
</invalidVariables>
It seems that there is some issue with the namespace, but even after trying out various combinations, I am not able to resolve this.
Here the message schema (xsd):
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/xmlfile"
xmlns:tns="http://xmlns.oracle.com/xmlfile"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="revision-report">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="alternategroup">
<xs:complexType>
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="Desc" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="doc" use="required" type="xs:string"/>
<xs:attribute name="model" use="required" type="xs:string"/>
<xs:attribute name="pubdate" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
And here is the xml file to be read by the file adapter:
<?xml version="1.0" encoding="UTF-8" ?>
<revision-report doc="doc2" model="model4" pubdate="pubdate5">
<alternategroup Name="ABC" Desc="ABC-Desc">
</alternategroup>
<alternategroup Name="DEF" Desc="DEF-Desc">
</alternategroup>
<alternategroup Name="GHI" Desc="GHI-Desc">
</alternategroup>
</revision-report>
Appreciate any help.
Thanks in advance for your attention.
JayThanks for your response.
I am not sure if there is any easier way, but I tried out the following tool available on the net to check an xml against a xsd:
http://tools.decisionsoft.com/schemaValidate/
There were a few issues, that I corrected and finally had a xsd and xml that were matching and valid. I tried this out in my file reading BPEL process, but the error still remained the same!
Here is my updated/simplified xsd and xml:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema targetNamespace="http://xmlns.oracle.com/xmlfile"
xmlns:tns="http://xmlns.oracle.com/xmlfile"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://xmlns.oracle.com/xmlfile">
<xs:element name="revision-report">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="alternategroup"/>
</xs:sequence>
<xs:attribute name="doc" use="required" type="xs:string"/>
<xs:attribute name="model" use="required" type="xs:string"/>
<xs:attribute name="pubdate" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="alternategroup">
<xs:complexType>
<xs:attribute name="Name" use="required" type="xs:string"/>
<xs:attribute name="Desc" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8" ?>
<revision-report doc="doc2" model="model4" pubdate="pubdate5" xmlns="http://xmlns.oracle.com/xmlfile">
<alternategroup Name="ABC" Desc="ABC-Desc"/>
<alternategroup Name="DEF" Desc="DEF-Desc"/>
<alternategroup Name="GHI" Desc="GHI-Desc"/>
</revision-report>
I even tried the option that is available in JDeveloper to generate a sample xml from a xsd (when in the context of a Transformation activity). The xml generated by this also seems exactly like the one above.
So, I am not able to figure out why my BPEL process errors out with the message Invalid xml document. -
I am Stuck! Need Help With Multicast Streaming Using VLC Player
I have a Multicast network topology shown below
and my configs
HUB ROUTER
no ip domain lookup
ip domain name primestarhotel.com
ip multicast-routing
interface Loopback0
ip address 5.5.5.5 255.255.255.255
ip pim sparse-dense-mode
interface FastEthernet0/0
ip address 200.0.0.2 255.255.255.240
ip pim sparse-dense-mode
ip virtual-reassembly
speed 100
full-duplex
interface FastEthernet0/1.65
description "Server Vlan"
encapsulation dot1Q 65
ip address 10.1.65.1 255.255.255.0
ip pim sparse-dense-mode
ip virtual-reassembly
router ospf 200
log-adjacency-changes
network 5.5.5.5 0.0.0.0 area 0
network 10.1.65.0 0.0.0.255 area 0
network 200.0.0.0 0.0.0.15 area 0
ip route 200.1.1.0 255.255.255.252 200.0.0.1
ip route 200.2.2.0 255.255.255.252 200.0.0.1
no ip http server
no ip http secure-server
ip pim send-rp-announce Loopback0 scope 6
ip pim send-rp-discovery Loopback0 scope 6
ISP ROUTER
interface FastEthernet1/0
interface FastEthernet1/1
no switchport
ip address 200.0.0.1 255.255.255.240
ip pim sparse-dense-mode
duplex full
speed 100
interface FastEthernet1/2
no switchport
ip address 200.1.1.1 255.255.255.252
ip pim sparse-dense-mode
duplex full
speed 100
interface FastEthernet1/3
no switchport
ip address 200.2.2.1 255.255.255.252
ip pim sparse-dense-mode
duplex full
speed 100
router ospf 200
log-adjacency-changes
network 200.0.0.0 0.0.0.15 area 0
network 200.1.1.0 0.0.0.3 area 0
network 200.2.2.0 0.0.0.3 area 0
SPOKE 1 Router
interface FastEthernet0/0
ip address 200.1.1.2 255.255.255.252
ip pim sparse-dense-mode
speed 100
full-duplex
interface FastEthernet0/1
no ip address
ip pim sparse-dense-mode
ip virtual-reassembly
speed 100
full-duplex
interface FastEthernet0/1.12
description "Workstation pc"
encapsulation dot1Q 12
ip address 10.1.12.1 255.255.255.0
ip pim sparse-dense-mode
router ospf 200
log-adjacency-changes
network 10.1.12.0 0.0.0.255 area 0
network 200.1.1.0 0.0.0.3 area 0
ip route 0.0.0.0 0.0.0.0 200.1.1.1
SPOKE 2
interface FastEthernet0/0
ip address 200.2.2.2 255.255.255.252
ip pim sparse-dense-mode
speed 100
full-duplex
interface FastEthernet0/1
ip address 10.2.22.1 255.255.255.0
ip pim sparse-dense-mode
speed 100
full-duplex
router ospf 200
log-adjacency-changes
network 10.2.22.0 0.0.0.255 area 0
network 200.2.2.0 0.0.0.3 area 0
ip route 0.0.0.0 0.0.0.0 200.2.2.1
ip route 200.2.2.0 255.255.255.252 200.0.0.1
I have implemented multicast on the network in a hub and spoke topology. i have set up ospf routing protocol and broadcast all network and can successfully ping.
I am currently using VLC player as my media streaming server and client. i have set up rtp streaming from the HUb router using multicast ip 224.2.2.2 and unable to broadcast the multicast traffic across the spokes 1 and 2 PC's
I have never used vlc player never set up multicast network before and i am struggling with this and need help.
these are my router configs below
http://dl.dropbox.com/u/20145606/ip%20video%20config.txt
Message was edited by: Louis OjuwuI have edited the message and the configs and topology are visible above now. instead of the links i provided
Maybe you are looking for
-
Dbca problem on rh 7.2 and 7.3 with Oracle 9.2
hi! i have problems using dbca on my redhat 7.2 and redhat 7.3 machine with fresh installed oracle 9i release2. installation succeded with no problems, but now i have problem creating database with dbca. however, when i type dbca & as user oracle, i
-
DMVPN Hub and Spoke behind NAT device
Hi All, I have seen many documents stating about DMVPN Hub behind NAT or DMVPN Spoke behind NAT. But My case i involve in both situation. 1) HUB have a Load Balancer (2 WAN Link) ISP A & B 2) Spoke have Load Balancer (2 WAN Link) ISP A & B Now the re
-
how to upgrade P 6.2 to P 6.8 and is it free of charge
-
Aperture 3 Intermittent Crashing
I have been using AP2 the past year or so... and love it. I downloaded the demo for AP3 and REALLY like the new features. The conversion process of my old library went well. BUT... I notice a couple times a day the program crashes. The program reboot
-
How to control speaker Pavilion dv7
Cannot get the the speaker on an elder freind's HP Pavilion dv7 - Product # xz288ua. Any help will be appreciated. Jerome