[Locked] php sql code
hello
i need to write a query that displays the best 10 out of 15 fifteen results. 99% of the code is easy, but can't figute out to dislpay the 'best 10 out of 15' bit.
any ideas?
in our fishing club, the club champion is the one with the most total points.
the total points is the made up of their best 10 scores over 15 matches.
i'm exploring the option at the moment of do a sort on all 15 results in desc order.
i'll put all these values into an array using push_array.
i'll then run a loop on the first 10 array values, which should be the highest 10, and add these to a totalpointsamount variable as i go.
i'll then display this variable, which should be what i'm looking for.
this does seem a long roundabout way of doing this though. i'm sure there must be an sql command that would do the job on query though.
Similar Messages
-
Pagination of output php code with sql code
if one program of php including sql query
it seems to output wrong .(means some data will be calculated sum)
if php code output all data in one page.pagination
it seems to output right(means some data will be calculated sum)
if there has column of company including two companies of A and B.
and if each page output 3 lines while A company has 4 lines in sql query,so
the last line of A company will output in second page,
i want to calculate A company including 4 lines sum
how to calculate sum of company of A in second page.
i think it will be a good interesting question of php code with sql code.
who can solution thus question ?
thanks !Hi,
for Example:
SELECT sum(quantity * price)
FROM orders
WHERE COMPANY = 'A';
This will give you the total amount for company A.
But remember that your example table will give no output, since you have no price column. So you must decide, what which sum to calculate.
A sum only calculated over the quantity makes IMHO no sense, because there are apples and bananas ...
Greetings from Hamburg
Thorsten Körner -
Performance tuning in PL/SQL code
Hi,
I am working on already existing PL/SQL code which is written by someone else on validation and conversion of data from a temporary table to base table. It usually has 3.5 million rows. and the procedure takes arount 2.5 - 3 hrs to complete.
Can I enhance the PL/SQL code for better performance ? or, is this OK to take so long to process these many rows?
Thanks!
YoginiCan I enhance the PL/SQL code for better performance ? Probably you can enhance it.
or, is this OK to take so long to process these many rows? It should take a few minutes, not several hours.
But please provide some more details like your database version etc.
I suggest to TRACE the session that executes the PL/SQL code, with WAIT events, so you'll see where and on what time is spent, you'll identify your 'problem statements very quickly' (after you or your DBA have TKPROF'ed the trace file).
SQL> alter session set events '10046 trace name context forever, level 12';
SQL> execute your PL/SQL code here
SQL> exitWill give you a .trc file in your udump directory on the server.
http://www.oracle-base.com/articles/10g/SQLTrace10046TrcsessAndTkprof10g.php
Also this informative thread can give you more ideas:
HOW TO: Post a SQL statement tuning request - template posting
as well as doing a search on 10046 at AskTom, http://asktom.oracle.com will give you more examples.
and reading Oracle's Performance Tuning Guide: http://www.oracle.com/pls/db102/to_toc?pathname=server.102%2Fb14211%2Ftoc.htm&remark=portal+%28Getting+Started%29 -
PHP/mySQL code help please
Hi all,
Thanks to David Powers fab tutorial I am now well on my way to competeing my first dynamique website using PHP/mySQL, (thanks David ), however I am stuck on one particular area....can anyone please help?
I know that the mySQL database uses the format YYYY/MM/DD for dates, and that is fine. I've sorted out how to display in a more regular format (eg. 1st September 2011) for my application, but I am stuck on how to convert a more regular formatted date entered by the site user into the mySQL format.
Ideally I would like for the users entry or say either 1/9/11 or 1-9-11 (or something along those lines, to be recognised and displayed on the entry form, but to have a backend function that converts the data to mySQL format. I seem to be reading plenty of forum posts which say this can be done, but unfortunately I can't quite seem to fathom how, or where the code should sit. Would someone mind taking a look at my code page to actually identify what I need to insert, and equally as importantly...where!!!
Along these lines...is it possible to have a mini-calendar date picker that could be embedded next to the date entry field to ensure that a valid date is entered and in the correct format? Where could this be sourced?
Thanks in advance of some much needed help
MarkThis is becoming really frustrating for me (so god knows how I am to you!!!!), but I usually pick things up so fast and yet this whole PHP/SQL thing is eluding me!!
I can see (I think) how the code would work, but am struggling to see where it fits into place with my own Dreamweaver 'Update Record' code, as follows. I have spent a couple of days trawling through PHP.net and various other sites and forums before bringing my stupidity to the public domain, but I just can't seem to crack it.
This one last time then i'll leave you in peace??????
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE gig_guide SET `date`=%s, town=%s, venue=%s, private_or_public=%s, start_time=%s WHERE `index`=%s",
GetSQLValueString($_POST['date'], "date"),
GetSQLValueString($_POST['town'], "text"),
GetSQLValueString($_POST['venue'], "text"),
GetSQLValueString($_POST['type'], "text"),
GetSQLValueString($_POST['start_time'], "text"),
GetSQLValueString($_POST['index'], "int"));
mysql_select_db($database_online, $online);
$Result1 = mysql_query($updateSQL, $online) or die(mysql_error());
$updateGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $updateGoTo));
$colname_updatePost = "-1";
if (isset($_GET['index'])) {
$colname_updatePost = $_GET['index']; -
PHP exception code in FaultEvent?
Hi-
The PHP exception code doesn't seem to get mapped into a
FaultEvent...only the exception *message* seems to be available in
a FaultEvent. I was hoping to use an exception code in a FaultEvent
to drive logic in Flex (i.e if code == 100, then x, if code == 200,
then y, etc).
Am I correct in assuming that the PHP exception code does not
get mapped into a FaultEvent? If so, how are other people using
FaultEvents to drive logic decisions in Flex?
One idea I had was to use a serialized object as the PHP
exception message, and unserialize the resulting
FaultEvent->faultDetail message in Flex. This method works OK,
but I was hoping for a more elegant solution.
Thanks!
GregAdobe Newsbot hopes that the following resources helps you.
NewsBot is experimental and any feedback (reply to this post) on
its utility will be appreciated:
Flex 3 - About data access:
Flex data access components are based on a service-oriented
architecture .... objects, such as ColdFusion components (CFCs),
Java objects, PHP objects,
Link:
http://livedocs.adobe.com/flex/3/html/data_intro_2.html
AMF3 PHP Server Objects to Flex Client Object Relational
Mapping:
Apr 16, 2008 ... fig1.png Flex Based Rich Internet
Applications (RIAs) by definition typically require server access
to provide the information resources and
Link:
http://www.insideria.com/2008/04/amf3-php-server-objects-to-fle.html
Flex 3 - Using HTTPService components:
You can use a Flex HTTPService component in conjunction with
PHP and a SQL ... The resultFormat property of the HTTPService
component is set to object
Link:
http://livedocs.adobe.com/flex/3/html/data_access_2.html
Adobe - Developer Center : Using Flex 2 RemoteObject and
SabreAMF:
After SabreAMF maps the PHP objects in the return array to
com.renaun.samples.vo.UserVO , the application on the Flex side
deserializes this return array
Link:
http://www.adobe.com/devnet/flex/articles/remoteobject_sabreamf_05.html
Flex 3 - About working with data in Flex Builder:
Flex Builder provides a set of data wizards that
automatically generate database applications that use PHP, J2EE, or
ASP.NET.
Link:
http://livedocs.adobe.com/flex/3/html/data_2.html
Disclaimer: This response is generated automatically by the
Adobe NewsBot based on Adobe
Community
Engine. -
Hi Experts,
My IPS has been reporting "PHP-Remote Code Execution" attack on one of our webserver for a while now. Each time the attackers IP address keeps changing. I created an object-group and access-list to deny the object-group on my firewall and i keep adding the attacker's IPs to the group, however i keep recieving new "PHP-Remote Code Execution" attacks. My IPS is in promiscous mode and i have auto signature update enabled.
IPS has reported "packet denied by global correlation in some case. Like i said, IPS is in promiscous mode. Signature: 2271/0 and CVE-2012-1823
Apart from making sure the webservers have the right security patches, What else should i be doing?. Do not want to miss anything out?cactus wrote:mhakali. I applaud your attention to security.
However, it is generally not well received to post the same thing in multiple categories..
Yes. Please do not cross-post: http://bbs.archlinux.org/viewtopic.php?p=205922
Use the above thread for discussion.
Locking. -
Got the following reply from db-kernel: SQL-Code :-903
Dear Experts,
I am having a problem running MaxDB Data backup on Netbackup.... Please se log below and suggest.
2011-04-11 13:30:38
Using environment variable 'TEMP' with value 'C:\Windows\TEMP' as directory for temporary files and pipes.
Using connection to Backint for MaxDB Interface.
2011-04-11 13:30:39
Checking existence and configuration of Backint for MaxDB.
Using configuration variable 'BSI_ENV' = 'C:\Netbackup_Script\bsi_backint_daily.env' as path of the configuration file of Backint for MaxDB.
Setting environment variable 'BSI_ENV' for the path of the configuration file of Backint for MaxDB to configuration value 'C:\Netbackup_Script\bsi_backint_daily.env'.
Reading the Backint for MaxDB configuration file 'C:\Netbackup_Script\bsi_backint_daily.env'.
Found keyword 'BACKINT' with value 'D:\sapdb\KGP\db\bin\backint.exe'.
Found keyword 'INPUT' with value 'E:\sapdb\data\wrk\KGP\backint.input'.
Found keyword 'OUTPUT' with value 'E:\sapdb\data\wrk\KGP\backint.output'.
Found keyword 'ERROROUTPUT' with value 'E:\sapdb\data\wrk\KGP\backint.error'.
Found keyword 'PARAMETERFILE' with value 'C:\Netbackup_Script\backint_parameter_daily.txt'.
Finished reading of the Backint for MaxDB configuration file.
Using 'D:\sapdb\KGP\db\bin\backint.exe' as Backint for MaxDB program.
Using 'E:\sapdb\data\wrk\KGP\backint.input' as input file for Backint for MaxDB.
Using 'E:\sapdb\data\wrk\KGP\backint.output' as output file for Backint for MaxDB.
Using 'E:\sapdb\data\wrk\KGP\backint.error' as error output file for Backint for MaxDB.
Using 'C:\Netbackup_Script\backint_parameter_daily.txt' as parameter file for Backint for MaxDB.
Using '300' seconds as timeout for Backint for MaxDB in the case of success.
Using '300' seconds as timeout for Backint for MaxDB in the case of failure.
Using 'E:\sapdb\data\wrk\KGP\dbm.knl' as backup history of a database to migrate.
Using 'E:\sapdb\data\wrk\KGP\dbm.ebf' as external backup history of a database to migrate.
Checking availability of backups using backint's inquire function.
Check passed successful.
2011-04-11 13:30:39
Checking medium.
Check passed successfully.
2011-04-11 13:30:39
Preparing backup.
The environment variable 'BSI_ENV' has already the value 'C:\Netbackup_Script\bsi_backint_daily.env'.
Setting environment variable 'BI_CALLER' to value 'DBMSRV'.
Setting environment variable 'BI_REQUEST' to value 'NEW'.
Setting environment variable 'BI_BACKUP' to value 'FULL'.
Constructed Backint for MaxDB call 'D:\sapdb\KGP\db\bin\backint.exe -u KGP -f backup -t file -p C:\Netbackup_Script\backint_parameter_daily.txt -i E:\sapdb\data\wrk\KGP\backint.input -c'.
Created temporary file 'E:\sapdb\data\wrk\KGP\backint.output' as output for Backint for MaxDB.
Created temporary file 'E:\sapdb\data\wrk\KGP\backint.error' as error output for Backint for MaxDB.
Writing 'D:\sapdb\pipe2 #PIPE' to the input file.
Prepare passed successfully.
2011-04-11 13:30:39
Starting database action for the backup.
Requesting 'SAVE DATA QUICK TO 'D:\sapdb\pipe2' PIPE BLOCKSIZE 8 NO CHECKPOINT MEDIANAME 'BACKDBFULL'' from db-kernel.The database is working on the request.
2011-04-11 13:30:39
Waiting until database has prepared the backup.
Asking for state of database.
2011-04-11 13:30:39 Database is still preparing the backup.
Waiting 1 second ... Done.
Asking for state of database.
2011-04-11 13:30:41 Database has finished preparation of the backup.
The database has prepared the backup successfully.
2011-04-11 13:30:41
Starting Backint for MaxDB.
Starting Backint for MaxDB process 'D:\sapdb\KGP\db\bin\backint.exe -u KGP -f backup -t file -p C:\Netbackup_Script\backint_parameter_daily.txt -i E:\sapdb\data\wrk\KGP\backint.input -c >>E:\sapdb\data\wrk\KGP\backint.output 2>>E:\sapdb\data\wrk\KGP\backint.error'.
Process was started successfully.
Backint for MaxDB has been started successfully.
2011-04-11 13:30:41
Waiting for end of the backup operation.
2011-04-11 13:30:41 The backup tool is running.
2011-04-11 13:30:41 The database is working on the request.
2011-04-11 13:30:43 The database has finished work on the request.
Receiving a reply from the database kernel.
Got the following reply from db-kernel:
SQL-Code :-903
2011-04-11 13:30:43 The backup tool is running.
2011-04-11 13:30:44 The backup tool process has finished work with return code 2.
The backup operation has ended.
2011-04-11 13:30:44
Filling reply buffer.
Have encountered error -24920:
The backup tool failed with 2 as sum of exit codes. The database request failed with error -903.
Constructed the following reply:
ERR
-24920,ERR_BACKUPOP: backup operation was unsuccessful
The backup tool failed with 2 as sum of exit codes. The database request failed with error -903.
Reply buffer filled.
2011-04-11 13:30:44
Cleaning up.
Copying output of Backint for MaxDB to this file.
Begin of output of Backint for MaxDB (E:\sapdb\data\wrk\KGP\backint.output)----
Reading parameter file C:\Netbackup_Script\backint_parameter_daily.txt.
Using D:\sapdb\KGP\db\bin\backint.exe as Backint for Oracle.
Using C:\Netbackup_Script\nt_initKGPdaily.utl as parameterfile of Backint for Oracle.
Using E:\sapdb\data\wrk\KGP\backinthistory.log as history file.
Using E:\sapdb\data\wrk\KGP\backintoracle.in as input of Backint for Oracle.
Using E:\sapdb\data\wrk\KGP\backintoracle.out as output of Backint for Oracle.
Using E:\sapdb\data\wrk\KGP\backintoracle.err as error output of Backint for Oracle.
Using staging area D:\sapdb\Stage1 with a size of 2147483648 bytes.
Reading input file E:\sapdb\data\wrk\KGP\backint.input.
Backing up pipe D:\sapdb\pipe2.
Found 1 entry in the input file.
Starting the backup.
Starting pipe2file program(s).
Waiting for creation of temporary files.
1 temporary file is available for backup.
Calling Backint for Oracle at 2011-04-11 13:30:43.
Calling 'D:\sapdb\KGP\db\bin\backint.exe -u KGP -f backup -t file -p C:\Netbackup_Script\nt_initKGPdaily.utl -i E:\sapdb\data\wrk\KGP\backintoracle.in -c' .
Backint for Oracle ended at 2011-04-11 13:30:43 with return code 2.
Backint for Oracle output: Reading parameter file C:\Netbackup_Script\nt_initKGPdaily.utl.
Backint for Oracle output: Using E:\sapdb\data\wrk\KGP\backint4oracle.in as input of Backint for Oracle.
Backint for Oracle output: Using E:\sapdb\data\wrk\KGP\backint4oracle.out as output of Backint for Oracle.
Backint for Oracle output: Using E:\sapdb\data\wrk\KGP\backint4oracle.err as error output of Backint for Oracle.
Backint for Oracle output: Using staging area D:\sapdb\Stage1 with a size of 2147483648 bytes.
Backint for Oracle output: Using E:\sapdb\data\wrk\KGP\backinthistory.log as history file.
Backint for Oracle output: Using D:\sapdb\KGP\db\bin\backint.exe as Backint for Oracle.
Backint for Oracle output:
Backint for Oracle output: Reading input file E:\sapdb\data\wrk\KGP\backintoracle.in.
Backint for Oracle output: Backing up file D:\sapdb\Stage1.0.
Backint for Oracle output: Found 1 entry in the input file.
Backint for Oracle output:
Backint for Oracle output: Starting the backup.
Backint for Oracle output: Starting pipe2file program(s).
Backint for Oracle output:
Backint for Oracle output: Calling Backint for Oracle at 2011-04-11 13:30:43.
Backint for Oracle output: Calling 'D:\sapdb\KGP\db\bin\backint.exe -u KGP -f backup -t file -i E:\sapdb\data\wrk\KGP\backint4oracle.in -c' .
Backint for Oracle output: Backint for Oracle ended at 2011-04-11 13:30:43 with return code 2.
Backint for Oracle output: Backint for Oracle output: Reading parameter file .
Backint for Oracle output: Backint for Oracle output:
Backint for Oracle output: Backint for Oracle output:
Backint for Oracle output: Backint for Oracle error output: No staging area is defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output: The path of Backint for Oracle is not defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output: The name of the history file is not defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output: The name of the input file of Backint for Oracle is not defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output: The name of the output file of Backint for Oracle is not defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output: The name of the error output file of Backint for Oracle is not defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output:
Backint for Oracle output:
Backint for Oracle output: Finished the backup unsuccessfully.
Backint for Oracle output:
Backint for Oracle output: #ERROR D:\sapdb\Stage1.0
Backint for Oracle output:
Backint for Oracle error output: Backint for Oracle was unsuccessful.
Backint for Oracle error output:
Finished the backup unsuccessfully.
#ERROR D:\sapdb\pipe2
End of output of Backint for MaxDB (E:\sapdb\data\wrk\KGP\backint.output)----
Removed Backint for MaxDB's temporary output file 'E:\sapdb\data\wrk\KGP\backint.output'.
Copying error output of Backint for MaxDB to this file.
Begin of error output of Backint for MaxDB (E:\sapdb\data\wrk\KGP\backint.error)----
Backint for Oracle was unsuccessful.
End of error output of Backint for MaxDB (E:\sapdb\data\wrk\KGP\backint.error)----
Removed Backint for MaxDB's temporary error output file 'E:\sapdb\data\wrk\KGP\backint.error'.
Removed the Backint for MaxDB input file 'E:\sapdb\data\wrk\KGP\backint.input'.
Have finished clean up successfully.> Requesting 'SAVE DATA QUICK TO 'D:\sapdb\pipe2' PIPE BLOCKSIZE 8 NO CHECKPOINT MEDIANAME 'BACKDBFULL'' from db-kernel.The database is working on the request.
This seems to be your problem, the pipe is wrongly defined. On Windows it looks like
\\.\pipe1
see
http://msdn.microsoft.com/en-us/library/aa365783.aspx
Markus -
PL/SQL code written in db or in application...????
Hi ,
Which is the best...at performance , maintability... e.t.c.???
To write PL/SQL as validation process of data values going to be inserted in db:
1) as db trigger (before insert or update row-level trigger)
2) in application level - in Forms10g...
This PL/SQL code compares some pairs of data values only.... there DML statement....
Both db server and App server are considered to be or in the same machine or in two machines very close to each other...
Note: i use Db10g .
Thanks...
SimIt is all about moving parts. How many there are. Where they are located.
The less moving parts, the less the complexity, the bugs - and the better the performance (less wheels to turn to crunch data), the easier the maintenance and the better the flexibility.
Part of this is having the moving parts close to the data. Kind of obvious - what is faster? Shipping data from the db engine to a front-end application via a app server and web server? Or shipping the data from the db (SQL) engine to a PL/SQL process running as part and parcel of db instance? IPC is significantly faster than TCP/IP.
Having the moving parts close to the data also means that it can scale with the data. Oracle is good at scalability. It is designed at its very core to be scalable. Partitions to reduce I/O. Shared Server to reduce o/s resource footprint per client session. Shared pool to re-use SQL. DB buffer to cache data. RAC to run multiple db instances for a single physical database. Etc. Etc.
With the application moving parts being close to the data, it inherits this scalability. You can "multi-thread" application code using table pipelines. You have access to forking application code using background processes (DBMS_JOB and DBMS_SCHEDULER). You have bulk processing in order to transfer more data per SQL engine call, between the buffer cache and your application, and thus also reduce expensive context switching.
This list goes on and on.
All this is summarised into the following rules.
Rule 1. Do it in SQL.
Rule 2. Only when SQL cannot do it, use PL/SQL. (e.g. SQL is not suited for managing and controlling process flow - PL/SQL is)
Rule 3. Only when PL/SQL cannot do it, use <insert-language-here> (e.g. PL/SQL cannot render a Windows grid on the client - but Delphi/C#//Java can).
Also keep in mind that in the modern client-server paradigm we deal with a web architecture. Which means the client is a web browser. And this means that PL/SQL can pass the data (HTML) required by the client (web browser) to render the User Interface.
Have a look at APEX (Oracle's Application Express) for how this works. http://apex.oracle.com
All you need to develop web applications is APEX (a PL/SQL product suite in the database) and a web browser. Kickass stuff... :-) -
DECLARE
SQ VARCHAR2(100);
BEGIN
SQ := 'SELECT * FROM EMP WHERE EMPNO=7788';
RETURN SQ;
END
THE ABOVE PL/SQL CODE WORKING FINE
BUT I NEED CONDITION BASED ON ENAME
SQ:='SELECT * FROM EMP WHERE ENAME=''SCOTT'';
IT IS GIVEING ERROR
WHAT TO DO?Hi,
You're missing the final quote - you have the quotes for SCOTT but not the one to close the SQ string:
DECLARE
SQ VARCHAR2(100);
BEGIN
SQ := 'SELECT * FROM EMP WHERE EMPNO=''SCOTT''';
RETURN SQ;
ENDAndy -
How to 100% Protect PL/SQL Code By Wrapped in Oracle Database 10g R2
Hello,
Is Possible to 100% Protect PL/SQL Code By Wrapped in Oracle 10g R2 ?
If it is not possible by wrap in oracle 10g R2,
Please, let me suggest, how i will be able to 100% protect PL/SQL code in Oracle Database 10g R2.
Because, I have lot of functions, procedures & package's in my project.
Which is running in field filed.
So, i have needed to protect 100%.
Also, will i convert to al functions, procedures & package's to .pll file ?
And .pll file to .plx file?
Is it possible to convert .plx file to .pll file ?
Please, let know any better solutions in this case....
Regards
MehediHello,
No, wrapping is not a 100% secure method. It could prevent your code from amateurs, but not from professional hackers. Look at the article http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/wrap.htm#BEHGBJAA
It says: "•Wrapping is not a secure method for hiding passwords or table names.
Wrapping a PL/SQL unit prevents most users from examining the source code, but might not stop all of them."
Edited by: apiminov on 03.12.2012 3:23
Edited by: apiminov on 03.12.2012 3:24 -
How to reference LEVEL in a TREE's SQL code
Is it possible to somehow reference LEVEL in a tree's sql code so that you can use a decode statement to selectively create links on specific levels only i.e. NOT on the root level?
e.g.
select "CHILD_ID" id,
"PARENT_ID" pid,
"NAME" name,
decode( LEVEL, 1, null,'f?p=' || :APP_ID || ':43:' || :APP_SESSION || '::::P43_CHILD_ID:' || CHILD_ID) link,
null a1,
null a2
from TREETABLE
order by name
one solution I've implemented is to create a DB function e.g.
create or replace function get_tree_level(v_child_id number) return number
is
v_level number(2);
begin
select level
into v_level
from TREETABLE
where child_id=v_child_id
start with child_id=1
connect by prior child_id= parent_id;
return v_level;
end;
and then use
decode( get_tree_level(child_id) 1, null,'f?p=' || :APP_ID || ':43:' || :APP_SESSION || '::::P43_CHILD_ID:' || CHILD_ID) link,
but this is too slow as I have quite a few records in the tree and takes too long to render
regards
Paul POK I found a workaround after reading
How to add URL to tree
The view my tree is build on is constructed out of 3 unions and 4 "selects" ( the first select creates the ROOT NODE where "1" is also used as a hard coded foreign key (Parent_id), in the company table.)
I just added a new column called tree_level to the query which is hard coded wrt its level on the hierarchy.
e.g.
CREATE OR REPLACE FORCE VIEW COMCONSTUTREE ("CHILD_ID", "PARENT_ID", "NAME","TREE_LEVEL") AS
select 1 as child_id,to_number(null) as parent_id ,'Company' as name,*1 as tree_level* from dual
UNION
select COM_ID, 1, COM_NAME,2
from company
UNION
select CON_ID,CON_COMPANY_ID, substr(con_name,instr(con_name,' ')+1) ||', '||substr(con_name,1,instr(con_name,' ')-1),3
from contact
UNION
select STU_ID,STU_CONTACT_ID, STU_LAST_NAME||', '||STU_FIRST_NAME ,4
from student;
the tree code now becomes
select "CHILD_ID" id,
"PARENT_ID" pid,
"NAME" name,
decode( tree_level,1, null,'f?p=' || :APP_ID || ':43:' || :APP_SESSION || ':TREE:::P43_CHILD_ID:' ||CHILD_ID) link,
null a1,
null a2
from COMCONSTUTREE"
order by name -
PL/SQL Code not working without debug statements
Hi Guys,
I have a pl/sql code in a procedure, logic iterates through almost 40K records, conditional delete and update.
When I execute this code, I dont see the deletes and updates happening, though procedure executes for 8 minutes and exits wihtout any error, execption.
In same procedure when I write some debug statements like dbms_output, then everything seems to be working fine.
I know this scenario happens in Oracle Forms, wehre we use SYNCHRONIZE.
But this is plain pl/sql procedure.
any thoughts on this?
Av.COMMIT ?
Aside from that, no idea what your procedure looks like, what it does, what version of Oracle you are using, how you are determining "I dont see the deletes and updates happening". etc...
You'd need to provide a slew of information for anyone to give you any meaningful help.
I can only assure you that DBMS_OUTPUT doesn't do magic :) -
Can I have a PL/SQL code for LOV
Hi,
I apologize for this dumb question. I have been so out of touch with dev (almost 8 years). Plus new to pl/sql.
I am creating a status report application. On the dashboard, I currently have some metrics (horizontal charts). I wanted to expose these metrics based on filter.
I had created 2 filters. The first one will identify the type (Week, Month, Qtr or Year) and the 2nd filter would be based on the type. For e.g. if I select Month as type, the 2nd filter should show May-12, April-12 etc. Once I select the 2nd filter, I should use them to show the appropriate metrics. The metric that I currently have would show all the projects that users have worked on during the week/month/qtr or year (depending on the 1st and 2nd filter).
On the dashboard region, I added a condition to check if the value for both 1st and 2nd filter is not null. This allows me to show the dashboard only if the 2 filters have been selected.
For the 2nd filter, I need to write a PL/SQL code to show the LOV.
I am assuming that the pl/sql would return a SQL query. The SQL query will be based on week, month etc. Is that right?
Thanks
balaji
Edited by: user644868 on May 17, 2012 11:29 AMrbalaji2026 wrote:
For the 2nd filter, I need to write a PL/SQL code to show the LOV. Doesn't appear necessary. With filter 2 cascading from filter 1, why not:
select
/* Week query */
from
where
and :p1_filter_1 = 'WEEK'
union all
select
/* Month query */
from
where
and :p1_filter_1 = 'MONTH'
union all
select
/* Quarter query */
from
where
and :p1_filter_1 = 'QUARTER'
union all
select
/* Year query */
from
where
and :p1_filter_1 = 'YEAR' -
Multiple SQL queries in additional PL/SQL code in Report
Hello gurus,
I have a form in my portal populated some searching parameters and these parameters inserted into some temporary tables such as name_temp, addr_temp. And then I have a report that run based on these parameters, I have added additional PL/SQL code in the report at the time after the header was displayed. The code is as follows:
declare
checkname varchar2(40);
checkaddr varchar2(100);
begin
select emp.name into checkname from emp
where name = (select name from name_temp);
select personnel.addr into checkaddr from personnel
where addr = (select address from addr_temp);
end;
The problem I have is always the first SQL statement was executed, but not the second one, nor the third one. Does PL/SQL only supports one SQL statement per call? Please help. Is there a better way to handle this case?
Thanks.
VinceHello gurus,
I have a form in my portal populated some searching parameters and these parameters inserted into some temporary tables such as name_temp, addr_temp. And then I have a report that run based on these parameters, I have added additional PL/SQL code in the report at the time after the header was displayed. The code is as follows:
declare
checkname varchar2(40);
checkaddr varchar2(100);
begin
select emp.name into checkname from emp
where name = (select name from name_temp);
select personnel.addr into checkaddr from personnel
where addr = (select address from addr_temp);
end;
The problem I have is always the first SQL statement was executed, but not the second one, nor the third one. Does PL/SQL only supports one SQL statement per call? Please help. Is there a better way to handle this case?
Thanks.
Vince -
How to change the profile value in the pl/sql code without making change in the database
How to change the profile value in the pl/sql code without making change in the database.
I have program ,where if the profiles 'printer and nunber of copies ' are set at the user level, by default when the report completes the O/p will be sent to the printer mentioned in the set-up. but what user wants is
if these Profiles are set for the user running this program automatic printing should not be done.
Maybe you are looking for
-
Multiple sites on CRM-ISA web proxy IIS
Hello, We're upgrading to CRM v6 (2007), with Internet Sales / Web Channel B2B in scope. As part of the system landscape, we have a Windows server running IIS acting as a web proxy. Now, the question is, can we share this web proxy so that it works f
-
How to avoid the port in portal
Hi Gurus, Please help me on this we have implementd SSL in our portal EP7.0 my question is i needs to avoid the port No. now and give normal url now the url is https://<host>.<company>:50001/irj/portal now want to change it to https://host.company/ir
-
Hi all, Can anyone help me figure out how to do this kind of bass slide? I uploaded a small .wav file. I suspect you get a particular synth bass and do something with the pitch bend on the MIDI controller? If anyone knows of a particular present, say
-
ORA-12545:connect failed because target host or object not exist
Dear DBA's I am getting this error message when i want to connect oracle by using internet explorer browser. ORA-12545:connect failed because target host or object not exist I already started services: oracleservicesSID,OracleOraDb10g_home1TSNListene
-
File that stores custom T9 in Nokia 6120c
Hey Everyone, I have a file explorer and I need to know what file (.dat) stores my custom predictive text entries in my Nokia 6120c phone so I can delete them. A phone restore, both through the proper user interface and a *#7370 reset does not work.