Two variables in the name of a table in the FROM clause.
HelloI have a problem to make this work:
SELECT *.
OF tablename_YY_MM
(This is part of the script I use YY and MM in different tables)
I need to find a way for the script asks me every time on AA and the MM
For example, the current name of the table "tablename_09_08" next month, it will be 'tablename_09_09 '.
It seems simple, but I can't get it to work. There seems to be a problem with concatenate | and the underscore _
Looks like this should be done with PL/SQL?
If anyone can help it will be much appreciated.
Thank you.
Published by: user1067236 on August 11, 2009 02:21
Published by: user1067236 on August 11, 2009 02:23
SQL>SELECT * FROM tablename_&YY._&MM;
Enter value for yy: 09
Enter value for mm: 08
old 1: SELECT * FROM tablename_&YY._&MM
new 1: SELECT * FROM tablename_09_08
SELECT * FROM tablename_09_08
HTH, Urs
Tags: Database
Similar Questions
-
Results of the query variant with unused table in the from clause
Hi all
I (processing_table2) table specified in the FROM clause in the SQL query , but I have not used any of its value in the SQL statement , but it still affects the results of the query. Please help me out here I'm naïve.
This is the provided query
SELECT SUM((CREV.sadc_extd*CSSP.redit_pcnt)/100)
OF crev revenue_lines,.
cssp sales_split,
processing_table2
WHERE crev.order_num = '7631090072'
Results of the above query : 344028065018.359
SELECT
Sum((CREV.sadc_extd*CSSP.redit_pcnt)/100)
OF crev revenue_lines,.
sales_split PCSS
WHERE crev.order_num = '7631090072'
Results of the above query : 26463697309.1046
Someone here suggest me pls!924804 wrote:
Hi allI (processing_table2) table specified in the FROM clause in the SQL query , but I have not used any of its value in the SQL statement , but it still affects the results of the query. Please help me out here I'm naïve.
This is the provided query
SELECT SUM((CREV.sadc_extd*CSSP.redit_pcnt)/100)
OF crev revenue_lines,.
cssp sales_split,
processing_table2
WHERE crev.order_num = '7631090072'Results of the above query : 344028065018.359
SELECT
Sum((CREV.sadc_extd*CSSP.redit_pcnt)/100)
OF crev revenue_lines,.
sales_split PCSSWHERE crev.order_num = '7631090072'
Results of the above query : 26463697309.1046
Someone here suggest me pls!
CARTESIAN PRODUCT of the changes result set
-
Effect of an additional table in the FROM clause in the query results?
I recently helped a colleague debug one of their SQL statements
The output was showing some very unexpected totals, and I was able to shrink down to an additional table in the FROM clause, but not used anywhere else in the application.
Thus, for example
SELECT A.ID, B.CODE
Of
EMPLOYEE,
B OF THE STATUTE,
PAY THE SAL
WHERE A.ID = B.ID
AND
A.ID = 1;
I was wondering, how can an extra table in a FROM clause influence directly on the rest of the query?
The query above is just an example of what I've seen, the my co worker was working on is a bit larger and a lot more code to read. I noticed that when I added/removed the extra table in my query to co workers and then it worked as expected.
I always thought that an additional table is not attached to what anyone would be just to do the inefficient code, but does not affect outputjust do the inefficient code
Yes, that too, you will get a Cartesian product by calling is not the entries in the where clause for this table 'disappeared' :(
-
Number of tables in the from clause
Hello
Can someone tell me how many tables can we have clause in oracle.As you can see it
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14237/limits003.htm#i288032
Subqueries levels Maximum of subqueries in a unlimited SQL in the FROM clause in subqueries queries Top Level 255 in the WHERE clause
Subqueries in the FROM-> unlimited, so number of tables is also unlimited (limited only by the size of SQL and probably time of your life while waiting to join thousands of tables :)) results
-
Question on the use of expressions and aliases in the FROM clause
Hello
I have the following query
outputs (of your choice):select substr(e.ename, iter.pos, 1) as C from (select 'KING' as ename from dual) e, (select rownum as pos from dictionary where rownum <= 100) iter where iter.pos <= length(e.ename);
For the purposes of hardcode 'KING' was made for the test, IRL would be a column from other tables. Is the other piece that is hardcoded "where rownum < = 100 ' and it's the one I would like to find a way to remove.C - K I N G
I tried the following:
Unfortunately this does not work because the SQL parser has not analyzed enough of the FROM clause to know e.ename causing the length (e.ename) expression return a message identifier unknown.select substr(e.ename, iter.pos, 1) as C from (select 'KING' as ename from dual) e, (select rownum as pos from dictionary where rownum <= length(e.ename)) iter where iter.pos <= length(e.ename);
I tried to restructure the query above to make the SQL parser aware of the e.ename early enough and therefore accept it. My efforts have failed.
I would like to know if there is a way to restructure the statement length (e.ename) can be used instead of Hardcoding an artificial upper limit (for example 100 as in the first statement).
Thank you
John.Use CONNECT BY LEVEL:
SQL> select substr(ename, level, 1) 2 from ( select 'KING' ename 3 from dual 4 ) 5 connect by level <= length(ename); S - K I N G 4 rows selected.
-
How can I model the RPD with the sub query that has the subquery in the from Clause.
SELECT
o948938. CONSOLIDATED_NAME,
(SUM (o948992. YTD_COMPLETED)) / (SUM (TOTAL_OCC_AP)) AS C_1,.
SUM (TOTAL_OCC_AP) AS TOTAL_OCC_AP,
Of
ORG_DIM o948938,
TIME_MONTHLY_DIM o948963,
INSPECTION_FACT o948992,
(SELECT TDS_NUM,
MONTH_ID,
SUM (TOTAL_APTS) TOTAL_AP,
OF SUMMARY_FACT
TDS_NUM GROUP,
MONTH_ID
) O949126
WHERE (o949126. MONTH_ID = o948992. MONTH_ID (+)
AND o949126. TDS_NUM = o948992. TDS_NUM (+)
AND (o948938. TDS_NUM = o949126. TDS_NUM)
AND (O948963. MONTH_ID = O949126. MONTH_ID))
Group
O948938. NEW_BOROUGH_GROUPING
Hello
You can do this via an opaque view.
You can also do this by modeling the cumulative value as a calculation LOGIC in the group by aggregation "pinned" to a specific dimension hierarchy that reflects consolidation in the online posting.
Hope this helps,
Robert.
-
Using a Bind Variable in the FROM of a SQL statement part?
Hi all
I have a problem, I am trying to execute a SQL statement. However, I need the FROM part of the SQL statement in a variable binding. This is because the end user will have to choose between 2 views of database.
I tried this:
Select CON_ID from: P23_DB_NAME where CON_LEGACY_ID =: P23_CONLEG_NO
I had no chance. The error I got was,
'+ The query cannot be parsed in the generator. If you believe that your request is
syntactically correct, choose the generic "columns" box below the
the source of the region without analysis.
"ORA-00903: invalid table name +".
What makes sence, but now I'm a little stuck.
Does anyone have ideas for a workaround?
Thanks in advance.
-N.S.N.O.
The example I gave you is quite simple. You must take some time to study it to see where you need to be very careful what put you where. Now, of course your example does not work becaues you have several errors. It will work for you:
DECLARE x VARCHAR2 (4000); BEGIN x := x || 'SELECT CON_ID FROM '; x := x || :p23_db_name; x := x || ' WHERE CON_LEGACY_ID = ' || :p23_conleg_no; RETURN (x); END;
Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
------------------------------------------------------------------- -
Session variable in the WHERE clause of the SQL statement
Hey all,.
I was wonering just if there is a way to set the WHERE clause of the query that the session variable? I have the following so far and have tried to go through a ton of tutorials, but it doesn't seem to work. Is it still possible? I don't know what follows is wrong, but can someone help me with changing the following code, or pointing me to a good tutorial? (I write it with PHP)
$query = "SELECT * from members where user_id = ' $_SESSION ['members']";
Thanks for your help.
$member = "-1";
If (isset($_SESSION['members'])) {}
$member = $_SESSION ['members'];}
$query = "SELECT * from members where user_id = $member; -
How to put the subquery in the from clause
Hi all
I want to put a my from clause subquery. I want to show the details of an account, when the status is active, but I want to show the date when he opened.
Here is my report query.
Select t.acct_id, x.acct_status_Dt
of cust_acct t, (select t1.acct_id, t1.acct_status_Dt from t1 cust_acct where t1.acct_status_code = 'OPEN') x
where t.acct_id = x.acct_td
and t.acct_status_code = 'ACTIVE'
Someone knows how to impliment this kind of query in OBIEE without RPD Exchange.
Help, please...Hello
To be more clear, ask in the Advanced tab of the request, should look like:
select A.saw_0, x.saw_1 from (select acct_id saw_0 from cust_acct)A, (select acct_id saw_0, acct_status_Dt saw_1 from cust_acct where cust_acct.acct_status_code='OPEN') x where a.saw_0=x.saw_0
Actual query that you pasted:
select t.acct_id,x.acct_status_Dt from cust_acct t , (select t1.acct_id, t1.acct_status_Dt from cust_acct t1 where t1.acct_status_code='OPEN') x where t.acct_id= x.acct_td and t.acct_status_code='ACTIVE'
I think it is x.acct_id in where clause... not x.acct_td, I corrected and wrote the sql above...
Published by: Kishore Guggilla, July 17, 2009 12:00
-
* Dynamic * Table name in the From Clause, with the help of the cursor
Hello
I said a slider...
Select the table table_name from dba_tables where < blah >
The result is
Row1: emp
rwo2: emp_1-> tables have the same structure and quite different data... Please don't ask why it's like that, and we can not change...
Now, we need to run an Insert...
Insert into tableX (col1, col2,...) select a, b,... from < o/p of the cursor > where < blah >...
Note: The table changes name and it the cursor can o/p emp, emp_a and emp_b.
Trying to do at the same time instead of do series and with the best performance... .no sql injection issues.
In parallel, I mean
Insert into tableX (col1, col2,...) select a, b,... from emp where < blah >
and insert tableX (col1, col2,...) select a, b,... from emp_1 where of < blah > statements at the fire parallel / at the same time to the database. If you can share the procedure if you guys already have with you... is really appreciated
Thank you very much for your time...
Published by: user007009 on April 27, 2013 20:33>
because suppose each request took 10 minutes and we have 5 tables, then 50 minutes so executed in series and 5 minutes, if each of them both right... I'm saving this time
>
And that's what I'm talking about when I said that
>
what you're doing wrong is trying to implement solutions more possible complex for a problem that does not exist yet.
>
You do not HAVE a problem. You are just "assuming"; "Suppose that each query took 10 minutes... ».Well suppose that the time it takes to "chunk" the query, run it in parallel is longer than the time it takes to simply run the query. Oh, wait, that OF what you have discovered.
Well, let's assume that each query took 2 seconds. Assume that all this takes that half a second. Suppose you waited until you actually have a problem.
The solutions are to solve real problems, not imaginary and non-existent problems.
If all you are doing is "assume that" you will never find a 'solution' because you could always 'suppose' another problem that prevents this 'solution' of work.
-
Reference SQL Loader Bind Variables in the when Clause
Support for SQL: SQL * Loader: version 8.0.6.3.0 (don't ask, it runs on Oracle EBS 11i...)
I have a case where my sample data looks like:
and another fileHD00100001002 SM00100002CHAPS 99999999999 20120906GBP0000000000001000000000001
Essentially, I need to apply another "IN" clause for each record of SM depends on the ack_type (char 13 on HD recording), either 1 or 2HD00100001001 SM00100002GBP0000000000001000000000001
I tried setting up the ack_type with a variable binding but find how to reference.
Example of control file:
The code above does not work, it is said that: ack_type is not recognized. Is there a way to do it, given the former character of the SQL Load version?-- $Header: test.ctl -- LOAD DATA REPLACE -- Record Type HD : File Header INTO TABLE test_table WHEN rec_id_no = 'HD' TRAILING NULLCOLS (rec_no RECNUM, hdr_line CONSTANT 'H', rec_id_no POSITION(1:2) CHAR, file_number POSITION(3:5) CHAR, sequence_number POSITION(6:10) CHAR, status POSITION(11:12) CHAR, ack_type POSITION(13:13) ":ack_type", co_id POSITION(14:21) CHAR, dept_id POSITION(22:24) CHAR, btch_no POSITION(25:36) CHAR, trans_id POSITION(37:42) CHAR) -- Record Type SM : File Summary INTO TABLE test_table WHEN rec_id_no = 'SM' and :ack_type = '1' TRAILING NULLCOLS (rec_no RECNUM, hdr_line CONSTANT 'L', rec_id_no POSITION(1:2) CHAR, file_number POSITION(3:5) CHAR, sequence_number POSITION(6:10) CHAR, ccy_code POSITION(11:13) CHAR, amount POSITION(14:26) CHAR, number_trans_ok POSITION(27:40) CHAR)
What is the database version 11i is running on? If 11 GR 2, this doc can help you in the use of the features that Dan mentions
How to use the 9i or 10g features in SQL * Loader for Apps? [423035.1 ID]
HTH
Srini -
Problems of execution of a SQL function with a variable in the WHERE clause
Hello world!
I have programmed a function that returns a boolean value based on the result of the SQL. It's the function:
FUNCTION existe_secuencial (seq_name VARCHAR2) RETURN AS BOOLEAN
cursor c2 is SELECT FROM all_sequences WHERE upper (sequence_name) = sequence_name' | seq_name | ' ;
BEGIN
OPEN c2;
DBMS_OUTPUT. Put_line (nombre_seq);
Get c2 INTO kk;
If c2% NOTFOUND = True THEN
RETURNS false;
on the other
RETURNS true;
end if;
END existe_secuencial;
And I give the floor to the function of a procedure in this way:
IF existe_secuencial ("SEQ_ARQUETA") = True THEN
DBMS_OUTPUT. Put_line ('exists');
ON THE OTHER
DBMS_OUTPUT. Put_line ("' NOT exists");
END IF;
The probrem that this SQL is forced to return results because this sequence exists in the comic book, but is not, return me the FALSE value. What makes me mad is that if I change the second line of the function in this way:
> > cursor c2 is SELECT FROM all_sequences WHERE upper (sequence_name) sequence_name ="SEQ_ARQUETA";
It works find and return of sequence existing (real)
Can someone help me please, I'm quite desperate to find what is the problem with that because I do not understand why if I built the slider with a variable returns no results so that if I do write it works...
Thanks in advance!
Itziar
Frame you your variable in quotes, which makes the string literal ' |. ' seq_name | "rather than the content of the variable.
I think that something like this would be an improvement.
function existe_secuencial (seq_name VARCHAR2) return a Boolean value as
number of exist_check: = 0;
Start
Start
Select 1
in exist_check
of all_sequences
where upper (sequence_name) = upper (seq_name);
exception
When no_data_found then
null;
end;
return (exist_check = 1);
end existe_secuencial;
-
NUMBERS FROM 1 TO 300 WITH THE HELP OF THE TABLE 'DOUBLE' IN FROM CLAUSE
Hi masters.
I need display numbers from 1 to 300.
We can achieve this by
Select rownum from TABLE_NAME where ROWNUM < = 300;
But the need to display table DOUBLE...Try this:
SELECT the level "Numbers."
OF the double
CONNECT BY LEVEL<=>=> -
Sage line initialized the variable in the WHERE clause of another block of initialization
Hello
I have following problem.
I created a block of initialization (called A) which initializes a wise session variable line.
Ex: SELECT X, Y, z
SELECT statement returns 3 rows (it is a block of initialization sage line!)
So I want to create another block of initialization that uses in its cluase WHERE the sage variable line previous
Ex: SELECT W, T of R where F = VALUEOF (NQ_SESSION. (A)
I have the following error: DB2 - UDB: token SQL10104; was not valid, valuable chips:...
I believe that this error is caused by the fact that VALUEOF (NQ_SESSION. (A) is translated by OBIEE inside (a list of values separated by; and not by).
Can you suggest me a solution?
Thank you
Giancarlo
P.S. I use OBIEE 10 GYou can avoid this by rewriting it as
t w, select
r
where f (with x = 'A' by selecting y in z)Kind regards
Robert
-
Assign the values of the two variables in a select statement
I'm trying to set two variables in a select statement in my definition of the procedure. I get the error identifier not valid "ATTRIBUTE" running the following code.
Can I not connect two different values to two different variables in the same select?create or replace procedure tbl_auth ( Email in varchar2, UserLevel out number) as v_Email varchar2(100) := lower(Email); v_login_chk number := 0; begin select UserLevel into p_UserLevel, v_login_chk into v_login_chk from tbl_User where eMail=v_Email exception when no_data_found then UserLevel := 0; end tbl_auth;
Thank you
Published by: jerry8989 on August 22, 2011 07:06
Published by: jerry8989 on August 22, 2011 07:06change as follows:
select UserLevel, v_login_chk into p_UserLevel, v_login_chk
IN ONE ALONE is enough.
BTW, don't you have "login Check" column in the "tbl_user"? If you do, your selection should be like this:
... select UserLevel, loginChk into /* check the column name in your table */ p_UserLevel, v_login_chk from tbl_User ...
Maybe you are looking for
-
Terrible GPS Since his arrival in new carrier
Hello I moved from AT & T to tmobile. I had an iphone 6 with at & t and now have an iphone6s Since his arrival, all my applications that rely on the GPS are almost unusable. Specifically, cards and my bike app following my tour. I thought GPS was not
-
I can't get the hang of lightning Gigabit Ethernet Adapter (MD463LL/A) working on my Macbook Pro 15 inch 2014 (11.2). When I plug the unit in each port thunderbolt I don't see anything on the screen. However, when I look in the section "Thunderbolt"
-
I recently reinstalled windows 8.1 and started from scratch with firefox. My clock of the computer somehow obtained a day before in the process, so all my browsers gave me errors. I fixed the date and all other browsers are fine, but Firefox still gi
-
An another name/phone number
Hello! Lately, when I tried iMessaging father, non-iPhone from my friend mobile number appears. Why is it so? And how can I solve this problem? Accidentally press some buttons wrong? Please help, because my friend gets my messages instead of my fathe
-
MacBook Pro opens to the screen and progress bar gray, freezes when the progress bar ends. Have tried several options to get into safe mode and suggested strikes, but can't. Any suggestions?