Using Variables in a system SQL query
Hello!I m new on Oracle and SQL so I Don t know not big thing about it.
There is problem of customization:
Is it possible to use the System Variable % username % in a SQL query?
I tried... where table.shorttag = "% username %";
but it does not work.
Oracle is able to manage Systemvariables? Or y at - it another way to use the current Windows user in a SQL query.
It is very Important to use the current Windows user and not the Oracle user.
Thank you
MFG
SELECT OSUSER FROM V$SESSION WHERE audsid = USERENV('sessionid')
URS
Tags: Database
Similar Questions
-
Using a Variable to create the SQL query
I need to create a "dynamic" update query I want to hold the meeting of the command in a variable and then refer to the query variable.
Example:
< cfquery name = "fred" datasource = "mydb" >
Update db_table_name set
PBname = "Fred Flintstone",
pbnumber = ' 555-555-1234. '
pbage = 25
where recnum = 24
< / cfquery >
I would like use this code:
< cfset upst = "pbname ="Fred Flintstone", pbnumber =' 555-555-1234, pbage = 25" > ".
< cfquery name = "fred" datasource = "mydb" >
Update db_table_name set
#upst #.
where recnum = 24
< / cfquery >
When I run the present, I get the following error message:
Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] syntax error (missing operator) in query expression "Fred Flintstone".
The SQL is:
Update db_table_name set pbname = "Fred Flintstone", pbnumber = "555-555-1234", pbage = 25 where recnum = 24
I know it's hard to see, but the "are 2' No 1". I have no idea why Coldfusion (or perhaps the ODBC driver?) puts the 2nd "in the command that causes the errors.
Anyone can shed some light on this subject?
While it is a simple example, my application is much more complex. I have over 50 fields in the update and based on changes to the values of the form, I may need to update all fields, some fields or NO fields.
Can I use < cfif > test if all the fields have changed and if so, include them in the update command, but if NONE of the fields have changed, I update the command vacuum and therefore get an error. I want to avoid having to test changes twice (once to determine if I do the update and twice to perform the update).
Thank you
Mike.
CF automatically escapes single quotes, he must preserve them
Update db_table_name set
#PreserveSingleQuotes (upst) #.
where recnum = 24
Ken
-
Using variable in a PL/SQL block
Here's my query.
OVER the years LIKE)
SELECT ROWNUM rn
OF the double
CONNECTION OF LEVEL < = (select round (SYSDATE-to_date('2010-01-01','YYYY-MM-DD')) double))
Select
TO_CHAR (to_date('2010-01-01','YYYY-MM-DD')-1 + rn, 'yyyy') * 10000 + (to_date('2010-01-01','YYYY-MM-DD')-1 to_char + rn, "mm") * 100 + (to_date('2010-01-01','YYYY-MM-DD')-1 to_char + rn, 'dd') As Date_ID
, to_date('2010-01-01','YYYY-MM-DD')-1 + rn as 'Date '.
(, to_char (to_date('2010-01-01','YYYY-MM-DD')-1 + rn, 'yyyy') as the year
(, to_char (to_date('2010-01-01','YYYY-MM-DD')-1 + rn, 'MM') As Month_Number
(, to_char (to_date('2010-01-01','YYYY-MM-DD')-1 + rn, 'Months') as month
(, to_char (to_date('2010-01-01','YYYY-MM-DD')-1 + rn, 'dd') as DayOfMonth
(, to_char (to_date('2010-01-01','YYYY-MM-DD')-1 + rn, 'Day') As DayOfWeek
(, to_char (to_date('2010-01-01','YYYY-MM-DD')-1 + rn, 'd.') As DayOfWeekNo
(, to_char (to_date('2010-01-01','YYYY-MM-DD')-1 + rn, 'Q') in the quarter
Years;
If you run this query, you will see my results.
Now my concern is that I don't want to hardcode so far. In above query I've hard-coded date ' 2010-01-01'.
Can use us somehow this variable?
Like this:
var start_date varchar2 (10)
exec: start_date: = ' 2010-01-01'
OVER the years LIKE)
SELECT to_date(:start_date,'YYYY-MM-DD') - level dt + 1
OF the double
CONNECT BY LEVEL<= (select="" round(="" sysdate-to_date(:start_date,'yyyy-mm-dd'))="" from="">=>)
Select
TO_CHAR (dt, 'yyyy') * 10000 + to_char (dt, 'mm') * 100 + to_char (dt, 'dd') as Date_ID
, dt as 'Date '.
to_char (dt, 'yyyy') As an
to_char(dt,'MM') as Month_Number
to_char(dt,'Month') in the month
to_char (dt, 'dd') As DayOfMonth
to_char(dt,'Day') As DayOfWeek
to_char(dt,'D') as DayOfWeekNo
to_char(dt,'Q') in the quarter
Years;for example to generate the date you common table expression and then use it in your application?
-
Using CASE in a dynamic sql query
Hello
I want to create a dynamic query using the CASE statement to replace the below 2 SQL statements:
+++++
Select "create or replace the synonym ' |" SYNONYM_NAME | 'for'. TABLE_OWNER |'. ' || TABLE_NAME | » @'|| SUBSTR (Db_link, 1, 30) |';' OF USER_SYNONYMS where db_link is not null;
Select "create or replace the synonym ' |" SYNONYM_NAME | 'for'. TABLE_OWNER |'. ' || TABLE_NAME |';' OF USER_SYNONYMS where the db_link is null;
+++++
While I have a unique select query which will give her create synonym statements for all with or without links db
Using the example of CASE statement as below:
SELECT
FirstName, LastName,
Salary, date of birth,
ABOUT sex
WHEN'm ' THEN 'male '.
WHEN 'F' THEN 'woman '.
END
Employees
I don't get how to write this CASE statement. Can someone guide me here?
Thank you
Malika"" The thread has been moved to Forum Home "database" SQL and PL/SQL+.
Nicolas.
-
Error using variable presentation of Expression SQL
Hi all
I get an error - '... Error to break information... "due to a variable used in a SQL Expression. It probably has something to do with a problem of data type. I have reduced the use of the presentation of the error variable.
I'll put a variable pres_mth_nme_to, presentation, from a prompt of dashboard. The line contains a month name.
I use the variable of presentation as part of a SQL Expression in a filter. Most of the SQL Expression is to use the
presentation in ONE variable and assign a value accordingly. For example:
Column: kind of month value
Operator: between
Value: * 10 *.
SQL expression: * case @{pres_mth_nme_to} {a few default} WHEN "NOV" THEN '10' WHEN 'DEC' THEN '11' WHEN 'JAN' THEN '12' WHEN 'FEB' THEN '13' WHEN... END *.
The name of the month is in character. If I was in this hard-coding, I don't get the error. For example:
CASE 'SEP' WHEN 'NOV' THEN '10' WHEN 'DEC '... END
It is something to do with the data type of the command prompt and to be used in the comparison. If I use a CAST, the problem persists.
CASE DROPS (@{pres_mth_nme_to} as char (3)) WHEN 'NOV' THEN... END
If I'm in the responses, the problem does not exist, I guess because of default values. If I'm on the dashboard, there is not, I guess because of the reception of the prompt value.
I don't know what I'm missing. Any suggestions?
Thank you.DJ,
If the formula presented by you is exactly true, I mean that it was not made to present as an example in the forum, you must include the variable presentation between apostrophes.
either your formula should look something like
Case ' @{pres_mth_nme_to} {a few default}' WHEN 'NOV' THEN '10' WHEN 'DEC' THEN '11' WHEN 'JAN' THEN '12' WHEN 'FEB' THEN '13' WHEN... ENDLet me know if it solved the problem...
-bifacts
http://www.obinotes.comPublished by: bifacts on October 25, 2010 13:50
-
Using a URL parameter in SQL query
Newbie question...
I've developed a dashboard application, and I use the enter SQL bind variables. Everything works well.
I want to do is to have a user access to a page via a URL with the parameters like this:
http://Atlas:7777 / pls/apex/f? p = 112:1:9191429456552868531:P1_ITM_CD_PASSED:JMINV
where P1_ITM_CD_PASSED is the parameter and the JMINV is the value.
So, I want the SQL to run using that:
Select *.
ITM
where itm_cd = ': P1_ITM_CD_PASSED'
I tried to test this on a page. Set up a report from the region, but it seems that the setting is not what makes the SQL. "No record found".
Is there a simple example that someone knows? Maybe I'm missing a point, process, calculation, etc. to be able to use the parameter?
Thanks in advanceHello
You have an extra ':' in the URL. Try this http://atlas:7777 / pls/apex/f? p = 112:1:9191429456552868531:P1_ITM_CD_PASSED:JMINV
The syntax of the URL of the APEX is described here http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/concept.htm#sthref165
CITY
-
How to use a table in a SQL query
Hello
I need to use a table of numbers as a VARRAY or table of associated Index so that I can do the following SQL code:
Select *.
of *.
where the array is null or id is in table
So that if the array is empty it returns all the records, and if the table is not empty, then it will return only the rows associated with the ID of the table.
Is this possible?
Kind regards
Nestor BoscanIn fact, solution I posted returns all rows when VARRAY is empty, not when it is null. To return all the rows when VARRAY is null, use:
SQL> select ename 2 from emp 3 where deptno in (select * from table(cast(sys.OdciNumberList(10,30) as sys.OdciNumberList))) 4 or sys.OdciNumberList(10,30) is null 5 / ENAME ---------- ALLEN WARD MARTIN BLAKE CLARK KING TURNER JAMES MILLER 9 rows selected. SQL> select ename 2 from emp 3 where deptno in (select * from table(cast(null as sys.OdciNumberList))) 4 or null is null 5 / ENAME ---------- SMITH ALLEN WARD JONES MARTIN BLAKE CLARK SCOTT KING TURNER ADAMS ENAME ---------- JAMES FORD MILLER 14 rows selected. SQL>
SY.
-
How to know the status of the process flow using a SQL query
Hello
I want to know the final status of a process flow after execution by using a sql query?
The available entries are:
-Item_Key
-Process_Flow_Package_Name
-Process_Flow_Name
I ran the process flow using a WF_Engine.LaunchProcess ()procedure, but I was not able to know the status of the process flow.
Is it possible to know the status of the process flow?
using a procedure or an sql query?
Thanks in advance,
SriGP.Once the process is completed, or not, you can see the status by calling:
UAS (your_OWF_shema) .wf_engine. ItemStatus()
-
Presentation using variable multiselect control
Hi all
I have a requirement.
I show a dashboard page that contains a direct SQL query and a command prompt. Guest must make a multiple selection control.
The SQL query is the following:
Select user_name, user_id table_name from where user_id = @{presentation_variable}.
The presentation variable will be declared in the guests, can I use it in the sql query.
But when we choose multiselect control, it does not show the area where we can declare a variable of presentation.
It allows us to declare the variable of presentation when we choose drop dwon control, in which a single value is selected.
Can someone guide me how I can use multiselect with direct SQL query, then several values can be passed to filter results.
Thank you.Hi rgksugan,
Variable presentation can't hold any more value, so we cannot define variable presentation (set variable) multi Select
How can I use multiple selection with direct SQL query,
You can't do that with multi select
Thank you
saichand.v -
Report with the sql query area
Hello
I have a region in relation to the sql query. There are two regions in the page. Top of page, the user enters data and after that second data enterd to see the region, which is related region
based on a sql query.
Now, when this page is opned, because the user has not entered anything, region report shows the message "no data found". Is it possible to remove this message or
may I have conditionally disaply region report IE if data are inserted only region report is dispalyed.
Thank youHello
You can use conditions for example "Exists (SQL query returns at least one row).
Kind regards
Jari -
'||' Operator in the sql query
Hi all
We use the "|" operator in the sql query. Under the terms of the performance, it's beneficial or not?
Please suggest me.
Select * from EMP
where (ename | empno) in ('xxx' | 'yyyy')
Thanks in advance...Select * from emp where (ename||empno) in ('xxx'||'yyyy')
What is the reason using the ' |'?
Similar results could be achieved by article AND only
Select * from emp where ename = 'xxx' and empno = 'yyyy'
-
Can I use session variables in data model BI publisher SQL query?
Hi Experts,
We apply security at the level of the BI Publisher 11g data.
In OBIEE we do so using session variables, so I wanted to just ask if we can use the same session variables in BI Publisher as well
That is, we can include a where clause in the SQL for the sample data as
Where ORG_ID = @{biServer.variables ['NQ_SESSION.]} {[INV_ORG']}
I would like to know your opinion on this.
PS: We implement security EBS r12 in BI Publisher.
Thank youRead this-> OBIEE 11 g: error: "[nQSError: 23006] the session variable, NQ_SESSION.» LAN_INT, has no definition of value. "When you create a SQL query using the session NQ_SESSION variable. LAN_INT in BI Publisher [ID 1511676.1]
Follow the ER - BUG: 13607750 -NEED TO be able TO SET up a SESSION IN OBIEE VARIABLE AND use it IN BI PUBLISHER
HTH,
SVS -
How can I use variable presentation logic SQL
Hi Experts,
How can I use variable SQL logical presentation. I need the exact syntax. Kindly help me to achieve this goal.
"Time". "" Date "between the Date of 2014 '-1-17 'and Date' ' 2014-2-16
Thanks in advance
Asim
It's done... We can use it in the logical query with the same syntax where we use in converting this filter as SQL...
-
problem with bind variables in the SQL query view object
Hi all
I use JDev 11.1.2.4.0.
I have a problem with bind variables in the SQL query view object.
This is my original SQL
SELECT sum(t.TIME) , t.legertype_id FROM LEDGER t WHERE t.nctuser_id = '20022' AND to_char(t.insertdate,'YYYYMMDD') in ('20130930','20130929') group by t.legertype_id
In my view .xml object query tab, I am writing this
SELECT sum(t.TIME) , t.legertype_id FROM LEDGER t WHERE t.nctuser_id = '20022' AND to_char(t.insertdate,'YYYYMMDD') in :dddd group by t.legertype_id
Davis here is a variable of Type liaison: String, updatable and necessary.
I try to deal with Davis as ('20130930 ', ' 20130929') hoping the view object, run as my original SQL.
But failed. The view object retrieves 0 line after that I run.
Why?
Thank you! ('2original SQL0130930', '20130929') ('20130930 ', ' 20130929')
A variable binding cannot be used as this is why you must use years table. Check decompilation binary ADF: using oracle.jbo.domain.Array with ViewCriteria to see a solution.
Timo
-
Correct way to use Bind variables when you use an interface to MS SQL Server
Hey,.
I have some difficulty to find how to use bind variables in a view, when you use an interface to MS SQL Server. For some reason when I use an ApplicationModule who has a library of MS SQL Server JDBC loaded and I try to click on OK when you change the following query:
SELECT kit_status, component_id
OF numbered_inv
WHERE trialname =: 1
I get an error stating that ' SQL Query Error Message incorrect syntax near ':'. JDeveloper is compatible with SQL server for bind variable as this query works fine if I replace the: 1 with a Word to say "Test test".
Thanks in advance
Edited by: NullCheck December 15, 2010 14:06Use positional JDBC Style Binding to bind variables
Try to use? Instead of:
As shown here:
http://www.Oracle.com/technetwork/developer-tools/jdev/multidatabaseapp-085183.html
Maybe you are looking for
-
Trying to activate XP home OEM after decommissioning of copy XP Pro illegal. Help!
I work on a PC the visitors, he had an illegal installation of XP Pro, but the pc it is installed on has a legal OEM product key stuck on it, why they installed I don't know, in any case.I have chagned it back to XP Home, using xp modeSwitch but had
-
A cable is not plugged into the network adapter 'connection to the Local network.
Hi, I am using a Dell Inspiron E1505... OS: Vista... 32 bit... IE 9... I still use dial-up "Conexant HDA D110 MDC V.92 Modem" connection connected to the internet without any problem... the problem is when I asked someone to download a program "MS Of
-
I can't run Windows Live\Messenger\la.
I get this error message "the application failed to start because its side-by-side configuration is incorrect." I uninstalled Windows Live, redownloaded and reinstalled and I still get the error message.
-
Column of username in the Task Manager disappeared after January 2010 automatic updates for XP
I noticed after the recent update of Microsoft "Windows Update", the username column deleted all the usernames on the process tab, exceptSystem idle process the which lists the SYSTEM. All other usernames are gone making 'show them processes from bo
-
Restored Windows 8.1 and I lost email storage folders - can someone advise
10 Windows installed ok and I was happy - but some 3rd party software programs not functioning properly - tried some reinstalls and messed up settings on their opinion correct - therefore restored to windows 8.1 and have lost all my email storage fil