Sending different table id's into user table using a form

hello, this is a lead up to another discussion that has not been resolved. i am getting pretty desperate now. i am sure it cant be that hard and really need help i am using MySQL php
i have created a input form that when submitted sends the data to 3 different tables
i have a tenant table. guarantor table and landlord table all in the database. i also have a property table that is already populated by another form on the website. on the input form though the property table is a dynamic drop down menu that when selected populates fields on the top of the input form
i have the understanding that because the guarantorID, landlordID and propertyID are all inputting new data these will be input commands, however the property is already in the table so this will be an update command?
what i need to do is when the form is submitted the guarantorID, landlordID and propertyID all are sent to columns in the tenant table. this is called join i believe?
i have provided the unformatted code below that all works, but what i need to know how to do is the above. Link them all togeather and send all the id from the  guarantorID, landlordID and propertyID to the tenant table so they can all be reference when i create new pages
can this be done?
<?php require_once('Connections/nameprop.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 name_tenant (Title, `First Names`, Surname, DOB, DOBMonth, DOBYear, Nationality, Marital_Status, DayNumber, EvenNumber, MobNumber, Smoker, CurrentAdd, Status, PreviousAdd, Student, FinancialCCj, FinancialArrears, FinancialBankR, FinancialNone, BankName, AccountNum, SortCode, BankDuration, DebitCCCard, Electoral, `next of kin`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Title'], "text"),
                       GetSQLValueString($_POST['First_Names'], "text"),
                       GetSQLValueString($_POST['Surname'], "text"),
                       GetSQLValueString($_POST['DOB'], "text"),
                       GetSQLValueString($_POST['DOBMonth'], "text"),
                       GetSQLValueString($_POST['DOBYear'], "text"),
                       GetSQLValueString($_POST['Nationality'], "text"),
                       GetSQLValueString($_POST['Marital_Status'], "text"),
                       GetSQLValueString($_POST['DayNumber'], "double"),
                       GetSQLValueString($_POST['EvenNumber'], "double"),
                       GetSQLValueString($_POST['MobNumber'], "double"),
                       GetSQLValueString($_POST['Smoker'], "text"),
                       GetSQLValueString($_POST['CurrentAdd'], "text"),
                       GetSQLValueString($_POST['Status'], "text"),
                       GetSQLValueString($_POST['PreviousAdd'], "text"),
                       GetSQLValueString($_POST['Student'], "text"),
                       GetSQLValueString($_POST['FinancialCCj'], "text"),
                       GetSQLValueString($_POST['FinancialArrears'], "text"),
                       GetSQLValueString($_POST['FinancialBankR'], "text"),
                       GetSQLValueString($_POST['FinancialNone'], "text"),
                       GetSQLValueString($_POST['BankName'], "text"),
                       GetSQLValueString($_POST['AccountNum'], "double"),
                       GetSQLValueString($_POST['SortCode'], "double"),
                       GetSQLValueString($_POST['BankDuration'], "text"),
                       GetSQLValueString($_POST['DebitCCCard'], "text"),
                       GetSQLValueString($_POST['Electoral'], "text"),
                       GetSQLValueString($_POST['next_of_kin'], "text"));
  mysql_select_db($database_nameprop, $nameprop);
  $Result1 = mysql_query($insertSQL, $nameprop) or die(mysql_error());
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO name_guarantor (FullName, Title, DOBday, DOBMonth, DOBYear, Sex, MaritalStatus, DaytimeNumber, EveningNumber, MobileNumber, Email, CurrentAddress, PreviousAddress, BankName, AccountNum, SortCode, BankDuration, CCDebitCard, ElectoralRoll, Profession, AnnualWages, PayrollNum, EmpName, EmpAddress, EmpContName, EmpContNumber, EmpEmail, EmpFinaHist, EmpDate, EmpDisclaimer) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['FullName'], "text"),
                       GetSQLValueString($_POST['Title'], "text"),
                       GetSQLValueString($_POST['DOBday'], "double"),
                       GetSQLValueString($_POST['DOBMonth'], "text"),
                       GetSQLValueString($_POST['DOBYear'], "text"),
                       GetSQLValueString($_POST['Sex'], "text"),
                       GetSQLValueString($_POST['MaritalStatus'], "text"),
                       GetSQLValueString($_POST['DaytimeNumber'], "double"),
                       GetSQLValueString($_POST['EveningNumber'], "double"),
                       GetSQLValueString($_POST['MobileNumber'], "double"),
                       GetSQLValueString($_POST['Email'], "text"),
                       GetSQLValueString($_POST['CurrentAddress'], "text"),
                       GetSQLValueString($_POST['PreviousAddress'], "text"),
                       GetSQLValueString($_POST['BankName'], "text"),
                       GetSQLValueString($_POST['AccountNum'], "double"),
                       GetSQLValueString($_POST['SortCode'], "double"),
                       GetSQLValueString($_POST['BankDuration'], "text"),
                       GetSQLValueString($_POST['CCDebitCard'], "text"),
                       GetSQLValueString($_POST['ElectoralRoll'], "text"),
                       GetSQLValueString($_POST['Profession'], "text"),
                       GetSQLValueString($_POST['AnnualWages'], "text"),
                       GetSQLValueString($_POST['PayrollNum'], "double"),
                       GetSQLValueString($_POST['EmpName'], "text"),
                       GetSQLValueString($_POST['EmpAddress'], "text"),
                       GetSQLValueString($_POST['EmpContName'], "text"),
                       GetSQLValueString($_POST['EmpContNumber'], "double"),
                       GetSQLValueString($_POST['EmpEmail'], "text"),
                       GetSQLValueString($_POST['EmpFinaHist'], "text"),
                       GetSQLValueString($_POST['EmpDate'], "double"),
                       GetSQLValueString($_POST['EmpDisclaimer'], "text"));
  mysql_select_db($database_nameprop, $nameprop);
  $Result1 = mysql_query($insertSQL, $nameprop) or die(mysql_error());
  header(sprintf("Location: %s", $insertGoTo));
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO name_landlord (name, `telephone number`, mobileNumber, email, address, dateday, datemonth, dateyear, terms) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_POST['telephone_number'], "text"),
                       GetSQLValueString($_POST['mobileNumber'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['address'], "text"),
                       GetSQLValueString($_POST['dateday'], "text"),
                       GetSQLValueString($_POST['datemonth'], "text"),
                       GetSQLValueString($_POST['dateyear'], "text"),
                       GetSQLValueString($_POST['terms'], "text"));
  mysql_select_db($database_nameprop, $nameprop);
  $Result1 = mysql_query($insertSQL, $nameprop) or die(mysql_error());
  $insertGoTo = "pay-online.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  header(sprintf("Location: %s", $insertGoTo));
