Help in SQL syntax
SELECT MARAMATNR MARAPRDHA MARAMEINS MARDLGORT
MARDLABST MARDINSME
INTO CORRESPONDING FIELDS OF TABLE ITAB_TEM_NORMAL
FROM MARA INNER JOIN MARC ON MARCMATNR = MARAMATNR
INNER JOIN MARD ON MARDMATNR = MARAMATNR
INNER JOIN MSEG ON MSEGMATNR = MSEGMATNR
INNER JOIN MKPF ON MKPFMBLNR = MSEGMBLNR
WHERE MARA~MATNR IN Z_MATNR
AND MARASPART IN Z_SPART AND MARAMATKL IN Z_MATKL
AND MARAMTART IN Z_MTART AND MARAPRDHA IN Z_PRDHA
AND MARCEKGRP IN Z_EKGRP AND MARCDISPO IN Z_DISPO
AND MARD~LGORT IN STR_LOC1
AND MKPF~BUDAT IN SHIP_D
AND NOT MARD~LGORT IN ('L001','L002','L003','V001','V002','V003')
AND ( MSEG~BWART IN ('901','902','101','102','106','105') AND
MSEGLGORT = 'L002') OR ( MSEGBWART IN ('311','312') AND
( MSEGLGORT = 'L001' OR MSEGUMLGO = 'L001')).
ENDFORM.
what's wrong with above coding? it said "(" has no closing ")".
thx
It seems you have an error:
INNER JOIN MSEG ON MSEGMATNR = MSEGMATNR
haven't you ment
INNER JOIN MSEG ON MSEGMATNR = MARAMATNR
Regarding syntax error perhaps you should put a space between two closing brackets et the end of your statement...
Similar Messages
-
Good day
someone help me when i replace( :1 to &var , nn:='1,2' to null ) and run sql when type 1,2 the enter its work . the problem i'm not want to used &var i want to assiagn value to nn in block and nn pass its value to :1 whendo that it say
note dep_id is number
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
declare
type m is ref cursor ;
cur m;
txt varchar2(500);
mm number;
nn varchar2(20);
begin
nn:='1,2';
txt:=q'[select count(*) from employees where dep_id in(*:1*))]';
execute immediate txt into mm using nn ;
dbms_output.put_line('nn= '||mm);
end;
/For your requirement the simplest way is
SQL> set serverout on
SQL> DECLARE
2 type m is ref cursor;
3 cur m;
4 txt varchar2(500);
5 mm number;
6 nn varchar2(20);
7 BEGIN
8 nn := '20,30';
9 txt := 'select count(*) from emp where deptno in ('||nn||')';
10 execute immediate txt
11 into mm;
12 --using nn;
13 dbms_output.put_line('nn= ' || mm);
14 END;
15 /
nn= 11
PL/SQL procedure successfully completed.
SQL> However, If you want to implement varying IN list then totally different story altogether. Search AskTom for some example. -
Need help with sql syntax....
The table "tblL" has columns a1 and a2. When the "where" clause is commented the query out runs fine. When "where" is uncommented I get a syntax error. Any help appreciated.
select a1, a2 from
select top 5 * from tblL
) as T
-- wbere (T.a1 = T.a2) -- when uncommented get syntax error
-- wbere (a1 = a2) -- when uncommented get syntax error too
Error:
"Incorrect syntax near 'wbere'...."
TIA,
edm2"Incorrect syntax near 'wbere'...."
The keyword is wHere, not wBere, you typed a B instead of H
Olaf Helper
[ Blog] [ Xing] [ MVP] -
Hello,
I've got a form that returns results from a MySQL table
[tasks] based on three parameters:
task_resource
begin_date
end_date
Here is my code in the record set dialog box:
SELECT *
FROM tasks
WHERE (task_resource = varName) AND (begin_date BETWEEN
varBeginDate AND varEndDate OR end_date BETWEEN varBeginDate AND
varEndDate)
ORDER BY tasks.begin_date
I thought it was working fine until I ran into a problem. The
SQL statement doesn't work if I want to see only those tasks begun
and completed on the same day. For example, I entered begin_date
02/22/08 to end_date 02/22/08 because I only want to see tasks
started AND completed on that date. But my SQL is set up (with the
"OR") so that it's returning tasks with a begin_date of 02/21/08
and end_date of 02/22/08.
How can I correct my SQL? Not sure how to do this if I take
out the OR condition.
Thank you.>> SELECT *
> FROM tasks
> WHERE (task_resource = varName) AND (begin_date BETWEEN
varBeginDate AND
> varEndDate OR end_date BETWEEN varBeginDate AND
varEndDate)
> ORDER BY tasks.begin_date
SELECT *
FROM tasks
WHERE (task_resource = varName) AND ((begin_date BETWEEN
varBeginDate AND
varEndDate) OR (end_date BETWEEN varBeginDate AND
varEndDate))
ORDER BY tasks.begin_date -
SQL Developer 1.1.0.21: Issues with Data Grid and SQL syntax checking
In this new release of SQL Dev, when I execute a SQL in the SQL Worksheet and click in the Data Grid in the Results tab and try to navigate within a record using arrow keys, the grid cell enters into edit mode by default and so I cannot use the Left or Right arrow keys to navigate the grid. I am forced to use tab key to navigate. This is counter intuitive in my opinion.
Is there any option to change this behavior?
Another issue that I have come across is with SQL syntax checking. In some cases, when I press F9 to execute a SQL, it shows the SQL as executed i.e. shows something like 0.0134 seconds in the toolbar and no results displayed. In reality, the SQL had some syntax error which were NOT reported. This can be frustrating since now I have to fall back to SQL*Plus or TOAD just for syntax check.
I like the fact that SQLDev highlights the current SQL but it would be more useful if it just indicated the first line of the current sql instead of highlighting the whole sql.
Manish"In this new release of SQL Dev, when I execute a SQL in the SQL Worksheet and click in the Data Grid in the Results tab and try to navigate within a record using arrow keys, the grid cell enters into edit mode by default and so I cannot use the Left or Right arrow keys to navigate the grid. I am forced to use tab key to navigate. This is counter intuitive in my opinion."
In the "Results" tab, Click Ctrl & Tab keys (at the same time) or with mouse click on any cell other than the first column (a sequence or rownum), you will be able to navigate using the arrow keys.
"Another issue that I have come across is with SQL syntax checking. In some cases, when I press F9 to execute a SQL, it shows the SQL as executed i.e. shows something like 0.0134 seconds in the toolbar and no results displayed. In reality, the SQL had some syntax error which were NOT reported. This can be frustrating since now I have to fall back to SQL*Plus or TOAD just for syntax check."
The 0.0134 seconds could be the result of the most recently executed successful statement. Check the Script Output tab for errors. Use F5 (Run Script option) instead of F9.
"I like the fact that SQLDev highlights the current SQL but it would be more useful if it just indicated the first line of the current sql instead of highlighting the whole sql."
On the SQL statement (or code), Right Click -> Format SQL (or press Ctrl & B), proper formatting would help.
I use version 1.0.0.15.57 and seems to be working allright.
- Babu Rangasamy -
Is there any context-sensitive help in SQL Developer. I'm looking for a way to link SQL syntax with some sort of a Help function. Searching the SQL Reference pdf just doesn't cut it. For example, when I search the SQL Reference pdf for Round, I get 134 hits. I would look for a page or 2 on how to use Round, with examples, but accessible directly from SQL Developer.
No there isn't.
There's a rejected feature request for this at the Exchange (http://htmldb.oracle.com/pls/otn/f?p=42626:39:947182819474243::NO::P39_ID:5662), so chances are very small it ever makes it in.
Nevertheless, you can still vote and add comments there; if there's enough weight on an item it will eventually make it for the TODO list.
Including the doc isn't necessary, but just linking to the correct page would save a lot of time. In the case of ROUND, on pressing F1 inside the code editor or worksheet, sqldev could link directly to the SQL reference (http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/functions135.htm).
If the team doesn't want to put it in, maybe someone else does. It would make a nice extension... if you feel up for it?
K. -
Hi all,
I have an SQL database which up untli about 20 minutes ago was fine. I have a complex contact form whic is (was) all finished. I have added a couple more tables to the database (now totalling 4), in order to create a registration / login page.
(Is it okay to have 4 tables in 1 database?)
Anyway. I have just finished with the login stuff and all works fine. I decided to have a quick look around the site and make sure everything is okay - but for some reason when I navigate to the "complex contact form" - I get this message:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASCE LIMIT 0, 150' at line 1
The registration wizard and login pages still work, and in general the site is browseable. But this page will not work and I have no idea why?
Does anyone have any suggestion? All I have done since it worked is add 2 other tables as I said....
Thank you / please help!
NJThere was a typo in my previous post. There should be only one $ in $query_recordsetName. I should also have added that "recordsetName" is the name of your recordset. I would have thought it was obvious, but I see you're limiting the number of results, so the name is slightly different.
The other thing is that you have not put it where I told you. Apart from that...
$query_rscontacts1 = "SELECT contacts.Logo, contacts.Industries,
contacts.coverage, contacts.misc, contacts.id, contacts.email,
contacts.website FROM contacts WHERE {$NXTFilter_rscontacts1} ORDER BY
{$NXTSort_rscontacts1}";
$query_limit_rscontacts1 = sprintf("%s LIMIT %d, %d", $query_rscontacts1, $startRow_rscontacts1, $maxRows_rscontacts1);
echo $query_limit_rscontacts1 . '<br />';
$rscontacts1 = mysql_query($query_limit_rscontacts1, $Contacts) or die(mysql_error()); -
I'm trying to get onto a website i could normally get into but all it says is this
you have an error in your SQL syntax;check the manual that corresponds to your MySQL server version for the right syntax to use near') and adlx.'action' != 2' at line 1
I'm not good with computers and I've never heard of this i need some help, I may just be stupid but i seriously need some help here
preferably instructions for a hp computerThis looks to be an error with the web site you are visiting, not a problem with your PC. I suggest you contact the web site owner. The error suggests a problem with programming against a MySQL database, which is not a Microsoft technology.
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
ANSI SQL Syntax - What belongs to join-clause and what to where-clause
Hello,
we currently have a discussion about the ANSI SQL Syntax where we do not agree what belongs to the join clause and what belongs to the where clause in an ANSI Sytnax SQL Query.
Lets say there is a query like this:
+SELECT *+
FROM employees emp, departments dept
WHERE emp.dept_country = dept.dept_country
AND emp.dept_name = dept.dept_name
AND dept.dept_type = 'HQ'
AND emp.emp_lastname = 'Smith'
Primary key of the departments table is on the columns dept_country, dept_name and dept_type. We have a Oracle database 10g.
Now I have rewritten the query to Ansi Syntax:
+SELECT *+
FROM employees emp
JOIN departments dept
ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name
WHERE dept.dept_type = 'HQ'
AND emp.emp_lastname = 'Smith'
Another developer says that this is not completely correct, every filter on a column that belongs to the primary-key of the joined table has to be in the join clause, like this:
+SELECT *+
FROM employees emp
JOIN departments dept
+ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name AND dept.dept_type = 'HQ'
WHERE emp.emp_lastname = 'Smith'
Can somebody tell me which on is correct?
Is there any definition for that? I couldn't find it in the Oracle Database definition.
I just found out the names of the ANSI documents here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_standard_sql001.htm#i11939
I had a look at the ANSI webstore but there you have to buy the PDF files. In my case thats exaggerated because both of the Queries work and i am just interessted if there is one correct way.
Thank you in advance
MarcoHi,
As i guideline i would say, answer the question: should the result of the join be filtered or should only filtered rows be joined from a particular table?
This is helpful in the case of outer joins also, for inner joins it doesnt matters as said already be former posters, where there may be hughe semantical differences depending of where the predicates are placed.
From performance view, if we talk about oracle, take a look a the execution plans. You will see that there is (probably) no difference in case of inner joins. Even in case of outer joins the optimizer pushes the predicate as a filter towards the table if it semantically possible.
Regards -
SQL syntax error when creating record insertion form
Good day,
I was hoping someone could help me. I am trying to create a record insertion form on a website to insert data into a database table. When attempting to create the form, I am getting the following error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Organization, Office, Department, Phone, EmailAddress, JobTitle, `OfficialMaili' at line 1
Not sure what is going on. I am running windows 8 and DW cs5 w/ MYSQL. I am testing on a local server prior to pushing to the remote server.
Thank you for your assistance and please advise any code you would like me to send.Here is all the code from this particular webpage. I apologize, I am too stupid to realize which parts are SQL vice PHP vice HTML:
<?php require_once('Connections/group4.php'); ?>
<?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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO individual (Grade, LastName, FirstName, M.I., Organization, Office, Department, Phone, EmailAddress, JobTitle, `OfficialMailing Address`, Citizenship, Designation, IATrainingComplete, IADate) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Grade'], "text"),
GetSQLValueString($_POST['LastName'], "text"),
GetSQLValueString($_POST['FirstName'], "text"),
GetSQLValueString($_POST['MI'], "text"),
GetSQLValueString($_POST['Organization'], "text"),
GetSQLValueString($_POST['Office'], "text"),
GetSQLValueString($_POST['Department'], "text"),
GetSQLValueString($_POST['Phone'], "double"),
GetSQLValueString($_POST['EmailAddress'], "text"),
GetSQLValueString($_POST['JobTitle'], "text"),
GetSQLValueString($_POST['OfficialMailing_Address'], "text"),
GetSQLValueString($_POST['Citizenship'], "text"),
GetSQLValueString($_POST['Designation'], "text"),
GetSQLValueString($_POST['IATrainingComplete'], "text"),
GetSQLValueString($_POST['IADate'], "text"));
mysql_select_db($database_group4, $group4);
$Result1 = mysql_query($insertSQL, $group4) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $insertGoTo));
mysql_select_db($database_group4, $group4);
$query_rsIndividual = "SELECT * FROM individual ORDER BY IndividualNumber ASC";
$rsIndividual = mysql_query($query_rsIndividual, $group4) or die(mysql_error());
$row_rsIndividual = mysql_fetch_assoc($rsIndividual);
$totalRows_rsIndividual = mysql_num_rows($rsIndividual);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Us</title>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.header {
font-size: 36px;
text-decoration: underline;
.quote {
font-size: 18px;
font-style: italic;
.tablethisone {
margin: 5px;
padding: 25px;
border: medium none #000;
text-align: center;
</style>
</head>
<body>
<p><img src="Images/EGA.png" width="227" height="222" alt="EGA" /><span class="header">SAAR Tracking System
</span></p>
<ul id="MenuBar1" class="MenuBarHorizontal">
<li><a href="index.php">Home</a> </li>
<li><a href="search.php">Search</a></li>
<li><a href="contact.php">Contact Us</a> </li>
</ul>
<p> </p>
<p>PRIVACY ACT STATEMENT</p>
<p>Executive Order 10450, 9397; and Public Law 99-474, the Computer Fraud and Abuse Act.
To record names, signatures, and other identifiers for the purpose of validating the trustworthiness of individuals requesting
access to Department of Defense (DoD) systems and information. NOTE: Records may be maintained in both electronic
and/or paper form.</p>
<p> </p>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Grade:</td>
<td><input type="text" name="Grade" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">LastName:</td>
<td><input type="text" name="LastName" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">FirstName:</td>
<td><input type="text" name="FirstName" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">M.I.:</td>
<td><input type="text" name="MI" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Organization:</td>
<td><input type="text" name="Organization" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Office:</td>
<td><input type="text" name="Office" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Department:</td>
<td><input type="text" name="Department" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Phone:</td>
<td><input type="text" name="Phone" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EmailAddress:</td>
<td><input type="text" name="EmailAddress" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">JobTitle:</td>
<td><input type="text" name="JobTitle" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">OfficialMailing Address:</td>
<td><input type="text" name="OfficialMailing_Address" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Citizenship:</td>
<td><input type="text" name="Citizenship" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Designation:</td>
<td><input type="text" name="Designation" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">IATrainingComplete:</td>
<td><input type="text" name="IATrainingComplete" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">IADate:</td>
<td><input type="text" name="IADate" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>Disclosure of this information is voluntary; however, failure to provide the requested information may impede, delay or
prevent further processing of this request.</p>
<p class="quote">"Be polite, be professional, but have a plan to kill everybody you meet" General James Mattis</p>
<p> </p>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>
<?php
mysql_free_result($rsIndividual);
?> -
Converting XPATH to SQL syntax?
HI, all
I am looking for a third party tool to convert XPATH syntax to SQL syntax?
XPATH is primary syntax to retrieve and locate data in XML structre, while SQL is the stand syntax to operate data in RDBMS. Please assume I have a way to map XML data to RDBMS.
Thanks in advance!
Tao
2002/11/15Did you ever find a solution?????... that�s exactly what I�m trying to do. Any help would be appreciated. Theres like no information on this stuff. Thanks
bpfl -
Entry-SQL syntax error: CASE not allowed
Hello All. When I use sap netweaver developer to develop webdynpro applications, I always meet that jdbc error.
when using inner join,left join, or using case when in the sql, it will pop up Entry-SQL syntax error.
But I have run the sql in Microsoft SQL Server studio successfully.
The SQL statement "UPDATE SAPNWDDB.Z_SERIAL SET LASTSERIAL = CASE WHEN ENDWITH IS NOT NULL THEN CASE WHEN LASTSERIAL + 1 > ENDWITH THEN ISNULL(STARTWITH, 0) ELSE LASTSERIAL + 1 END ELSE LASTSERIAL + 1 END WHERE SERIALNO = ?" contains the syntax error[s]: - 1:43 - Entry-SQL syntax error: CASE not allowed
- 1:78 - Entry-SQL syntax error: CASE not allowed
- 1:124 - SQL syntax error: the token "(" was not expected here
Can someone help me? Thank you.Hi Arun Jaiswal ,
Thank you for your answer. But I have tried query in sql editor. Actually it can work. Other than "CASE" syntax, it seems not support inner join and left join in webdynpro either. I even can not query the db views.
That's imposible jdbc not support these simple syntex. I wonder there is any config control the sql compatibility level.
I have developped a java programm to test it. It is ok. No error. But the same case pop up error in java webdynpro application.I don't know why.
I am entry level webdynpro developper.
Hopefully you can help me.
Thank you.
Edited by: zegunlee330 on Sep 3, 2010 4:18 AM -
You have an error in your SQL syntax;
i have a checkout page that i am trying to send to a payment centre but and getting the following error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '16)' at line 1
can someone help and tell me what this means does it mean "conflict with columns definitions"
if so what can i do to solve the issue? do you need to see the page code?
thanks<?php require_once('Connections/wibbles.php'); ?>
<?php
// do not cache
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate"); // /1.1
header ("Pragma: no-cache"); // /1.0
// *** Restrict Access To Page: Grant or deny access to this page
$FX_authorizedUsers=" ";
$FX_authFailedURL="login.php";
$FX_grantAccess=0;
if (!session_id()) session_start();
if (isset($_SESSION["MM_Username"])) {
if (true || !(isset($_SESSION["MM_UserAuthorization"])) || $_SESSION["MM_UserAuthorization"]=="" || strpos($FX_authorizedUsers, $_SESSION["MM_UserAuthorization"])) {
$FX_grantAccess = 1;
if (!$FX_grantAccess) {
$FX_qsChar = "?";
if (strpos($FX_authFailedURL, "?")) $FX_qsChar = "&";
$FX_referrer = "Restricted Area";
$FX_authFailedURL = $FX_authFailedURL . $FX_qsChar . "accessdenied=" . urlencode($FX_referrer);
header("Location: $FX_authFailedURL");
exit;
// *** Retrieve X ID ***
if (!session_id()) session_start();
$XC_OrderIdSessionVar = "OrderID";
if (!isset($_SESSION[$XC_OrderIdSessionVar])) {
// Get a unique OrderID number and save to session.
$XC_tableName = "wibble_nextorder";
$XC_fieldName = "NextOrderID";
mysql_select_db($database_wibbles, $wibbles);
$XC_IdSource = "select " . $XC_fieldName . " from " . $XC_tableName;
$XC_rsId = mysql_query($XC_IdSource, $wibbles) or die(mysql_error());
$row_XC_rsId = mysql_fetch_assoc($XC_rsId);
$_SESSION[$XC_OrderIdSessionVar] = $row_XC_rsId[$XC_fieldName];
$$XC_OrderIdSessionVar = $_SESSION[$XC_OrderIdSessionVar];
session_register($XC_OrderIdSessionVar);
$XC_next = $_SESSION[$XC_OrderIdSessionVar] + 1;
$XC_upd = "update " . $XC_tableName . " set " . $XC_fieldName . " = " . $XC_next;
$XC_rsId = mysql_query($XC_upd, $wibbles) or die(mysql_error());
$XC_rsId = null;
// x limit validation
if (isset($_POST["XC_Limit"]) && $_POST["XC_Limit"] != "") {
$XC_limErr = stripslashes($_POST["XC_Limit"]);
if (isset($_GET['XC_SaveCartToTable'])) unset($_GET['XC_SaveCartToTable']);
unset($HTTP_POST_VARS);
unset($_POST);
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;
// x limit validation
if (isset($_POST["XC_Limit"]) && $_POST["XC_Limit"] != "") {
$XC_limErr = stripslashes($_POST["XC_Limit"]);
if (isset($_GET['XC_SaveCartToTable'])) unset($_GET['XC_SaveCartToTable']);
unset($_POST);
unset($_POST);
// Validate X amount
if (isset($_POST["XC_Amount"]) && $_POST["XC_Amount"] < 10) {
if (isset($_GET['XC_SaveCartToTable'])) unset($_GET['XC_SaveCartToTable']);
unset($_POST);
unset($_POST);
$XC_amErr = "The amount doesn't reach the allowed minimum of € 100.";
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO wibble_orders (OrderID, CustomerID, OrderDate, Shipping, Discount, Tax, Total) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['OrderID'], "int"),
GetSQLValueString($_POST['CustomerID'], "int"),
GetSQLValueString($_POST['OrderDate'], "date"),
GetSQLValueString($_POST['Shipping'], "double"),
GetSQLValueString($_POST['Discount'], "double"),
GetSQLValueString($_POST['Tax'], "double"),
GetSQLValueString($_POST['XC_Amount'], "double"));
mysql_select_db($database_wibbles, $wibbles);
$Result1 = mysql_query($insertSQL, $wibbles) or die(mysql_error());
// *** X Shopping Cart ***
$useSessions = true;
$XCName = "wibbleJakeCart";
$XCTimeout = 30;
$XC_ColNames=array("ProductID","Quantity","Name","Color","Price","MinQty","Discount","Stoc k","Total");
$XC_ComputedCols=array("","","","","","","","","Price");
require_once('XCInc/XCart.inc');
$colname_rsCustomer = "1";
if (isset($_SESSION['MM_UserAuthorization'])) {
$colname_rsCustomer = $_SESSION['MM_UserAuthorization'];
mysql_select_db($database_wibbles, $wibbles);
$query_rsCustomer = sprintf("SELECT * FROM wibble_customers WHERE CustomerID = %s", GetSQLValueString($colname_rsCustomer, "int"));
$rsCustomer = mysql_query($query_rsCustomer, $wibbles) or die(mysql_error());
$row_rsCustomer = mysql_fetch_assoc($rsCustomer);
$totalRows_rsCustomer = mysql_num_rows($rsCustomer);
// *** Redirect if XCart is Empty ***
$XC_RedirectIfEmpty = "shopping-cart.php";
if (isset($_SERVER["QUERY_STRING"])) {
$XC_RedirectIfEmpty .= "?" . htmlentities($_SERVER["QUERY_STRING"]);
if (isset(${$XCName}["contents"]) && (sizeof(${$XCName}["contents"][0]) == 0)) header("Location: " . $XC_RedirectIfEmpty);
// *** Repeat XCart region *** (do not remove this label)
// validate x limit
$XC_invalidItems = "";
$XC_lim = "";
$iCol = array_search("Quantity",${$XCName}["ColNames"]);
$iSrc = array_search("Stock",${$XCName}["ColNames"]);
for ($iVal=0; $iVal<sizeof(${$XCName}["contents"][0]); $iVal++) {
if (${$XCName}["contents"][$iCol][$iVal] > ${$XCName}["contents"][$iSrc][$iVal]) {
if ($XC_invalidItems != "") $XC_invalidItems .= "-";
$XC_invalidItems .= (string) ($iVal+1);
if ($XC_lim != "") $XC_lim .= "-";
$XC_lim .= (string) ${$XCName}["contents"][$iSrc][$iVal];
if ($XC_invalidItems != "") {
$XC_invalidItems = "(".$XC_invalidItems.")";
$XC_lim = "(".$XC_lim.")";
$x_limErr = "The item(s) $XC_invalidItems exceed the available stock of $XC_lim";
// *** Add shipping based on Range
mysql_select_db($database_wibbles, $wibbles);
$XC_sourceVal = $XCart_sumTotal;
$XC_ShipSource = "SELECT Shipping FROM wibble_shipbyprice WHERE MinPurchase < " . $XC_sourceVal . " AND MaxPurchase >= " . $XC_sourceVal;
$XC_rsShip = mysql_query($XC_ShipSource, $wibbles) or die(mysql_error());
$row_XC_rsShip = mysql_fetch_assoc($XC_rsShip);
$XC_Shipping = $row_XC_rsShip['Shipping'];
$XC_rsShip = null;
// *** Add Referenced Sales Tax
mysql_select_db($database_wibbles, $wibbles);
$XC_taxSource = "SELECT Tax FROM wibble_tax WHERE Country = '" . $row_rsCustomer['Country'] . "'";
$XC_rsTax = mysql_query($XC_taxSource, $wibbles) or die(mysql_error());
$row_XC_rsTax = mysql_fetch_assoc($XC_rsTax);
$XC_Tax = $row_XC_rsTax['Tax'];
$XC_rsTax = null;
$XC_SalesTax = $XC_Tax*($XCart_sumTotal+$XC_Shipping-$XC_Discount);
// *** Compute Grand Total
$XC_GranTotal = $XCart_sumTotal+$XC_SalesTax+$XC_Shipping-$XC_Discount;
// *** Format table as Europe style
if (!session_id()) session_start();
// set header
$XC_header = "<style type=\"text/css\">\n<!--\n";
$XC_header .= "table {font-family: Arial, Helvetica, sans-serif; font-size: 13px;}\n";
$XC_header .= "-->\n</style>\n";
$XC_header .= "<table width=\"520\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
$XC_header .= " <tr>\n <td>\n";
$XC_header .= "<table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\n";
$XC_header .= " <tr>\n <td> </td>\n <td align=\"right\"> </td>\n </tr>\n";
$XC_header .= " <tr>\n <td>Order n. <b>" . $_SESSION["OrderID"] . "</b></td>\n <td align=\"right\"> " . date("d/m/Y") . "</td>\n </tr>\n";
$XC_header .= " <tr>\n <td> </td>\n <td> </td>\n </tr>\n";
$XC_header .= " <tr>\n <td colspan=\"2\" align=\"Left\">";
$XC_header .= $row_rsCustomer["FirstName"] . " ";
$XC_header .= $row_rsCustomer["LastName"] . " <br>";
$XC_header .= $row_rsCustomer["Address"] . " <br>";
$XC_header .= $row_rsCustomer["ZIP"] . " ";
$XC_header .= $row_rsCustomer["City"] . " ";
$XC_header .= $row_rsCustomer["State"] . " <br>";
$XC_header .= $row_rsCustomer["Country"] . " <br>";
$XC_header .= "</td>\n </tr>\n</table>\n";
$XC_header .= "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\n";
$XC_header .= " <tr>\n <td colspan=\"5\"> </td>\n </tr>\n";
$XC_header .= " <tr>\n <td colspan=\"5\">Cart contents: </td>\n </tr>\n";
// set cart data
$XCartData = " <tr>\n";
$XCartData .= " <th width=\"30\" bgcolor=\"#CC6600\"><font color=\"white\">Qty</font></th>\n";
$XCartData .= " <th width=\"310\" bgcolor=\"#CC6600\"><font color=\"white\">Description</font></th>\n";
$XCartData .= " <th width=\"60\" bgcolor=\"#CC6600\"><font color=\"white\">Price</font></th>\n";
$XCartData .= " <th width=\"40\" bgcolor=\"#CC6600\"><font color=\"white\">Disc</font></th>\n";
$XCartData .= " <th width=\"80\" bgcolor=\"#CC6600\"><font color=\"white\">Total</font></th>\n";
$XCartData .= " </tr>\n";
for ($jRow=0; $jRow<sizeof(${$XCName}["contents"][0]); $jRow++) {
require('XCInc/RepeatXMailRegion.inc');
$XCartData .= " <tr>\n";
$XCartData .= " <td align=\"Center\" bgcolor=\"#FFFF99\">" . ${$XCName}["contents"][1][$jRow] . "</td>\n";
$XCartData .= " <td align=\"Left\" bgcolor=\"#FFFF99\">" . ${$XCName}["contents"][2][$jRow] . "</td>\n";
$XCartData .= " <td align=\"Right\" bgcolor=\"#FFFF99\">€ " . number_format(${$XCName}["contents"][4][$jRow], 2, ',', '.') . "</td>\n";
$XCartData .= " <td align=\"Center\" bgcolor=\"#FFFF99\">" . ${$XCName}["contents"][6][$jRow] . "</td>\n";
$XCartData .= " <td align=\"Right\" bgcolor=\"#FFFF99\">€ " . number_format(${$XCName}["contents"][8][$jRow], 2, ',', '.') . "</td>\n";
$XCartData .= " </tr>\n";
// set footer
$XC_footer = " <tr>\n <td colspan=\"4\" align=\"right\"><b> SubTotal </b></td>\n <td align=\"right\" bgcolor=\"#FFFF99\"><b> € " . number_format($XCart_sumTotal, 2, ',', '.') . "</b></td>\n </tr>\n";
$XC_footer .= " <tr>\n <td colspan=\"4\" align=\"right\"> Shipping </td>\n <td align=\"right\" bgcolor=\"#FFFF99\"> € " . number_format($XC_Shipping, 2, ',', '.') . "</td>\n </tr>\n";
$XC_footer .= " <tr>\n <td colspan=\"4\" align=\"right\"> </td>\n <td align=\"right\" bgcolor=\"#FFFF99\"> </td>\n </tr>\n";
$XC_footer .= " <tr>\n <td colspan=\"4\" align=\"right\"> Sales Tax </td>\n <td align=\"right\" bgcolor=\"#FFFF99\"> € " . number_format($XC_SalesTax, 2, ',', '.') . "</td>\n </tr>\n";
$XC_footer .= " <tr>\n <td colspan=\"4\" align=\"right\"><b> Grand Total </b></td>\n <td align=\"right\" bgcolor=\"#FFFF99\"><b> € " . number_format($XC_GranTotal, 2, ',', '.') . "</b></td>\n </tr>\n";
$XC_footer .= " <tr>\n <td colspan=\"5\"> </td>\n </tr>\n";
$XC_footer .= "</table>\n </td>\n </tr>\n</table>\n";
// join all
if (isset($_SESSION["XC_CartMail"])) session_unregister("XC_CartMail");
$XC_CartMail = $XC_header . $XCartData . $XC_footer;
$_SESSION["XC_CartMail"] = $XC_CartMail;
session_register("XC_CartMail");
// *** Save XCart contents to table ***
require_once('XCInc/XCsaveAction.inc');
if (isset($_GET['XC_SaveCartToTable']) && ($_GET['XC_SaveCartToTable'] == "1")) {
$XC_destColName = array("ProductID","Quantity","","Color","UnitPrice","","Discount","","Total");
$XC_destColType = array("str","num","str","str","num","num","num","num","num");
$XC_orderId = $_SESSION['OrderID'];
$XC_tableName = "wibble_orderdetails";
$XC_OrderIDCol = "OrderID";
$XC_OrderIDType = "num";
$XC_AddToTableRedirect = "thanks.php";
$XC_conName = "wibbles";
require_once('XCInc/SaveXCartToTable.inc');
// clone a session
if (!session_id()) session_start();
if (isset($_SESSION["OrderNum"])) session_unregister("OrderNum");
if (isset($_SESSION["OrderID"])) {
$OrderNum = $_SESSION["OrderID"];
$_SESSION["OrderNum"] = $OrderNum;
session_register("OrderNum");
function DoFormatCurrency($theObject,$NumDigitsAfterDecimal,$DecimalSeparator,$GroupDigits,$Curren cySymbol) {
$currencyFormat=$CurrencySymbol.number_format($theObject,$NumDigitsAfterDecimal,$Dec imalSeparator,$GroupDigits);
return ($currencyFormat);
function DoFormatPercent($theObject,$NumDigitsAfterDecimal,$DecimalSeparator,$GroupDigits) {
$currencyFormat=number_format($theObject*100,$NumDigitsAfterDecimal,$DecimalSeparato r,$GroupDigits).'%';
return ($currencyFormat);
?> -
Error when making connection: You have an error in your SQL syntax;
I'm getting this error when trying to make a simple Database Connection:
SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '????????????????????????????????' at line 1
SQLState: 42000
VendorError: 1064
I tried a different driver and got the same error with more "?"s in the "use near....." part.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBTest{ public static void main(String[] args){ try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch(Exception e){ System.out.println(e); System.exit(0); } Connection conn = null; try { conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/testDB?" + "user=root&password=password"); conn.close(); } catch (SQLException ex) { // handle any errors System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); } } }
MySQL Server Version:
Server version: 5.0.67-0ubuntu6 (Ubuntu)cotton.m wrote:
c0c0 wrote:
I've tried Drivers 5.1 , 5.0 and 3.1 now and I get the same problem every time. I've tried switching databases, users, etc but always get this same error:
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '????????????????' at line 1
I have the latest version of mysql from the Ubuntu repositories. Do I have to configure that a certain way? It isn't the URL which I supply that it does not like because I've tried multiple URLs and they all give me the same error when I supply the correct information.
Any help is greatly appreciated.This is.. very odd.
I have to ask are you really, really sure that your code is just as you posted? Are you sure you aren't running a query of some sort? My guess at this point would be some sort of rather bizarre encoding issue. I'm sorry but I can't reproduce your behaviour, I am connecting to different MySQL instances with no problem from Ubuntu..
Yes the code is exactly the same as what I posted (except hiding actual usernames and passwords)
I've even tried to connect to a remote mysql server and get the same behavior (If I type in the wrong database it alerts me there is no db of that name, if I lg in with the wrong password it alerts me cant login ____ @ ______, when I have all the correct information I get that same old error) , I'm somewhat convinced it's my driver now. I thought at first it was the way I had mysql configured but now I think it's my driver or the way I have everything installed. I simply put the driver location in the classpath and do the command:
export set CLASSPATH=/usr/share/tomcat5.5-webapps/ROOT/lib/mysql-connector-java-5.1.7-bin.jar
Was this the wrong way to go about doing it? I'm not currently running tomcat I simply put it there because a book said that's where it should go for tomcat, but I wanted to first try this not running tomcat with just a simple normal Java example. -
Need help in SQL (DENSE_RANK) function
Hello All,
I need the help in SQL.
We have a table called status and the column are
status_id number
account_id number
status_cd varchar2(10)
created_id varchar2(10)
created_by date
and data is as follows
insert into status values (1,101,'ENTER','ABC',to_date('21-JAN-2007 11:15:14','DD-MON-YYYY HH:MI:SS'));
insert into status values (2,101,'REVIEW','DEF',to_date('21-JAN-2007 11:30:25','DD-MON-YYYY HH:MI:SS'));
insert into status values (3,101,'APPROVE','GHI',to_date('21-JAN-2007 11:30:25','DD-MON-YYYY HH:MI:SS'));
insert into status values (4,102,'ENTER','ABC',to_date('21-JAN-2007 11:18:14','DD-MON-YYYY HH:MI:SS'));
insert into status values (5,102,'REVIEW','DEF',to_date('21-JAN-2007 11:33:25','DD-MON-YYYY HH:MI:SS'));
insert into status values (6,102,'CANCEL','GHI',to_date('21-JAN-2007 11:33:25','DD-MON-YYYY HH:MI:SS'));
insert into status values (7,103,'ENTER','ABC',to_date('21-JAN-2007 11:21:14','DD-MON-YYYY HH:MI:SS'));We have different status as follows
1. ENTER
2. REVIEW
3. APPROVE
4. CANCEL
5. REJECT
My requirement ..
I need the max of created_id column for the status in ('APPROVE','CANCEL') and if there is no status in ('APPROVE','REVIEW') than it should be NULL.
I wrote an SQL as
select account_id,max(created_id) keep (dense_rank first order by decode(status_cd,'APPROVE',created_dt,'REVIEW',created_dt,NULL) DESC NULLS LAST,
decode(status_cd,'APPROVE',status_id,'REVIEW',status_id,NULL) DESC NULLS LAST) last_app_rev_user
from status
group by account_id and gives me the output like
ACCOUNT_ID LAST_APP_R
101 GHI
102 DEF
103 ABCBut I want the Output like
ACCOUNT_ID LAST_APP_R
101 GHI
102 DEF
103 NULLAs the account 103 has no status called 'REVIEW' and 'APPROVE'
My DB Version in 10.2.0.3.0.
Hope I explain it properly. And if you have any other option without dense_rank still i will be happy.
Thanks in advance for your help.
AB
null
Message was edited by:
ABinstead of max(created_id) keep... use
smth like max(case when status_cd in ('APPROVE','REVIEW') then created_id end) keep...
Maybe you are looking for
-
Attempting to Save data from an access database file into a local variable for use.
Hello! i'm trying to develop a small text based game in Visual Basic 2013 and I've recently decided i need to use a more sophisticated data storage system then dozens of .txt files and stream-readers. i'm using Microsoft access and i completed my dat
-
How to share my wifi connection to my pc with usb cable?
Is it possible??
-
How to store a query containing more than 15000 characters in a variable of nvarchar(max)
I have the following string and I want to store it in variable using SQL Server 2008 R2 . I can't store this string using variable of nvarchar(max) . ' SELECT A.[EmployeeCode] ,A.[EmployeeId] ,A.[Name],A.[DepartmentCode],A.[DesignationCode] , A
-
Rac node evicted and asm related
Hi friends I have few doubts in rac environment 1.In 2 node rac while adding datafile to tablespace if you forget to metion '+'then what will happen whether it is going to be create or it throws an error if it creates where exactly located and other
-
Iphoto save instant slide show
I created a book in iPhoto with a specific theme, titles, photos etc. The "instant slideshow" that I can play while selecting the book under "Projects" takes all the specifics from my book and puts them into a slideshow format that I would like to s