mysql_select_db($database_nameprop, $nameprop);
$query_rsApplyNow = "SELECT * FROM name_editprop";
$rsApplyNow = mysql_query($query_rsApplyNow, $nameprop) or die(mysql_error());
$row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);
$totalRows_rsApplyNow = mysql_num_rows($rsApplyNow);
?>
<!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>Untitled Document</title>
<script type="text/javascript">
function loadFields(theValue) {
         var props = theValue.split("|");
          var prop_id = props[0];
          var propAdd = props[1] ;
          var propPrice = props[2];
                      var town = props[3]
                      var postcode = props[4]
          document.getElementById('prop_id').value=prop_id;
          document.getElementById('Add1').value=propAdd;
                      document.getElementById('town').value=town;
                      document.getElementById('postcode').value=postcode;
          document.getElementById('RentalPrice').value='£' + propPrice +'/ per month';
</script>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  <input type="hidden" name="MM_insert" value="form1" />
<!-- Place the following code where you want to show the result of the property selection --><table width="100%" border="0" cellpadding="0">
  <tr>
    <td width="23%"><!-- the following code is just copied from your code -->
      <select name="Select Property" id="Select Property" onchange="loadFields(this.value)">
        <option value="select your property">select your property</option>
        <?php
do {
?>
        <option value="<?php echo $row_rsApplyNow['prop_id'] . '|' . $row_rsApplyNow['prop_add1'] . '|' . $row_rsApplyNow['rental_price'] . '|' . $row_rsApplyNow['town'] . '|' . $row_rsApplyNow['postcode'];?>"><?php echo $row_rsApplyNow['prop_id'] . " , " . $row_rsApplyNow['prop_add1']; ?></option>
        <?php
} while ($row_rsApplyNow = mysql_fetch_assoc($rsApplyNow));
  $rows = mysql_num_rows($rsApplyNow);
  if($rows > 0) {
      mysql_data_seek($rsApplyNow, 0);
            $row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);
?>
      </select></td>
    <td width="77%"> </td>
  </tr>
  <tr>
    <td>Property ID:</td>
    <td><input type="text" name="prop_id" id="prop_id" readonly="readonly" /></td>
  </tr>
  <tr>
    <td>Address</td>
    <td><input type="text" name="Add1" id="Add1" readonly="readonly" /></td>
  </tr>
  <tr>
    <td>Town</td>
    <td><input type="text" name="town" id="town" readonly="readonly" /></td>
  </tr>
  <tr>
    <td>Postcode</td>
    <td><label for="postcode"></label>
      <input type="text" name="postcode" id="postcode" readonly="readonly" /></td>
  </tr>
  <tr>
    <td>Rent</td>
    <td><input type="text" name="RentalPrice" id="RentalPrice" readonly="readonly" /></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellpadding="0">
      <tr>
        <td>tenant</td>
        <td>gaurantor</td>
        <td>landlord</td>
      </tr>
      <tr>
        <td><table align="center">
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Title:</td>
            <td><input type="text" name="Title" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">First Names:</td>
            <td><input type="text" name="First_Names" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Surname:</td>
            <td><input type="text" name="Surname" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DOB:</td>
            <td><input type="text" name="DOB" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DOBMonth:</td>
            <td><input type="text" name="DOBMonth" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DOBYear:</td>
            <td><input type="text" name="DOBYear" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Nationality:</td>
            <td><input type="text" name="Nationality" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Marital_Status:</td>
            <td><input type="text" name="Marital_Status" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DayNumber:</td>
            <td><input type="text" name="DayNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EvenNumber:</td>
            <td><input type="text" name="EvenNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">MobNumber:</td>
            <td><input type="text" name="MobNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Smoker:</td>
            <td><input type="text" name="Smoker" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">CurrentAdd:</td>
            <td><input type="text" name="CurrentAdd" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Status:</td>
            <td><input type="text" name="Status" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">PreviousAdd:</td>
            <td><input type="text" name="PreviousAdd" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Student:</td>
            <td><input type="text" name="Student" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">FinancialCCj:</td>
            <td><input type="text" name="FinancialCCj" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">FinancialArrears:</td>
            <td><input type="text" name="FinancialArrears" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">FinancialBankR:</td>
            <td><input type="text" name="FinancialBankR" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">FinancialNone:</td>
            <td><input type="text" name="FinancialNone" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">BankName:</td>
            <td><input type="text" name="BankName" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">AccountNum:</td>
            <td><input type="text" name="AccountNum" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">SortCode:</td>
            <td><input type="text" name="SortCode" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">BankDuration:</td>
            <td><input type="text" name="BankDuration" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DebitCCCard:</td>
            <td><input type="text" name="DebitCCCard" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Electoral:</td>
            <td><input type="text" name="Electoral" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Next of kin:</td>
            <td><input type="text" name="next_of_kin" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right"> </td>
            <td> </td>
          </tr>
        </table></td>
        <td><table align="center">
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">FullName:</td>
            <td><input type="text" name="FullName" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Title:</td>
            <td><input type="text" name="Title2" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DOBday:</td>
            <td><input type="text" name="DOBday" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DOBMonth:</td>
            <td><input type="text" name="DOBMonth2" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DOBYear:</td>
            <td><input type="text" name="DOBYear2" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Sex:</td>
            <td><input type="text" name="Sex" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">MaritalStatus:</td>
            <td><input type="text" name="MaritalStatus" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DaytimeNumber:</td>
            <td><input type="text" name="DaytimeNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EveningNumber:</td>
            <td><input type="text" name="EveningNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">MobileNumber:</td>
            <td><input type="text" name="MobileNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Email:</td>
            <td><input type="text" name="Email" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">CurrentAddress:</td>
            <td><input type="text" name="CurrentAddress" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">PreviousAddress:</td>
            <td><input type="text" name="PreviousAddress" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">BankName:</td>
            <td><input type="text" name="BankName2" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">AccountNum:</td>
            <td><input type="text" name="AccountNum2" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">SortCode:</td>
            <td><input type="text" name="SortCode2" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">BankDuration:</td>
            <td><input type="text" name="BankDuration2" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">CCDebitCard:</td>
            <td><input type="text" name="CCDebitCard" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">ElectoralRoll:</td>
            <td><input type="text" name="ElectoralRoll" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Profession:</td>
            <td><input type="text" name="Profession" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">AnnualWages:</td>
            <td><input type="text" name="AnnualWages" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">PayrollNum:</td>
            <td><input type="text" name="PayrollNum" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EmpName:</td>
            <td><input type="text" name="EmpName" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EmpAddress:</td>
            <td><input type="text" name="EmpAddress" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EmpContName:</td>
            <td><input type="text" name="EmpContName" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EmpContNumber:</td>
            <td><input type="text" name="EmpContNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EmpEmail:</td>
            <td><input type="text" name="EmpEmail" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EmpFinaHist:</td>
            <td><input type="text" name="EmpFinaHist" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EmpDate:</td>
            <td><input type="text" name="EmpDate" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EmpDisclaimer:</td>
            <td><input type="text" name="EmpDisclaimer" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right"> </td>
            <td> </td>
          </tr>
        </table></td>
        <td><table align="center">
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Name:</td>
            <td><input type="text" name="name" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Telephone number:</td>
            <td><input type="text" name="telephone_number" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">MobileNumber:</td>
            <td><input type="text" name="mobileNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Email:</td>
            <td><input type="text" name="email" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Address:</td>
            <td><input type="text" name="address" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Dateday:</td>
            <td><input type="text" name="dateday" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Datemonth:</td>
            <td><input type="text" name="datemonth" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Dateyear:</td>
            <td><input type="text" name="dateyear" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Terms:</td>
            <td><input type="text" name="terms" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right"> </td>
            <td><input type="submit" value="Insert record" /></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
    </tr>
</table>
</form>
<p> </p>
<p> </p>
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($rsApplyNow);
?>

basically it isnt coming up with an error code just not sending the information across and not redirecting to the next page
here is the full code for the temp for i am working on.
<?php require_once('Connections/nameprop.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 name_tenant (Title, `First Names`, Surname, DOB, DOBMonth, DOBYear, Nationality, Marital_Status, DayNumber, EvenNumber, MobNumber, Smoker, CurrentAdd, Status, PreviousAdd, Student, FinancialCCj, FinancialArrears, FinancialBankR, FinancialNone, BankName, AccountNum, SortCode, BankDuration, DebitCCCard, Electoral, `next of kin`, prop_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Title'], "text"),
                       GetSQLValueString($_POST['First_Names'], "text"),
                       GetSQLValueString($_POST['Surname'], "text"),
                       GetSQLValueString($_POST['DOB'], "text"),
                       GetSQLValueString($_POST['DOBMonth'], "text"),
                       GetSQLValueString($_POST['DOBYear'], "text"),
                       GetSQLValueString($_POST['Nationality'], "text"),
                       GetSQLValueString($_POST['Marital_Status'], "text"),
                       GetSQLValueString($_POST['DayNumber'], "double"),
                       GetSQLValueString($_POST['EvenNumber'], "double"),
                       GetSQLValueString($_POST['MobNumber'], "double"),
                       GetSQLValueString($_POST['Smoker'], "text"),
                       GetSQLValueString($_POST['CurrentAdd'], "text"),
                       GetSQLValueString($_POST['Status'], "text"),
                       GetSQLValueString($_POST['PreviousAdd'], "text"),
                       GetSQLValueString($_POST['Student'], "text"),
                       GetSQLValueString($_POST['FinancialCCj'], "text"),
                       GetSQLValueString($_POST['FinancialArrears'], "text"),
                       GetSQLValueString($_POST['FinancialBankR'], "text"),
                       GetSQLValueString($_POST['FinancialNone'], "text"),
                       GetSQLValueString($_POST['BankName'], "text"),
                       GetSQLValueString($_POST['AccountNum'], "double"),
                       GetSQLValueString($_POST['SortCode'], "double"),
                       GetSQLValueString($_POST['BankDuration'], "text"),
                       GetSQLValueString($_POST['DebitCCCard'], "text"),
                       GetSQLValueString($_POST['Electoral'], "text"),
                       GetSQLValueString($_POST['next_of_kin'], "text"),
                       GetSQLValueString($_POST['prop_id'], "text"));
  mysql_select_db($database_nameprop, $nameprop);
  $Result1 = mysql_query($insertSQL, $nameprop) or die(mysql_error());
mysql_select_db($database_nameprop, $nameprop);
$query_rsApplyNow = "SELECT * FROM name_editprop";
$rsApplyNow = mysql_query($query_rsApplyNow, $nameprop) or die(mysql_error());
$row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);
$totalRows_rsApplyNow = mysql_num_rows($rsApplyNow);
?>
<!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>Untitled Document</title>
<script type="text/javascript">
function loadFields(theValue) {
         var props = theValue.split("|");
          var prop_id = props[0];
          var propAdd = props[1] ;
          var propPrice = props[2];
                      var town = props[3]
                      var postcode = props[4]
          document.getElementById('prop_id').value=prop_id;
          document.getElementById('Add1').value=propAdd;
                      document.getElementById('town').value=town;
                      document.getElementById('postcode').value=postcode;
          document.getElementById('RentalPrice').value='£' + propPrice +'/ per month';
</script>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<!-- Place the following code where you want to show the result of the property selection --><table width="100%" border="0" cellpadding="0">
  <tr>
    <td width="23%"><!-- the following code is just copied from your code -->
      <select name="Select Property" id="Select Property" onchange="loadFields(this.value)">
        <option value="select your property">select your property</option>
        <?php
do {
?>
        <option value="<?php echo $row_rsApplyNow['prop_id'] . '|' . $row_rsApplyNow['prop_add1'] . '|' . $row_rsApplyNow['rental_price'] . '|' . $row_rsApplyNow['town'] . '|' . $row_rsApplyNow['postcode'];?>"><?php echo $row_rsApplyNow['prop_id'] . " , " . $row_rsApplyNow['prop_add1']; ?></option>
        <?php
} while ($row_rsApplyNow = mysql_fetch_assoc($rsApplyNow));
  $rows = mysql_num_rows($rsApplyNow);
  if($rows > 0) {
      mysql_data_seek($rsApplyNow, 0);
            $row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);
?>
      </select></td>
    <td width="77%"> </td>
  </tr>
  <tr>
    <td>Property ID:</td>
    <td><input type="text" name="prop_id" id="prop_id" readonly="readonly" /></td>
  </tr>
  <tr>
    <td>Address</td>
    <td><input type="text" name="Add1" id="Add1" readonly="readonly" /></td>
  </tr>
  <tr>
    <td>Town</td>
    <td><input type="text" name="town" id="town" readonly="readonly" /></td>
  </tr>
  <tr>
    <td>Postcode</td>
    <td><label for="postcode"></label>
      <input type="text" name="postcode" id="postcode" readonly="readonly" /></td>
  </tr>
  <tr>
    <td>Rent</td>
    <td><input type="text" name="RentalPrice" id="RentalPrice" readonly="readonly" /></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellpadding="0">
      <tr>
        <td width="29%"><table align="center">
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Title:</td>
            <td><input type="text" name="Title" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">First Names:</td>
            <td><input type="text" name="First_Names" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Surname:</td>
            <td><input type="text" name="Surname" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DOB:</td>
            <td><input type="text" name="DOB" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DOBMonth:</td>
            <td><input type="text" name="DOBMonth" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DOBYear:</td>
            <td><input type="text" name="DOBYear" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Nationality:</td>
            <td><input type="text" name="Nationality" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Marital_Status:</td>
            <td><input type="text" name="Marital_Status" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DayNumber:</td>
            <td><input type="text" name="DayNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">EvenNumber:</td>
            <td><input type="text" name="EvenNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">MobNumber:</td>
            <td><input type="text" name="MobNumber" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Smoker:</td>
            <td><input type="text" name="Smoker" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">CurrentAdd:</td>
            <td><input type="text" name="CurrentAdd" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Status:</td>
            <td><input type="text" name="Status" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">PreviousAdd:</td>
            <td><input type="text" name="PreviousAdd" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Student:</td>
            <td><input type="text" name="Student" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">FinancialCCj:</td>
            <td><input type="text" name="FinancialCCj" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">FinancialArrears:</td>
            <td><input type="text" name="FinancialArrears" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">FinancialBankR:</td>
            <td><input type="text" name="FinancialBankR" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">FinancialNone:</td>
            <td><input type="text" name="FinancialNone" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">BankName:</td>
            <td><input type="text" name="BankName" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">AccountNum:</td>
            <td><input type="text" name="AccountNum" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">SortCode:</td>
            <td><input type="text" name="SortCode" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">BankDuration:</td>
            <td><input type="text" name="BankDuration" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">DebitCCCard:</td>
            <td><input type="text" name="DebitCCCard" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Electoral:</td>
            <td><input type="text" name="Electoral" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Next of kin:</td>
            <td><input type="text" name="next_of_kin" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right"> </td>
            <td><input type="submit" value="Insert record" /></td>
          </tr>
        </table></td>
        <td width="68%"> </td>
        <td width="3%"> </td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
    </table></td>
    </tr>
</table>
</form>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($rsApplyNow);
?>

Similar Messages

  • Can BO Enterprize SDK inserts records into user table

    From Infostore can we create a jsp script using Java SDK to inserts records into user table??
    Thanks
    Amar

    Hi Amar,
    I want to retrieve data/records from Infostore and insert into a user table using JSP script. Is it possible to do this?
    Infostore is a database used by BO Server. so any changes made in infostore through BO enterprise session is valid.
    Say u want to retrive on of report present in folder <my folder>.
    The you have to query for that. for eg.
    boinfostore.query("select * from ci_infoobjects where si_kind ='report' and si_foldername='my folder'");
    Create/add/insert any new information in infostore is done by functionalities provide by SDK.
    like adding the user or scheduling a report will add new object to infostore.
    If you directly access cms database and make any changes then , I am afraid you will end up with nightmare.
    So it is always recommneded to access infostore/ cms database only from bo session.
    For more information refer below link
    [http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/devsuite.htm]
    then under Contents
    BusinessObjects Enterprise SDK >>  COM developer guide and API reference >> Query Language Reference
    do revert if any queries
    Thanks,
    Praveen.

  • How to print form into pdf format using smart forms in abap

    please let me know how to print form into pdf format using smart forms in abap.
    Moderator message: please search for available information/documentation.
    Edited by: Thomas Zloch on Mar 25, 2011 2:04 PM

    Hi ,
    refer this link
    <removed by moderator>
    Regards,
    Dhina..
    Moderator message: please do not reply to questions that violate forum rules.
    Edited by: Thomas Zloch on Mar 25, 2011 2:04 PM

  • Create Quotation by sending different partner data to header & item table in a Report

    Hello all,
       Can any one please guide me how can I send different Partner data to Header & Item by running a Z Quotation Report in SE38. Actually Now I am able to create a Quotation which takes same Partner data of Header to Item data as well but my requirement is to send different Partner data to Header & Item in a quotation.
    If you have sample code for the same please do share. I will be thankful to you.
    Waiting for helpful suggestions.
    Regards
    -Ajay

    Hi Ajay,
    I was referring to CRM_PARTNER_MAINTAIN_MULTI_OW and CRM_PARTNER_MAINTAIN_SINGLE_OW function modules. A sample working code (written in badi) for an order below.
    l_wa_partner_com-partner_no  = l_v_bp_guid.
    l_wa_partner_com-partner_fct  = l_c_partner_fct.
    l_wa_field_names-fieldname = l_c_field_partner.
    INSERT l_wa_field_names INTO TABLE l_i_input_fields.
    l_wa_field_names-fieldname = l_c_field_fct.
    INSERT l_wa_field_names INTO TABLE l_i_input_fields.
    ** Update the order with new partners
    CALL FUNCTION 'CRM_PARTNER_MAINTAIN_SINGLE_OW'
    EXPORTING
    iv_ref_guid                    = is_orderadm_h_wrk-guid
    iv_ref_kind                    = l_c_ref_kind " Pass B here in u'r case
    is_partner_com            = l_wa_partner_com
    CHANGING
    ct_input_field_names   = l_i_input_fields
    EXCEPTIONS
    error_occurred             = 1
    OTHERS                      = 2.
    IF sy-subrc <> 0.
    ENDIF.
    Thanks,
    Faisal

  • How to  load data into user tables using DIAPIs?

    Hi,
    I have created an user table using UserTablesMD object.
    But I don't have know how to load data into this user table. I guess I have to use UserTable object for that. But I still don't know how to put some data in particular column.
    Can somebody please help me with this?
    I would appreciate if somebody can share their code in this regard.
    Thank you,
    Sudha

    You can try this code:
    Dim lRetCode As Long
    Dim userTable As SAPbobsCOM.UserTable
    userTable = pCompany.UserTables.Item("My_Table")
    'First row in the @My_Table table
    userTable.Code = "A1"
    userTable.Name = "A.1"
    userTable.UserFields.Fields.Item("U_1stF").Value = "First row value"
    userTable.Add()
    'Second row in the @My_Table table
    userTable.Code = "A2"
    userTable.Name = "A.2"
    userTable.UserFields.Fields.Item("U_1stF").Value = "Second row value"
    userTable.Add()
    This way I have added 2 lines in my table.
    Hope it helps
    Trinidad.

  • Build a sql query fro different table and insert into a table

    Hi I have a requirement ,
    i have some table 1 table which holds rules which rules i have to apply on the sql query
    2 table will hold table name and column name and transformation
    with these help of 2 tables i want to build a sql quey and the sql query need to be insert into another  table.

    Hi Karthick,
    I am not going to build Dynamic Data Model.
    i already have table 1 contains rules let's say COUNT,
    and another table contain source table name , column name , Target table name, Source Table name like that
    so with the help of these 2 tables i want to build Sql query and going to insert into 3rd table.

  • How to get the data from one table and insert into another table

    Hi,
    We have requirement to build OA page with the data needs to be populated from one table and on save data into another table.
    For the above requirement what the best way to implement in OAF.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    Thanks

    You can achieve this in many different ways, one is
    1. Create another VO based on the EO which is based on the dest table.
    2. At save, copy the contents of the source VO into the dest VO (see copy routine in dev guide).
    3. commiting the transaction will push the data into the dest table on which the dest VO is based.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    if by table you mean a DB table, then no, you can have a VO based on multiple EOs which will do DMLs accordingly.Thanks
    Tapash

  • How to read LONG RAW data from one  table and insert into another table

    Hello EVERYBODY
    I have a table called sound with the following attributes. in the music attribute i have stored some messages in the different language like hindi, english etc. i want to concatinate all hindi messages and store in the another table with only one attribute of type LONG RAW.and this attribute is attached with the sound item.
    when i click the play button of sound item the all the messages recorded in hindi will play one by one automatically. for that i'm doing the following.
    i have written the following when button pressed trigger which will concatinate all the messages of any selected language from the sound table, and store in another table called temp.
    and then sound will be played from the temp table.
    declare
         tmp sound.music%type;
         temp1 sound.music%type;
         item_id ITEM;
    cursor c1
    is select music
    from sound
    where lang=:LIST10;
    begin
         open c1;
         loop
              fetch c1 into tmp; //THIS LINE GENERATES THE ERROR
              temp1:=temp1||tmp;
              exit when c1%notfound;
         end loop;
    CLOSE C1;
    insert into temp values(temp1);
    item_id:=Find_Item('Music');
    go_item('music');
    play_sound(item_id);
    end;
    but when i'm clicking the button it generates the following error.
    WHEN-BUTTON-PRESSED TRIGGER RAISED UNHANDLED EXCEPTION ORA-06502.
    ORA-06502: PL/SQL: numeric or value error
    SQL> desc sound;
    Name Null? Type
    SL_NO NUMBER(2)
    MUSIC LONG RAW
    LANG CHAR(10)
    IF MY PROCESS TO SOLVE THE ABOVE PROBLEM IS OK THEN PLESE TELL ME THE SOLUTION FOR THE ERROR. OTHER WISE PLEASE SUGGEST ME,IF ANY OTHER WAY IS THERE TO SOLVE THE ABOVE PROBLEM.
    THANKS IN ADVANCE.
    D. Prasad

    You can achieve this in many different ways, one is
    1. Create another VO based on the EO which is based on the dest table.
    2. At save, copy the contents of the source VO into the dest VO (see copy routine in dev guide).
    3. commiting the transaction will push the data into the dest table on which the dest VO is based.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    if by table you mean a DB table, then no, you can have a VO based on multiple EOs which will do DMLs accordingly.Thanks
    Tapash

  • Program to upload csv file to internal table and insert into database table

    Hi I'm writing a program where I need to upload a csv file into an internal table using gui_upload, but i also need this program to insert the data into my custom database table using the split command.  Anybody have any samples to help, its urgent!

    Hi,
    Check this table may be it will give u an hint...
    REPORT z_table_upload LINE-SIZE 255.
    Data
    DATA: it_dd03p TYPE TABLE OF dd03p,
          is_dd03p TYPE dd03p.
    DATA: it_rdata  TYPE TABLE OF text1024,
          is_rdata  TYPE text1024.
    DATA: it_fields TYPE TABLE OF fieldname.
    DATA: it_file  TYPE REF TO data,
          is_file  TYPE REF TO data.
    DATA: w_error  TYPE text132.
    Macros
    DEFINE write_error.
      concatenate 'Error: table'
                  p_table
                  &1
                  &2
             into w_error
             separated by space.
      condense w_error.
      write: / w_error.
      stop.
    END-OF-DEFINITION.
    Field symbols
    FIELD-SYMBOLS: <table> TYPE STANDARD TABLE,
                   <data>  TYPE ANY,
                   <fs>    TYPE ANY.
    Selection screen
    SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
    PARAMETERS: p_file  TYPE localfile DEFAULT 'C:\temp\' OBLIGATORY,
                p_separ TYPE c DEFAULT ';' OBLIGATORY.
    SELECTION-SCREEN: END OF BLOCK b01.
    SELECTION-SCREEN: BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.
    PARAMETERS: p_table TYPE tabname OBLIGATORY
                                     MEMORY ID dtb
                                     MATCHCODE OBJECT dd_dbtb_16.
    SELECTION-SCREEN: END OF BLOCK b02.
    SELECTION-SCREEN: BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
    PARAMETERS: p_create TYPE c AS CHECKBOX.
    SELECTION-SCREEN: END OF BLOCK b03,
                      SKIP.
    SELECTION-SCREEN: BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
    PARAMETERS: p_nodb RADIOBUTTON GROUP g1 DEFAULT 'X'
                                   USER-COMMAND rg1,
                p_save RADIOBUTTON GROUP g1,
                p_dele RADIOBUTTON GROUP g1.
    SELECTION-SCREEN: SKIP.
    PARAMETERS: p_test TYPE c AS CHECKBOX,
                p_list TYPE c AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN: END OF BLOCK b04.
    At selection screen
    AT SELECTION-SCREEN.
      IF sy-ucomm = 'RG1'.
        IF p_nodb IS INITIAL.
          p_test = 'X'.
        ENDIF.
      ENDIF.
    At selection screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                field_name = 'P_FILE'
           IMPORTING
                file_name  = p_file.
    Start of selection
    START-OF-SELECTION.
      PERFORM f_table_definition USING p_table.
      PERFORM f_upload_data USING p_file.
      PERFORM f_prepare_table USING p_table.
      PERFORM f_process_data.
      IF p_nodb IS INITIAL.
        PERFORM f_modify_table.
      ENDIF.
      IF p_list = 'X'.
        PERFORM f_list_records.
      ENDIF.
    End of selection
    END-OF-SELECTION.
          FORM f_table_definition                                       *
    -->  VALUE(IN_TABLE)                                               *
    FORM f_table_definition USING value(in_table).
      DATA: l_tname TYPE tabname,
            l_state TYPE ddgotstate,
            l_dd02v TYPE dd02v.
      l_tname = in_table.
      CALL FUNCTION 'DDIF_TABL_GET'
           EXPORTING
                name          = l_tname
           IMPORTING
                gotstate      = l_state
                dd02v_wa      = l_dd02v
           TABLES
                dd03p_tab     = it_dd03p
           EXCEPTIONS
                illegal_input = 1
                OTHERS        = 2.
      IF l_state NE 'A'.
        write_error 'does not exist or is not active' space.
      ENDIF.
      IF l_dd02v-tabclass NE 'TRANSP' AND
         l_dd02v-tabclass NE 'CLUSTER'.
        write_error 'is type' l_dd02v-tabclass.
      ENDIF.
    ENDFORM.
          FORM f_prepare_table                                          *
    -->  VALUE(IN_TABLE)                                               *
    FORM f_prepare_table USING value(in_table).
      DATA: l_tname TYPE tabname,
            lt_ftab TYPE lvc_t_fcat.
      l_tname = in_table.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
           EXPORTING
                i_structure_name = l_tname
           CHANGING
                ct_fieldcat      = lt_ftab
           EXCEPTIONS
                OTHERS           = 1.
      IF sy-subrc NE 0.
        WRITE: / 'Error while building field catalog'.
        STOP.
      ENDIF.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = lt_ftab
        IMPORTING
          ep_table        = it_file.
      ASSIGN it_file->* TO <table>.
      CREATE DATA is_file LIKE LINE OF <table>.
      ASSIGN is_file->* TO <data>.
    ENDFORM.
          FORM f_upload_data                                            *
    -->  VALUE(IN_FILE)                                                *
    FORM f_upload_data USING value(in_file).
      DATA: l_file    TYPE string,
            l_ltext   TYPE string.
      DATA: l_lengt   TYPE i,
            l_field   TYPE fieldname.
      DATA: l_missk   TYPE c.
      l_file = in_file.
      l_lengt = strlen( in_file ).
      FORMAT INTENSIFIED ON.
      WRITE: / 'Reading file', in_file(l_lengt).
      CALL FUNCTION 'GUI_UPLOAD'
           EXPORTING
                filename = l_file
                filetype = 'ASC'
           TABLES
                data_tab = it_rdata
           EXCEPTIONS
                OTHERS   = 1.
      IF sy-subrc <> 0.
        WRITE: /3 'Error uploading', l_file.
        STOP.
      ENDIF.
    File not empty
      DESCRIBE TABLE it_rdata LINES sy-tmaxl.
      IF sy-tmaxl = 0.
        WRITE: /3 'File', l_file, 'is empty'.
        STOP.
      ELSE.
        WRITE: '-', sy-tmaxl, 'rows read'.
      ENDIF.
    File header on first row
      READ TABLE it_rdata INTO is_rdata INDEX 1.
      l_ltext = is_rdata.
      WHILE l_ltext CS p_separ.
        SPLIT l_ltext AT p_separ INTO l_field l_ltext.
        APPEND l_field TO it_fields.
      ENDWHILE.
      IF sy-subrc = 0.
        l_field = l_ltext.
        APPEND l_field TO it_fields.
      ENDIF.
    Check all key fields are present
      SKIP.
      FORMAT RESET.
      FORMAT COLOR COL_HEADING.
      WRITE: /3 'Key fields'.
      FORMAT RESET.
      LOOP AT it_dd03p INTO is_dd03p WHERE NOT keyflag IS initial.
        WRITE: /3 is_dd03p-fieldname.
        READ TABLE it_fields WITH KEY table_line = is_dd03p-fieldname
                             TRANSPORTING NO FIELDS.
        IF sy-subrc = 0.
          FORMAT COLOR COL_POSITIVE.
          WRITE: 'ok'.
          FORMAT RESET.
        ELSEIF is_dd03p-datatype NE 'CLNT'.
          FORMAT COLOR COL_NEGATIVE.
          WRITE: 'error'.
          FORMAT RESET.
          l_missk = 'X'.
        ENDIF.
      ENDLOOP.
    Log other fields
      SKIP.
      FORMAT COLOR COL_HEADING.
      WRITE: /3 'Other fields'.
      FORMAT RESET.
      LOOP AT it_dd03p INTO is_dd03p WHERE keyflag IS initial.
        WRITE: /3 is_dd03p-fieldname.
        READ TABLE it_fields WITH KEY table_line = is_dd03p-fieldname
                             TRANSPORTING NO FIELDS.
        IF sy-subrc = 0.
          WRITE: 'X'.
        ENDIF.
      ENDLOOP.
    Missing key field
      IF l_missk = 'X'.
        SKIP.
        WRITE: /3 'Missing key fields - no further processing'.
        STOP.
      ENDIF.
    ENDFORM.
          FORM f_process_data                                           *
    FORM f_process_data.
      DATA: l_ltext TYPE string,
            l_stext TYPE text40,
            l_field TYPE fieldname,
            l_datat TYPE c.
      LOOP AT it_rdata INTO is_rdata FROM 2.
        l_ltext = is_rdata.
        LOOP AT it_fields INTO l_field.
          ASSIGN COMPONENT l_field OF STRUCTURE <data> TO <fs>.
          IF sy-subrc = 0.
          Field value comes from file, determine conversion
            DESCRIBE FIELD <fs> TYPE l_datat.
            CASE l_datat.
              WHEN 'N'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                WRITE l_stext TO <fs> RIGHT-JUSTIFIED.
                OVERLAY <fs> WITH '0000000000000000'.           "max 16
              WHEN 'P'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                TRANSLATE l_stext USING ',.'.
                <fs> = l_stext.
              WHEN 'F'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                TRANSLATE l_stext USING ',.'.
                <fs> = l_stext.
              WHEN 'D'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                TRANSLATE l_stext USING '/.-.'.
                CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
                     EXPORTING
                          date_external = l_stext
                     IMPORTING
                          date_internal = <fs>
                     EXCEPTIONS
                          OTHERS        = 1.
              WHEN 'T'.
                CALL FUNCTION 'CONVERT_TIME_INPUT'
                     EXPORTING
                          input  = l_stext
                     IMPORTING
                          output = <fs>
                     EXCEPTIONS
                          OTHERS = 1.
              WHEN OTHERS.
                SPLIT l_ltext AT p_separ INTO <fs> l_ltext.
            ENDCASE.
          ELSE.
            SHIFT l_ltext UP TO p_separ.
            SHIFT l_ltext.
          ENDIF.
        ENDLOOP.
        IF NOT <data> IS INITIAL.
          LOOP AT it_dd03p INTO is_dd03p WHERE datatype = 'CLNT'.
          This field is mandant
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-mandt.
          ENDLOOP.
          IF p_create = 'X'.
            IF is_dd03p-rollname = 'ERDAT'.
              ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                            TO <fs>.
              <fs> = sy-datum.
            ENDIF.
            IF is_dd03p-rollname = 'ERZET'.
              ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                            TO <fs>.
              <fs> = sy-uzeit.
            ENDIF.
            IF is_dd03p-rollname = 'ERNAM'.
              ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                            TO <fs>.
              <fs> = sy-uname.
            ENDIF.
          ENDIF.
          IF is_dd03p-rollname = 'AEDAT'.
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-datum.
          ENDIF.
          IF is_dd03p-rollname = 'AETIM'.
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-uzeit.
          ENDIF.
          IF is_dd03p-rollname = 'AENAM'.
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-uname.
          ENDIF.
          APPEND <data> TO <table>.
        ENDIF.
      ENDLOOP.
    ENDFORM.
          FORM f_modify_table                                           *
    FORM f_modify_table.
      SKIP.
      IF p_save = 'X'.
        MODIFY (p_table) FROM TABLE <table>.
      ELSEIF p_dele = 'X'.
        DELETE (p_table) FROM TABLE <table>.
      ELSE.
        EXIT.
      ENDIF.
      IF sy-subrc EQ 0.
        FORMAT COLOR COL_POSITIVE.
        IF p_save = 'X'.
          WRITE: /3 'Modify table OK'.
        ELSE.
          WRITE: /3 'Delete table OK'.
        ENDIF.
        FORMAT RESET.
        IF p_test IS INITIAL.
          COMMIT WORK.
        ELSE.
          ROLLBACK WORK.
          WRITE: '- test only, no update'.
        ENDIF.
      ELSE.
        FORMAT COLOR COL_NEGATIVE.
        WRITE: /3 'Error while modifying table'.
        FORMAT RESET.
      ENDIF.
    ENDFORM.
          FORM f_list_records                                           *
    FORM f_list_records.
      DATA: l_tleng TYPE i,
            l_lasti TYPE i,
            l_offst TYPE i.
    Output width
      l_tleng = 1.
      LOOP AT it_dd03p INTO is_dd03p.
        l_tleng = l_tleng + is_dd03p-outputlen.
        IF l_tleng LT sy-linsz.
          l_lasti = sy-tabix.
          l_tleng = l_tleng + 1.
        ELSE.
          l_tleng = l_tleng - is_dd03p-outputlen.
          EXIT.
        ENDIF.
      ENDLOOP.
    Output header
      SKIP.
      FORMAT COLOR COL_HEADING.
      WRITE: /3 'Contents'.
      FORMAT RESET.
      ULINE AT /3(l_tleng).
    Output records
      LOOP AT <table> ASSIGNING <data>.
        LOOP AT it_dd03p INTO is_dd03p FROM 1 TO l_lasti.
          IF is_dd03p-position = 1.
            WRITE: /3 sy-vline.
            l_offst = 3.
          ENDIF.
          ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>.
          l_offst = l_offst + 1.
          IF is_dd03p-decimals LE 2.
            WRITE: AT l_offst <fs>.
          ELSE.
            WRITE: AT l_offst <fs> DECIMALS 3.
          ENDIF.
          l_offst = l_offst + is_dd03p-outputlen.
          WRITE: AT l_offst sy-vline.
        ENDLOOP.
      ENDLOOP.
    Ouptut end
      ULINE AT /3(l_tleng).
    ENDFORM.
    Regards,
    Joy.

  • Join multiple output tables of BAPI into new table

    Hi,
    In my model (VC 7.0), I have a BAPI which outputs two different tables. Tables have many multiple records. Each table has several fields and a common field also. I want to combine these tables into one table form. I used the following methods and result are :
    1. I tried to connect output tables to one table form but no success. Because table form allows only one table input.
    2. I put a combine operator for output tables. No success. Although they're common field and multiple records but table form shows only one record? Where are the other record ?
    3. I put a union operator  for output tables. No success. Because union operator output only the common field. But I need the other fields from output tables in my table form.
    Will you please suggest what are the options available with me for joing output of both tables. I think combine operator should solve.
    Regards,
    Yi&#287;it

    Hi,
    use this link to get your answer:
    Join two Table output to new table
    Otherwise you can try with this:
    1. Drag signal out from the first table. Select all the fields which you want to be pass in the final table.Make the first table as multiple selection one.
    2. Create one button in toolbar for the first table and give some proper name in action property.
    3. mentioned the same action name in the link between the signal out and the first table.
    4. follow the same steps for the second table also.
    5. then from compose choose two signal ins and drag them on the story board. Then give the same name as you have given the signal outs name.
    6. Mention all the fields as you have mentioned in the siganl outs.
    7. Add a combine operator with both the signal ins and combine a table with the outport of the combine operator.
    Save and deploy. I hope it will help you.
    Here, you have to select the rows which you want to visualize in the final output table.
    Regards,
    Nutan
    regards,
    Nutan

  • How to Getting 10lack records from 2 tables and share  into 10 tables

    Hi Experts,
    i have some special requirement about counting records before we we procees them in to intenal table.
    here is the sample code .
    **Needed to get users for ref users data
    DATA: BEGIN OF gt_usr02 OCCURS 0,
            bname LIKE usr02-bname,
          END OF gt_usr02.
    DATA:g_wa_usr02 LIKE LINE OF gt_usr02.
    **Needed To get reference users data
    DATA: BEGIN OF gt_usrefus OCCURS 0,
            bname LIKE usrefus-bname,
            refuser LIKE usrefus-refuser,
            END OF gt_usrefus.
    DATA:g_wa_usrefus LIKE LINE OF gt_usrefus.
    SELECTION-SCREEN :BEGIN OF BLOCK blk1 WITH FRAME TITLE text-000.
    SELECT-OPTIONS : s_user FOR usr02-bname.
    SELECTION-SCREEN :END OF BLOCK blk1.
    START-OF-SELECTION.
    REFRESH:gt_usr02,gt_usrefus.
    CLEAR:gt_usr02,gt_usrefus
    CLEAR:g_wa_usr02,g_wa_usrefus ,
    SELECT bname FROM usr02 INTO TABLE
           gt_usr02 WHERE bname IN s_user. "say suppose "*" in s_user
    1.Here i need to get no of records befor we are getting data from this select statement
    basically i need to know the no of records (like count (sy-dbcnt) with same condition like below.
    IF NOT gt_usr02 IS INITIAL.
        SELECT bname refuser FROM usrefus INTO TABLE  gt_usrefus
         FOR ALL ENTRIES IN  gt_usr02
        WHERE bname =  gt_usr02-bname AND refuser <> space.
      ENDIF.
    2.if i found no of records based on that  i have to broke those records into diff tables
    say i found 10,000 records ,that time i have spilt those 10,000 records into 10 tables(Similar strcture like table gt_usrefus ) with 1000 records each .
    Can you help us.this requirement is for avoiding memory issues.

    Hi nagraju102,
    - please try to post code formatted as code
    - splitting a table of 10000 records into 10 tables of 1000 records will use not less memory at all, even a little bit more for the administrative overhead
    - the numer of lines in an internal table can  determinde used system function lines( itab )
    - you can create an internal table of references and then create any number of internal tables,
    data:
      lt_tabref type table of ref to data.
    field-symbols:
      <table> type  table,
      <tabref> type ref to data.
    DO 10 TIMES.
      append initial line to lt_tabref assigning <tabref>.
      create data <tabref> type table of usrefus.
      assign <tabref>->* to <table>.
      perform fill_table changing  <table>."fill this table as you prefer
    ENDDO.
    Here you have 10 internal tables with USREFUS structure.
    Regards,
    Clemens

  • Selecting Records from 125 million record table to insert into smaller table

    Oracle 11g
    I have a large table of 125 million records - t3_universe.  This table never gets updated or altered once loaded,  but holds data that we receive from a lead company.
    I need to select records from this large table that fit certain demographic criteria and insert those into a smaller table - T3_Leads -  that will be updated with regard to when the lead is mailed and for other relevant information.
    My question is what is the best (fastest) approach to select records from this 125 million record table to insert into the smaller table.  I have tried a variety of things - views, materialized views, direct insert into smaller table...I think I am probably missing other approaches.
    My current attempt has been to create a View using the query that selects the records as shown below.  Then use a second query that inserts into T3_Leads from this View V_Market.  This is very slow. Can I just use an Insert Into T3_Leads with this query - it did not seem to work with the WITH clause?    My Index on the large table is t3_universe_composite and includes zip_code, address_key, household_key. 
    CREATE VIEW V_Market  as
    WITH got_pairs    AS  
         SELECT /*+ INDEX_FFS(t3_universe t3_universe_composite) */  l.zip_code, l.zip_plus_4, l.p1_givenname, l.surname, l.address, l.city, l.state, l.household_key, l.hh_type as l_hh_type, l.address_key, l.narrowband_income, l.p1_ms, l.p1_gender, l.p1_exact_age, l.p1_personkey, e.hh_type as filler_data, 1.p1_seq_no, l.p2_seq_no 
         ,      ROW_NUMBER () OVER ( PARTITION BY  l.address_key 
                                      ORDER BY      l.hh_verification_date  DESC 
                      ) AS r_num   
         FROM   t3_universe  e   
         JOIN   t3_universe  l  ON   
                l.address_key  = e.address_key
                AND l.zip_code = e.zip_code
              AND   l.p1_gender != e.p1_gender
                 AND   l.household_key != e.household_key         
                 AND  l.hh_verification_date  >= e.hh_verification_date 
      SELECT  * 
      FROM  got_pairs
      where l_hh_type !=1 and l_hh_type !=2 and filler_data != 1 and filler_data != 2 and zip_code in (select * from M_mansfield_02048) and p1_exact_age BETWEEN 25 and 70 and narrowband_income >= '8' and r_num = 1
    Then
    INSERT INTO T3_leads(zip, zip4, firstname, lastname, address, city, state, household_key, hh_type, address_key, income, relationship_status, gender, age, person_key, filler_data, p1_seq_no, p2_seq_no)
    select zip_code, zip_plus_4, p1_givenname, surname, address, city, state, household_key, l_hh_type, address_key, narrowband_income, p1_ms, p1_gender, p1_exact_age, p1_personkey, filler_data, p1_seq_no, p2_seq_no
    from V_Market;

    I had no trouble creating the view exactly as you posted it.  However, be careful here:
    and zip_code in (select * from M_mansfield_02048)
    You should name the column explicitly rather than select *.  (do you really have separate tables for different zip codes?)
    About the performance, it's hard to tell because you haven't posted anything we can use, like explain plans or traces but simply encapsulating your query into a view is not likely to make it any faster.
    Depending on the size of the subset of rows you're selecting, the /*+ INDEX hint may be doing your more harm than good.

  • Fetch data from one table and insert into two tables in desired format

    I have similar to the following data in a table and it is not normalized. The groupID is being used to group two records of similar nature.
    DECLARE @OldDoc TABLE (oldDocID INT, groupID INT, deptID INT)
    INSERT INTO @OldDoc (oldDocID, groupID) VALUES (1, NULL, 111),(2,NULL,111),(3,1,111),(4,NULL,333),(5,1,222),(6,NULL,333),(7,2,222),(8,2,333),(9,NULL,111),(10,3,222),(11,NULL,333),(12,3,444)
    I need to process the data from the above table (@OldDoc) and write into two new tables (@NewDoc and @NewDocGroup) as follows.
    oldDocID should be stored as newDocID when inserting to @NewDoc table. Only records with groupID NULL and one record (first one) per group should be considered (For example, oldDocID 5 is not considered as 3 and 5 belong to the same groupID 1) for insertion. 
    DECLARE @NewDoc TABLE (newDocID INT)
    INSERT INTO @NewDoc (newDocID) VALUES (1),(2),(3),(4),(6),(7),(9),(10),(11)
    All records from @OldDoc should be considered for insertion into @NewDocGroup table. OldDocID is inserted as NewDocID and deptID is as-is. Instead of groupID, the ID of the first record in the 
    group should be considered as parentNewDocID (For example, 3 is considered as parentNewDocID for newDocID 5 as 3 and 5 belong to the same groupID in @OldDoc table) for the newDocID.
    DECLARE @NewDocGroup (newDocID INT, parentNewDocID INT, deptID INT)
    INSERT INTO @NewDocGroup (newDocID, parentNewDocID, deptID) VALUES (1,1,111),(2,2,111),(3,3,111),(4,4,333),(5,3,222),(6,6,333),(7,7,222),(8,7,333),(9,9,111),(10,10,222),(11,11,333),(12,10,444)
    How do I accomplish the above using SQL ? Thanks for the help.

    >> I have similar to the following data in a table and it is not normalized. The group_id is being used to group two records [sic] of similar nature. <<
    Rows are not records. Tables have to have a key by definition. You do not do math with identifiers, so they should not be numeric. Let's ignore that error for now. In short, you are posting garbage. If you had followed Forum Netiquette, would you have posted
    this? 
    CREATE TABLE Old_Documents
    (old_doc_id INTEGER NOT NULL PRIMARY KEY, 
     group_id INTEGER, 
     dept_nbr INTEGER NOT NULL
       REFERENCES Departments (dept_nbr));
    INSERT INTO Old_Documents(old_doc_id, group_id, dept_nbr) 
    VALUES  (1, NULL, 111), 
    (2, NULL, 111), 
    (3, 1, 111), 
    (4, NULL, 333), 
    (5, 1, 222), 
    (6, NULL, 333), 
    (7, 2, 222), 
    (8, 2, 333), 
    (9, NULL, 111), 
    (10, 3, 222), 
    (11, NULL, 333), 
    (12, 3, 444);
    >> I need to process the data from the above table (Old_Documents) and write into two new tables (New_Documents and New_Documents_Groups) as follows. <<
    Just like punch cards and mag tape data processing! Being old and being new are a status, not another kind of entity. But that is how mag tapes work. And you even use the verb "fetch" from tape files. This design flaw is called  attribute splitting.
    Do you have a Male_Personnel and Female_Personnel table? NO! It is just Personnel! 
    >> old_doc_id should be stored as new_doc_id when inserting to New_Documents table. Only records [sic] with group_id NULL and one record [sic] (first [sic; no ordering in a table] one) per group should be considered (For example, old_doc_id 5 is not considered
    as 3 and 5 belong to the same group_id =1) for insertion. <<
    Think about your punch card mindset. Why did you physically materialize that redundant New_Documents table? Let me answer that: this is how you work with punch cards! In SQL we use a VIEW:
    CREATE VIEW New_Documents (new_doc_id)
    AS 
    SELECT old_doc_id 
      FROM Old_Documents;
    >> All records [sic] from Old_Documents should be considered for insertion into New_Documents_Groups table. The old_doc_id is inserted as new_doc_id and dept_nbr is as-is. Instead of group_id, the ID [sic: which identifier??] of the first [sic: tables
    have no ordering like a deck of punch cards] record [sic] in the group should be considered as parent_new_doc_id (For example, 3 is considered as parent_new_doc_id for new_doc_id 5 as 3 and 5 belong to the same group_id in Old_Documents table) for the new_doc_id.
    <<
    Why not use 5 as the parent? My guess is that you are trying to form equivalence classes. See:
    https://www.simple-talk.com/content/print.aspx?article=2020
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Fetch data from two tables and insert into one table

    I have similar to the following data in two tables (@Plant, @PlantDirector) and need to consolidate into one table (@PlantNew) as follows.
    DECLARE @Plant TABLE (PlantID INT, PlantName VARCHAR(100))
    INSERT INTO @Plant (PlantID, PlantName) VALUES (1, 'Name One'),(2, 'Name Two'),(3, 'Name Three'),(4, 'Name Four'),(5, 'Name Five'),(6, 'Name Six')
    Director data for the Plants exist in the following table. Assistant value 1 means Assistant Director and 0 means Director. 
    Data exists only for subset of plants and a Plant may have one or both roles.
    DECLARE @PlantDirector TABLE (PlantID INT, PlantDirectorID INT, Assistant bit)
    INSERT INTO @PlantDirector (PlantID, PlantDirectorID, Assistant) VALUES (2, 111, 1),(2, 222, 0),(4, 333, 0),(6,444,1)
    The above data needs to be inserted into one table (@PlantNew) as follows: 
    PlantID in @Plant table is IDENTITY value and needs to be inserted as-is into this table.
    PlantDirExists will get a value of 1 if at least one record exists in @PlantDirector table for a PlantID. PlantAssistantDirID and PlantDirID should be set to the corresponding PlantDirID or NULL appropriately depending on the data.
    DECLARE @PlantNew TABLE (PlantID INT, PlantName VARCHAR(100), PlantDirExists bit, PlantAssistantDirID INT, PlantDirID INT)
    INSERT INTO @PlantNew (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID)
    VALUES (1, 'Name One', 0, NULL, NULL),(2, 'Name Two', 1, 111, 222),(3, 'Name Three', 0, NULL, NULL),(4, 'Name Four', 1, NULL, 333),(5, 'Name Five', 0, NULL, NULL),(6, 'Name Six',1, 444, NULL)
    How do I achieve the above using SQL ? Thanks.

    like this
    INSERT @PlantNew  (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID) 
    SELECT p.PlantID,
    p.PlantName,
    CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
    PlantAssistantDirID,
    PlantDirID
    FROM @Plant p
    LEFT JOIN (SELECT PlantID,
    MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
    MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
    @PlantDirector
    GROUP BY PlantID)pd
    ON pd.PlantID = p.PlantID
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
    You're missing a FROM
    insert into @PlantNew
    SELECT p.PlantID,
    p.PlantName,
    CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
    PlantAssistantDirID,
    PlantDirID
    FROM @Plant p
    LEFT JOIN (SELECT PlantID,
    MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
    MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
    from @PlantDirector
    GROUP BY PlantID)pd
    ON pd.PlantID = p.PlantID

  • Read table context data into Internal table

    Hi All,
    I created a table and filled it with values and bind it to output.
    i have a field in ouput when i change the value in the output i need to change the values in my table.
    how to get the entie table(table context node ) into my method.
    is it possible to get the output table data when "On action " event is triggered.

    Hello.
    I guess you want to do that with Web Dynpro.
    So you need a function which is called, when your click-event is triggered.
    And within your function you need something like that:
    DATA lo_node_of_table TYPE REF TO if_wd_context_node.
    DATA lo_some_other_node TYPE REF TO if_wd_context_node.
    DATA lo_element TYPE REF TO if_wd_context_element.
    DATA ld_counter TYPE i.
    DATA ld_value TYPE i.
    DATA ld_sum TYPE i.
    lo_node_of_table = wd_context->path_get_node( path = `PATH_TO.CONTEXT_NODE` ).
    ld_counter = lo_node_of_table->get_element_count( ).
      DO ld_counter TIMES.
        lo_element = lo_nd_in->get_element( index = sy-index ).
        lo_element->get_attribute(
          EXPORTING name = 'FIELD_NAME'
            IMPORTING value = ld_value ).
        ld_sum = ld_sum + ld_value.
      ENDDO.
    lo_some_other_node->set_attribute( name = 'SUM_OF_SOMETHING' value = ld_sum ).
    Please reply if you meant something else.
    Regards
    Thomas

Maybe you are looking for

  • SRM 5.0: CLEAN_REQREQ_UP, BBP_REQEQ_TRANSFER and Webmonitor

    Hi SDN, we are on SRM 5.0 SP15. Classic Scenario with MM Backend. We have some issues with the webmoitoring. We have the clean job clean_reqreq_up running in 10 minutes intervals. Also we have bbp_get_status_2 every 20 minutes. Quite often we have re

  • Safari 2.0.2 - Flash Issues

    I've got a bit of a problem here. You see, I just had Comcast High Speed Internet installed in my house. It's a secured network and only my laptop and my mom's laptop can use the signal, so it's not a lack of bandwidth. While the guy was here install

  • Approving a role removal

    Hi, I created a role and added an approver, I would like the same approver/approvers to be required to approve not only when the role is granted but also when the role is removed from a user, what is the easiest way to implement this? Thanks in advan

  • Where are flash player parameters stored?

    Hello, when we modifiy our parameters for flash player here: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager05.htm l where are these parameters stored in the computer? because i want to delpoy my parameters on all

  • Intermittent Messages App after mountain lion upgrade

    help! it keeps on disconnecting me on AIM and other accounts -internet connection is OK