问:
Form input values not received in Javascript variables
I am working on a node.js project and i'm currently working on the login and sign up pages .
But somehow when i try to access the values of the text inputs of the form in the console it seems the values are not stored in the variables assigned to the various event listeners i had setup . There arent any errors in the console nor do i get any warnings in VS Code.

Here is the js file retrieving the form values:

```<code>```//set up event listeners
const form = document.getElementById("sign_up")
const username = document.getElementById("user_name").value
const mail = document.getElementById("mail").value
const residence = document.getElementById("residence").value
const password = document.getElementById("password").value
const repeat  = document.getElementById("repeat").value

//retrieve form data
form.onsubmit=async (event)=>{
    event.preventDefault()
    console.log("the form works!")

    //check if the passwords match
    if (password !== repeat){
        alert("passwords do not match")
    }else{
        //retrieve the data and submit form
        const result = await fetch('/api/register',{
            method: 'POST',
            headers:{
                'Content-Type':'application/json'
            },
            body:JSON.stringify({
                username,
                mail,
                residence,
                password,
                repeat
            })
        }).then(res=>{
            res.json()
        })
    }
}```
</code>```

Here is the form, i am using the ejs templating engine

```<code>```

                <form class="form" id="sign_up" method="get">

                    Name
                    <input type="text"  id="user_name" name="customer_name" required />

                      Email
                      <input type="text"  id="mail" name="customer_mail" required />

                      Residence
                      <input type="text"  id="residence" name="customer_residence" required />

                      Password
                      <input type="password"  id="password" name="customer_password" required />

                      Repeat Password
                      <input type="password" name="repeat_password" id="repeat" required />

                        <input class="login_form-checkbox" type="checkbox">
                        I've read and accepted the Terms & Conditions
                        <input type="submit" class="login_form-button"value="Create my account">

Already have an account? Sign In

                </form>

```
</code>```

Could someone please point out to me what the issue may be ?
i have cleard my browser cache, tried using different browsers and the result is still the same.

答:
Move all the const assignments that read value of a HTMLInputElement into the submit event handler. Otherwise with your current code you are assigning them at runtime (e.g. when the JS is parsed and executed), and their values will not change anymore.

What you want is to access this values at the moment when the form is about to be submitted instead.

```<code>form.onsubmit=async (event)=>{
  const username = document.getElementById("user_name").value;
  const mail = document.getElementById("mail").value;
  const residence = document.getElementById("residence").value;
  const password = document.getElementById("password").value;
  const repeat  = document.getElementById("repeat").value;

  // Rest of the logic here
}
</code>```

Body:
I am working on a node.js project and i'm currently working on the login and sign up pages .
But somehow when i try to access the values of the text inputs of the form in the console it seems the values are not stored in the variables assigned to the various event listeners i had setup . There arent any errors in the console nor do i get any warnings in VS Code.

Here is the js file retrieving the form values:

```//set up event listeners
const form = document.getElementById("sign_up")
const username = document.getElementById("user_name").value
const mail = document.getElementById("mail").value
const residence = document.getElementById("residence").value
const password = document.getElementById("password").value
const repeat  = document.getElementById("repeat").value

//retrieve form data
form.onsubmit=async (event)=>{
    event.preventDefault()
    console.log("the form works!")

    //check if the passwords match
    if (password !== repeat){
        alert("passwords do not match")
    }else{
        //retrieve the data and submit form
        const result = await fetch('/api/register',{
            method: 'POST',
            headers:{
                'Content-Type':'application/json'
            },
            body:JSON.stringify({
                username,
                mail,
                residence,
                password,
                repeat
            })
        }).then(res=>{
            res.json()
        })
    }
}```

Here is the form, i am using the ejs templating engine

```  <!-- FORM STARTS -->
            <div class="login_form" >
                <form class="form" id="sign_up" method="get">
                  <div class="form_input">
                    <label>Name</label>
                    <input type="text"  id="user_name" name="customer_name" required />
                  </div>

                  <div class="form_input">
                      <label>Email</label>
                      <input type="text"  id="mail" name="customer_mail" required />
                    </div>

                    <div class="form_input">
                      <label>Residence</label>
                      <input type="text"  id="residence" name="customer_residence" required />
                    </div>
                    <div class="form_input">
                      <label>Password</label>
                      <input type="password"  id="password" name="customer_password" required />
                    </div>
                    <div class="form_input">
                      <label>Repeat Password</label>
                      <input type="password" name="repeat_password" id="repeat" required />
                    </div>
                    <div class="login_form-terms">
                        <hr>
                        <input class="login_form-checkbox" type="checkbox">
                        <label for="">I've read and accepted the <span>Terms & Conditions</span> </label>
                        <input type="submit" class="login_form-button"value="Create my account">
                    </div>
                    <div class="login_form-sign-in-option">
                        <p>Already have an account? <a>Sign In</a></p>
                    </div>

                </form>
              </div>
              <!-- FORM ENDS -->
```

Could someone please point out to me what the issue may be ?
i have cleard my browser cache, tried using different browsers and the result is still the same.

Body:
Move all the const assignments that read value of a HTMLInputElement into the submit event handler. Otherwise with your current code you are assigning them at runtime (e.g. when the JS is parsed and executed), and their values will not change anymore.

What you want is to access this values at the moment when the form is about to be submitted instead.

form.onsubmit=async (event)=>{
  const username = document.getElementById("user_name").value;
  const mail = document.getElementById("mail").value;
  const residence = document.getElementById("residence").value;
  const password = document.getElementById("password").value;
  const repeat  = document.getElementById("repeat").value;

  // Rest of the logic here
}


来源: stackexchange

问:
How to make nuget package:moderenwpfui generate only needed language files.(WPF project)
How to make nuget package:moderenwpfui generate only needed language files.

The repository for this nuget package is https://github.com/Kinnara/ModernWpf .

When I generate my app, a lot of language files will be generated. Is there a way to generate only the language I need or preset the language file to the language I use?

The following are all the files generated in the Debug directory, the one without the suffix is the folder, the folder contains the dll library for the language files

```<code>af-ZA
am-ET
ar-SA
az-Latn-AZ
be-BY
bg-BG
bn-BD
bs-Latn-BA
ca-ES
cs-CZ
da-DK
de-DE
dotnetCampus.FileDownloader.dll
el-GR
en-GB
es-ES
es-MX
et-EE
eu-ES
fa-IR
fi-FI
file
fr-CA
fr-FR
gl-ES
ha-Latn-NG
he-IL
hi-IN
hr-HR
hu-HU
ICSharpCode.SharpZipLib.dll
ICSharpCode.SharpZipLib.pdb
id-ID
is-IS
it-IT
ja-JP
ka-GE
kk-KZ
km-KH
kn-IN
ko-KR
lo-LA
lt-LT
lv-LV
Microsoft.Web.WebView2.Core.dll
Microsoft.Web.WebView2.WinForms.dll
Microsoft.Web.WebView2.Wpf.dll
mk-MK
ml-IN
ModernWpf.Controls.dll
ModernWpf.dll
ms-MY
nb-NO
nl-NL
nn-NO
myapp.exe
myapp.exe.config
myapp.pdb
myapp.xml
pl-PL
pt-BR
pt-PT
ro-RO
ru-RU
runtimes
sk-SK
sl-SI
sq-AL
sr-Latn-RS
sv-SE
sw-KE
System.Drawing.Common.dll
System.ValueTuple.dll
ta-IN
te-IN
th-TH
tr-TR
uk-UA
uz-Latn-UZ
vi-VN
WPFUI.dll
zh-CN
zh-TW
</code>```

答:
Under Project>References you will find ModernWpf and ModernWpf.Controls. You need to set the property Copy Local to False for both of them.

Before you do that, backup these files and copy them manually to debug folder after doing the above steps.

```<code>ModernWpf.Controls.dll
ModernWpf.dll
</code>```

You will get errors if you don't do this.

ContentLicense: CC BY-SA 4.0

Body:
How to make nuget package:moderenwpfui generate only needed language files.

The repository for this nuget package is https://github.com/Kinnara/ModernWpf .

When I generate my app, a lot of language files will be generated. Is there a way to generate only the language I need or preset the language file to the language I use?

The following are all the files generated in the Debug directory, the one without the suffix is the folder, the folder contains the dll library for the language files

af-ZA
am-ET
ar-SA
az-Latn-AZ
be-BY
bg-BG
bn-BD
bs-Latn-BA
ca-ES
cs-CZ
da-DK
de-DE
dotnetCampus.FileDownloader.dll
el-GR
en-GB
es-ES
es-MX
et-EE
eu-ES
fa-IR
fi-FI
file
fr-CA
fr-FR
gl-ES
ha-Latn-NG
he-IL
hi-IN
hr-HR
hu-HU
ICSharpCode.SharpZipLib.dll
ICSharpCode.SharpZipLib.pdb
id-ID
is-IS
it-IT
ja-JP
ka-GE
kk-KZ
km-KH
kn-IN
ko-KR
lo-LA
lt-LT
lv-LV
Microsoft.Web.WebView2.Core.dll
Microsoft.Web.WebView2.WinForms.dll
Microsoft.Web.WebView2.Wpf.dll
mk-MK
ml-IN
ModernWpf.Controls.dll
ModernWpf.dll
ms-MY
nb-NO
nl-NL
nn-NO
myapp.exe
myapp.exe.config
myapp.pdb
myapp.xml
pl-PL
pt-BR
pt-PT
ro-RO
ru-RU
runtimes
sk-SK
sl-SI
sq-AL
sr-Latn-RS
sv-SE
sw-KE
System.Drawing.Common.dll
System.ValueTuple.dll
ta-IN
te-IN
th-TH
tr-TR
uk-UA
uz-Latn-UZ
vi-VN
WPFUI.dll
zh-CN
zh-TW

Body:
Under Project>References you will find ModernWpf and ModernWpf.Controls. You need to set the property Copy Local to False for both of them.

Before you do that, backup these files and copy them manually to debug folder after doing the above steps.

ModernWpf.Controls.dll
ModernWpf.dll

You will get errors if you don't do this.


问:
Equivalent of mysql_real_escape_string()
In MySQL there is the mysql_real_escape_string function.
Is there an such for MS SQL to correctly handle strings like this one?
SELECT * FROM MyTable WHERE Phrase='Mr Charlie's dog's dog and Mrs Molly's cat's cat plus Chris' bicycle' AND Item='wood';

I use Microsoft SQL

```<code>#include <sqlext.h>
#include <sqltypes.h>
#include <sql.h>
</code>```

答:
Rather than composing a query as a string, write a parameterised query and supply whatever string as the parameter.

You don't say what sql library you use, but it'd look something like this

```<code>void prepare_find(pqxx::connection_base &c)
{
  c.prepare(
        "find",
        "SELECT * FROM MyTable WHERE Phrase = $1 AND Item = $2");
}

pqxx::result execute_find(
  pqxx::transaction_base &t, std::string phrase, std::string item)
{
  return t.exec_prepared("find", phrase, item);
}
</code>```

Body:
In MySQL there is the mysql_real_escape_string function.
Is there an such for MS SQL to correctly handle strings like this one?
SELECT * FROM MyTable WHERE Phrase='Mr Charlie's dog's dog and Mrs Molly's cat's cat plus Chris' bicycle' AND Item='wood';

I use Microsoft SQL

#include <sqlext.h>
#include <sqltypes.h>
#include <sql.h>

Body:
Rather than composing a query as a string, write a parameterised query and supply whatever string as the parameter.

You don't say what sql library you use, but it'd look something like this

void prepare_find(pqxx::connection_base &c)
{
  c.prepare(
        "find",
        "SELECT * FROM MyTable WHERE Phrase = $1 AND Item = $2");
}

pqxx::result execute_find(
  pqxx::transaction_base &t, std::string phrase, std::string item)
{
  return t.exec_prepared("find", phrase, item);
}


问:
How to automate release notes using GIT merge descriptions
All,

In our organization we are trying to automate generating RELEASE NOTES using GIT Merge requests.
Is there any better way to do this, preferably looking for a solution in NodeJS.

答:
Take a look at the semantic release plugin for GitLab: https://github.com/semantic-release/gitlab

Which implements the popular https://github.com/semantic-release/semantic-release project.


问:
How to remove bottom padding of List and ScrollView in SwiftUI
I'd like to remove bottom padding, the white space between the red space. Is there any way to achieve it?

Test Code:

```<code>struct ContentView: View {
    var body: some View {
        return NavigationView {
            VStack {
                // the same result with using List instead of ScrollView
                ScrollView {
                    ForEach(1..<100) { index in
                        HStack {
                            Spacer()
                            Text("\(index)")
                            Spacer()
                        }
                    }
                }.background(Color.red)
                HStack {
                    Spacer()
                    Text("Test")
                    Spacer()
                }
                .background(Color.red)
            }
            .navigationBarTitle(Text("Test"), displayMode: .inline)
        }
    }
}
</code>```

答:
Just use GeometryReader</p>
```<code>@State var contentSize: CGSize = .zero

ScrollView {
    YourContentView()
        .overlay(
            GeometryReader { geo in
                Color.clear.onAppear {
                    contentSize = geo.size
                }
            }
        )
}
.frame(maxWidth: .infinity, maxHeight: contentSize.height)
</code>```

Body:
I'd like to remove bottom padding, the white space between the red space. Is there any way to achieve it?

Test Code:

struct ContentView: View {
    var body: some View {
        return NavigationView {
            VStack {
                // the same result with using List instead of ScrollView
                ScrollView {
                    ForEach(1..<100) { index in
                        HStack {
                            Spacer()
                            Text("\(index)")
                            Spacer()
                        }
                    }
                }.background(Color.red)
                HStack {
                    Spacer()
                    Text("Test")
                    Spacer()
                }
                .background(Color.red)
            }
            .navigationBarTitle(Text("Test"), displayMode: .inline)
        }
    }
}

Body:
Just use GeometryReader

@State var contentSize: CGSize = .zero

ScrollView {
    YourContentView()
        .overlay(
            GeometryReader { geo in
                Color.clear.onAppear {
                    contentSize = geo.size
                }
            }
        )
}
.frame(maxWidth: .infinity, maxHeight: contentSize.height)


问:
Stored procedure Is throwing ORA-20000: ORA-00913: too many values
The below code is used to create the stored procedure and this is how the stored procedure is called. Stored procedure is throwing ORA-20000: ORA-00913: too many values</p>
```<code>BEGIN EDW_ODS_DELETE_RECORDS_PKG.MAIN('EDWFIN', 'PSP_LABOR_ADJUSTMENTS_F'); END;
</code>```
```<code>create or replace
    PACKAGE BODY         "EDW_ODS_DELETE_RECORDS_PKG" AS

    CON_EDW_IUD_FLAG  CONSTANT CHAR := 'D';
    CON_CURRENT_FLAG  CONSTANT CHAR := 'N';
    CON_DELETED_FLAG  CONSTANT CHAR := 'Y';
    PROCEDURE main (table_schema_in   IN VARCHAR2, target_table_alias_in   IN VARCHAR2) AS
      v_source_schema       VARCHAR2(30);
      v_source_table_name   VARCHAR2(30);
      v_target_schema       VARCHAR2(30);
      v_target_table_name   VARCHAR2(30);
      v_source_table_key    VARCHAR2(1000);
      v_target_table_key    VARCHAR2(1000);
      v_table_type          VARCHAR2(20);
      v_last_deleted_date   DATE;
      v_delete_control_id   NUMBER := 0;
      v_target_table_alias  VARCHAR2(30);
      v_arc_target_table_name   VARCHAR2(30);
      BEGIN
          SELECT SOURCE_TABLE_SCHEMA, SOURCE_TABLE_NAME, SOURCE_TABLE_KEY,
                  TARGET_TABLE_SCHEMA, TARGET_TABLE_NAME, TARGET_TABLE_KEY,
                  TABLE_TYPE, LAST_DELETED_DATE, DELETE_CONTROL_ID,
                  TARGET_TABLE_ALIAS,
                  ARC_TARGET_TABLE_NAME
                  INTO
                  v_source_schema, v_source_table_name, v_source_table_key,
                  v_target_schema, v_target_table_name, v_target_table_key,
                  v_table_type, v_last_deleted_date, v_delete_control_id,
                  v_target_table_alias,
                  v_arc_target_table_name
                  FROM EDW_ODS_DWH_DELETES_CONTROL
          WHERE target_table_schema = table_schema_in AND target_table_alias = target_table_alias_in;

          DBMS_OUTPUT.PUT_LINE ('Values : ' || v_last_deleted_date);

          v_source_table_key := REPLACE(v_source_table_key, '~', ' || ''~'' || ');
          v_target_table_key := REPLACE(v_target_table_key, '~', ' || ''~'' || ');

          IF v_table_type = 'FACT' THEN
            UPDATE_FACT_TABLES (v_source_schema, v_source_table_name, v_source_table_key,
                                      v_target_schema, v_target_table_name, v_target_table_key,
                                      v_last_deleted_date, v_delete_control_id,v_arc_target_table_name);
          ELSE
            UPDATE_DIMENSION_TABLES (v_source_schema, v_source_table_name, v_source_table_key,
                                      v_target_schema, v_target_table_name, v_target_table_key,
                                      v_last_deleted_date, v_delete_control_id, v_table_type);
          END IF;

        EXCEPTION
          WHEN OTHERS THEN
            ROLLBACK;
            ERROR_LOG(v_delete_control_id, table_schema_in, target_table_alias_in,
                        SQLERRM, DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
            RAISE;
      END main;

      PROCEDURE UPDATE_FACT_TABLES (source_schema_in IN VARCHAR2, source_table_name_in IN VARCHAR2, source_table_key_in IN VARCHAR2,
                                      target_schema_in IN VARCHAR2, target_table_name_in IN VARCHAR2, target_table_key_in IN VARCHAR2,
                                      last_deleted_date_in IN DATE, delete_control_id_in IN NUMBER, arc_target_table_name IN VARCHAR2) AS

      v_source_stage_table        VARCHAR2(70);
      v_target_fact_table         VARCHAR2(70);
      v_target_arc_table          VARCHAR2(70);
      query_fetch_deleted_recs    CLOB;
      query_insert_into_arc       CLOB;
      query_delete_from_fact      CLOB;
      v_delete_count              NUMBER;
      v_insert_count              NUMBER;
      v_last_deleted_date         VARCHAR2(100) := TO_CHAR(last_deleted_date_in,'MM/DD/YYYY HH24:MI:SS');

      BEGIN
          v_source_stage_table  :=  source_schema_in || '.' || source_table_name_in;
          v_target_fact_table   :=  target_schema_in || '.' || target_table_name_in;
          v_target_arc_table    :=  target_schema_in || '.' || arc_target_table_name;

          query_fetch_deleted_recs    := ' SELECT * FROM ' || v_source_stage_table ||
                                      ' STAGING_TABLE WHERE STAGING_TABLE.' || source_table_key_in || ' = FACT_TABLE.' || target_table_key_in ||
                                      ' AND NVL(STAGING_TABLE.EDW_IUD_FLAG, ''X'') = '''|| CON_EDW_IUD_FLAG ||
                                      ''' AND STAGING_TABLE.EDW_UPDATE_DATE_TIME >= TO_DATE('''|| v_last_deleted_date || ''', ''MM/DD/YYYY HH24:MI:SS'')';
          DBMS_OUTPUT.PUT_LINE ('Query : ' || query_fetch_deleted_recs);
          query_insert_into_arc       := 'INSERT INTO ' || v_target_arc_table || ' SELECT * FROM ' || v_target_fact_table ||
                                      ' FACT_TABLE WHERE EXISTS (' || query_fetch_deleted_recs || ')';
          query_delete_from_fact      := 'DELETE FROM ' || v_target_fact_table ||
                                      ' FACT_TABLE WHERE EXISTS (' || query_fetch_deleted_recs || ')';
          DBMS_OUTPUT.PUT_LINE ('Insert Query : ' || query_insert_into_arc);
          EXECUTE IMMEDIATE query_insert_into_arc;
            v_insert_count := SQL%ROWCOUNT;
          EXECUTE IMMEDIATE query_delete_from_fact;
            v_delete_count := SQL%ROWCOUNT;
          COMMIT;

          DBMS_OUTPUT.PUT_LINE ('Results : ' || v_insert_count ||v_delete_count);

          --IF v_insert_count > 0 AND v_delete_count > 0 THEN
              UPDATE_LAST_DELETED_DATE(v_source_stage_table, delete_control_id_in);
          --END IF;

      EXCEPTION
          WHEN OTHERS THEN
            ROLLBACK;
            RAISE;

      END UPDATE_FACT_TABLES;

      PROCEDURE UPDATE_DIMENSION_TABLES (source_schema_in IN VARCHAR2, source_table_name_in IN VARCHAR2, source_table_key_in IN VARCHAR2,
                                      target_schema_in IN VARCHAR2, target_table_name_in IN VARCHAR2, target_table_key_in IN VARCHAR2,
                                      last_deleted_date_in IN DATE, delete_control_id_in IN NUMBER, table_type_in IN VARCHAR2) AS

      v_source_stage_table      VARCHAR2(70);
      v_target_dim_table        VARCHAR2(70);
      query_fetch_deleted_recs  CLOB;
      query_update_dim1         CLOB;
      query_update_dim2         CLOB;
      query_update_dim6         CLOB;
      v_update_count            NUMBER;
      v_last_deleted_date       VARCHAR2(100) := TO_CHAR(last_deleted_date_in,'MM/DD/YYYY HH24:MI:SS');

    BEGIN
          v_source_stage_table  :=  source_schema_in || '.' || source_table_name_in;
          v_target_dim_table    :=  target_schema_in || '.' || target_table_name_in;

          query_fetch_deleted_recs    := ' SELECT * FROM ' || v_source_stage_table ||
                                      ' STAGING_TABLE WHERE STAGING_TABLE.' || source_table_key_in || ' = DIM_TABLE.' || target_table_key_in ||
                                      ' AND NVL(STAGING_TABLE.EDW_IUD_FLAG, ''X'') = '''|| CON_EDW_IUD_FLAG ||
                                      ''' AND STAGING_TABLE.EDW_UPDATE_DATE_TIME >= TO_DATE('''|| v_last_deleted_date || ''', ''MM/DD/YYYY HH24:MI:SS'')';
          IF table_type_in = 'DIMTYP1' THEN
          query_update_dim1           := 'UPDATE ' || v_target_dim_table || ' DIM_TABLE' ||
                                      ' SET DIM_TABLE.DELETE_FLAG = ''' || CON_DELETED_FLAG || ''', DIM_TABLE.EDW_UPDATE_DATE_TIME = SYSDATE, DIM_TABLE.EDW_UPDATED_BY = ''ETL'''||
                                      ' WHERE (DIM_TABLE.DELETE_FLAG = ''N'' OR DIM_TABLE.DELETE_FLAG IS NULL)' ||
                                      ' AND EXISTS (' || query_fetch_deleted_recs || ')';
          DBMS_OUTPUT.PUT_LINE ('Query : ' || query_update_dim1);
              EXECUTE IMMEDIATE query_update_dim1;
              v_update_count := SQL%ROWCOUNT;

          ELSIF table_type_in = 'DIMTYP2' THEN
          query_update_dim2           := 'UPDATE ' || v_target_dim_table || ' DIM_TABLE' ||
                                      ' SET DIM_TABLE.CURRENT_FLAG = ''' || CON_CURRENT_FLAG || ''', DIM_TABLE.EDW_END_DATE = TRUNC(SYSDATE), ' ||
                                      ' EDW_UPDATE_DATE_TIME = SYSDATE, EDW_UPDATED_BY = ''ETL'''||
                                      ' WHERE DIM_TABLE.CURRENT_FLAG = ''Y'' AND EXISTS (' || query_fetch_deleted_recs || ')';

              EXECUTE IMMEDIATE query_update_dim2;
              v_update_count := SQL%ROWCOUNT;

            ELSIF table_type_in = 'DIMTYP6' THEN
            query_update_dim6           := 'UPDATE ' || v_target_dim_table || ' DIM_TABLE' ||
                                      ' SET  DIM_TABLE.EDW_END_DATE = TRUNC(SYSDATE) , ' ||
                                      ' DIM_TABLE.DELETE_FLAG = ''' || CON_DELETED_FLAG || ''', DIM_TABLE.EDW_UPDATE_DATE_TIME = SYSDATE, DIM_TABLE.EDW_UPDATED_BY = ''ETL'''||
                                      ' WHERE DIM_TABLE.EDW_END_DATE = TO_DATE(''12/31/2099'',''MM/DD/YYYY'') AND EXISTS (' || query_fetch_deleted_recs || ')';

              EXECUTE IMMEDIATE query_update_dim6;
              v_update_count := SQL%ROWCOUNT;

          END IF;
          COMMIT;
          DBMS_OUTPUT.PUT_LINE ('Results : ' || v_update_count);

          --IF v_update_count > 0 THEN
              UPDATE_LAST_DELETED_DATE(v_source_stage_table, delete_control_id_in);
          --END IF;

      EXCEPTION
          WHEN OTHERS THEN
            ROLLBACK;
            RAISE;
      END UPDATE_DIMENSION_TABLES;

      PROCEDURE UPDATE_LAST_DELETED_DATE (source_stage_table_in IN VARCHAR2, delete_control_id_in IN NUMBER) AS
      query_max_updated_query   CLOB;
      v_max_updated_date        DATE;
      BEGIN
          query_max_updated_query := 'SELECT MAX(STAGE_TABLE.EDW_UPDATE_DATE_TIME) FROM ' || source_stage_table_in || ' STAGE_TABLE ';

          EXECUTE IMMEDIATE query_max_updated_query INTO v_max_updated_date;

          UPDATE EDW_ODS_DWH_DELETES_CONTROL
                  SET EDW_UPDATE_DATE_TIME = SYSDATE, EDW_UPDATED_BY = 'ETL', LAST_DELETED_DATE = v_max_updated_date
          WHERE DELETE_CONTROL_ID = delete_control_id_in;

          COMMIT;
      EXCEPTION
          WHEN OTHERS THEN
            ROLLBACK;
            RAISE;
      END UPDATE_LAST_DELETED_DATE;

      PROCEDURE ERROR_LOG (delete_record_key_in IN NUMBER, table_schema_in   IN VARCHAR2, target_table_in   IN VARCHAR2,
                              error_message_in IN VARCHAR2, error_backtrace_in IN VARCHAR2 := NULL) AS

        PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
          INSERT INTO edw_ods_dwh_deletes_log VALUES (delete_record_key_in, target_table_in, table_schema_in, SYSDATE, 'ETL',
                                                        error_message_in, error_backtrace_in);
          COMMIT;
          RAISE_APPLICATION_ERROR(-20000, error_message_in);
      EXCEPTION
          WHEN OTHERS THEN
            RAISE;
            END ERROR_LOG;
    END EDW_ODS_DELETE_RECORDS_PKG;
</code>```

答:
Your error is, as the ORA-00913 error message states, that in one of your statements you are passing too many values.

Cause:

As an example, if you have the table:

CREATE TABLE table_name (a NUMBER, b NUMBER);
```
<p>And you do either of:</p>
<pre class="lang-sql prettyprint-override"><code>INSERT INTO table_name VALUES (1,2,3);
INSERT INTO table_name (a,b) VALUES (1,2,3);
</code>```

Then you get the error:

ORA-00913: too many values
```
</blockquote>
<p>As you are trying to insert three values into two columns.</p>
<p>If you name all the columns:</p>
<pre class="lang-sql prettyprint-override"><code>INSERT INTO table_name (a,b,c) VALUES (1,2,3);
</code>```

Then you will get a more expressive error message:

ORA-00904: "C": invalid identifier
```
</blockquote>
<hr />
<h3>Solution:</h3>
<p>Go through every statement and explicitly name the columns you are inserting and make sure you are selecting the same number of columns.</p>
<p>For example, in the <code>UPDATE_FACT_TABLES</code> procedure you have:</p>
<pre class="lang-sql prettyprint-override"><code>query_insert_into_arc := 'INSERT INTO ' || v_target_arc_table || ' SELECT * FROM ' || v_target_fact_table ||
                         ' FACT_TABLE WHERE EXISTS (' || query_fetch_deleted_recs || ')';
</code>```

It would be better to be:

query_insert_into_arc := 'INSERT INTO ' || v_target_arc_table || ' (col1, col2, col3, col4)
                      || ' SELECT other_col1, other_col2, other_col3, other_col3'
                      || ' FROM ' || v_target_fact_table || ' FACT_TABLE'
                      || ' WHERE EXISTS (' || query_fetch_deleted_recs || ')';
```
<p>Then you know which columns are being inserted where and you will get a more detailed error message if you are trying to insert into a column that does not exist.</p>
<hr />
<p>You also do not need to use:</p>
<pre class="lang-sql prettyprint-override"><code>EXCEPTION
  WHEN OTHERS THEN
    ROLLBACK;
    RAISE;
</code>```

As the default behaviour is to rollback the transaction when an exception is raised.

Additionally, you should not raise an exception in your autonomous transaction as you are already raising the exception in the non-autonomous procedure.

PROCEDURE ERROR_LOG (
  delete_record_key_in IN NUMBER,
  table_schema_in      IN VARCHAR2,
  target_table_in      IN VARCHAR2,
  error_message_in     IN VARCHAR2,
  error_backtrace_in   IN VARCHAR2 := NULL
)
AS
  PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
  INSERT INTO edw_ods_dwh_deletes_log (
    delete_record_key, -- Give the columns their proper names
    target_table,
    table_schema,
    change_date,
    col1,
    error_message,
    error_backtrace
  ) VALUES (
    delete_record_key_in,
    target_table_in,
    table_schema_in,
    SYSDATE,
    'ETL',
    error_message_in,
    error_backtrace_in
  );
  COMMIT;
  -- Remove raising the exception.
END ERROR_LOG;
```

Body:
The below code is used to create the stored procedure and this is how the stored procedure is called. Stored procedure is throwing ORA-20000: ORA-00913: too many values

BEGIN EDW_ODS_DELETE_RECORDS_PKG.MAIN('EDWFIN', 'PSP_LABOR_ADJUSTMENTS_F'); END;

create or replace
    PACKAGE BODY         "EDW_ODS_DELETE_RECORDS_PKG" AS

    CON_EDW_IUD_FLAG  CONSTANT CHAR := 'D';
    CON_CURRENT_FLAG  CONSTANT CHAR := 'N';
    CON_DELETED_FLAG  CONSTANT CHAR := 'Y';
    PROCEDURE main (table_schema_in   IN VARCHAR2, target_table_alias_in   IN VARCHAR2) AS
      v_source_schema       VARCHAR2(30);
      v_source_table_name   VARCHAR2(30);
      v_target_schema       VARCHAR2(30);
      v_target_table_name   VARCHAR2(30);
      v_source_table_key    VARCHAR2(1000);
      v_target_table_key    VARCHAR2(1000);
      v_table_type          VARCHAR2(20);
      v_last_deleted_date   DATE;
      v_delete_control_id   NUMBER := 0;
      v_target_table_alias  VARCHAR2(30);
      v_arc_target_table_name   VARCHAR2(30);
      BEGIN
          SELECT SOURCE_TABLE_SCHEMA, SOURCE_TABLE_NAME, SOURCE_TABLE_KEY,
                  TARGET_TABLE_SCHEMA, TARGET_TABLE_NAME, TARGET_TABLE_KEY,
                  TABLE_TYPE, LAST_DELETED_DATE, DELETE_CONTROL_ID,
                  TARGET_TABLE_ALIAS,
                  ARC_TARGET_TABLE_NAME
                  INTO
                  v_source_schema, v_source_table_name, v_source_table_key,
                  v_target_schema, v_target_table_name, v_target_table_key,
                  v_table_type, v_last_deleted_date, v_delete_control_id,
                  v_target_table_alias,
                  v_arc_target_table_name
                  FROM EDW_ODS_DWH_DELETES_CONTROL
          WHERE target_table_schema = table_schema_in AND target_table_alias = target_table_alias_in;

          DBMS_OUTPUT.PUT_LINE ('Values : ' || v_last_deleted_date);

          v_source_table_key := REPLACE(v_source_table_key, '~', ' || ''~'' || ');
          v_target_table_key := REPLACE(v_target_table_key, '~', ' || ''~'' || ');

          IF v_table_type = 'FACT' THEN
            UPDATE_FACT_TABLES (v_source_schema, v_source_table_name, v_source_table_key,
                                      v_target_schema, v_target_table_name, v_target_table_key,
                                      v_last_deleted_date, v_delete_control_id,v_arc_target_table_name);
          ELSE
            UPDATE_DIMENSION_TABLES (v_source_schema, v_source_table_name, v_source_table_key,
                                      v_target_schema, v_target_table_name, v_target_table_key,
                                      v_last_deleted_date, v_delete_control_id, v_table_type);
          END IF;

        EXCEPTION
          WHEN OTHERS THEN
            ROLLBACK;
            ERROR_LOG(v_delete_control_id, table_schema_in, target_table_alias_in,
                        SQLERRM, DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
            RAISE;
      END main;

      PROCEDURE UPDATE_FACT_TABLES (source_schema_in IN VARCHAR2, source_table_name_in IN VARCHAR2, source_table_key_in IN VARCHAR2,
                                      target_schema_in IN VARCHAR2, target_table_name_in IN VARCHAR2, target_table_key_in IN VARCHAR2,
                                      last_deleted_date_in IN DATE, delete_control_id_in IN NUMBER, arc_target_table_name IN VARCHAR2) AS

      v_source_stage_table        VARCHAR2(70);
      v_target_fact_table         VARCHAR2(70);
      v_target_arc_table          VARCHAR2(70);
      query_fetch_deleted_recs    CLOB;
      query_insert_into_arc       CLOB;
      query_delete_from_fact      CLOB;
      v_delete_count              NUMBER;
      v_insert_count              NUMBER;
      v_last_deleted_date         VARCHAR2(100) := TO_CHAR(last_deleted_date_in,'MM/DD/YYYY HH24:MI:SS');

      BEGIN
          v_source_stage_table  :=  source_schema_in || '.' || source_table_name_in;
          v_target_fact_table   :=  target_schema_in || '.' || target_table_name_in;
          v_target_arc_table    :=  target_schema_in || '.' || arc_target_table_name;

          query_fetch_deleted_recs    := ' SELECT * FROM ' || v_source_stage_table ||
                                      ' STAGING_TABLE WHERE STAGING_TABLE.' || source_table_key_in || ' = FACT_TABLE.' || target_table_key_in ||
                                      ' AND NVL(STAGING_TABLE.EDW_IUD_FLAG, ''X'') = '''|| CON_EDW_IUD_FLAG ||
                                      ''' AND STAGING_TABLE.EDW_UPDATE_DATE_TIME >= TO_DATE('''|| v_last_deleted_date || ''', ''MM/DD/YYYY HH24:MI:SS'')';
          DBMS_OUTPUT.PUT_LINE ('Query : ' || query_fetch_deleted_recs);
          query_insert_into_arc       := 'INSERT INTO ' || v_target_arc_table || ' SELECT * FROM ' || v_target_fact_table ||
                                      ' FACT_TABLE WHERE EXISTS (' || query_fetch_deleted_recs || ')';
          query_delete_from_fact      := 'DELETE FROM ' || v_target_fact_table ||
                                      ' FACT_TABLE WHERE EXISTS (' || query_fetch_deleted_recs || ')';
          DBMS_OUTPUT.PUT_LINE ('Insert Query : ' || query_insert_into_arc);
          EXECUTE IMMEDIATE query_insert_into_arc;
            v_insert_count := SQL%ROWCOUNT;
          EXECUTE IMMEDIATE query_delete_from_fact;
            v_delete_count := SQL%ROWCOUNT;
          COMMIT;

          DBMS_OUTPUT.PUT_LINE ('Results : ' || v_insert_count ||v_delete_count);

          --IF v_insert_count > 0 AND v_delete_count > 0 THEN
              UPDATE_LAST_DELETED_DATE(v_source_stage_table, delete_control_id_in);
          --END IF;

      EXCEPTION
          WHEN OTHERS THEN
            ROLLBACK;
            RAISE;

      END UPDATE_FACT_TABLES;

      PROCEDURE UPDATE_DIMENSION_TABLES (source_schema_in IN VARCHAR2, source_table_name_in IN VARCHAR2, source_table_key_in IN VARCHAR2,
                                      target_schema_in IN VARCHAR2, target_table_name_in IN VARCHAR2, target_table_key_in IN VARCHAR2,
                                      last_deleted_date_in IN DATE, delete_control_id_in IN NUMBER, table_type_in IN VARCHAR2) AS

      v_source_stage_table      VARCHAR2(70);
      v_target_dim_table        VARCHAR2(70);
      query_fetch_deleted_recs  CLOB;
      query_update_dim1         CLOB;
      query_update_dim2         CLOB;
      query_update_dim6         CLOB;
      v_update_count            NUMBER;
      v_last_deleted_date       VARCHAR2(100) := TO_CHAR(last_deleted_date_in,'MM/DD/YYYY HH24:MI:SS');

    BEGIN
          v_source_stage_table  :=  source_schema_in || '.' || source_table_name_in;
          v_target_dim_table    :=  target_schema_in || '.' || target_table_name_in;

          query_fetch_deleted_recs    := ' SELECT * FROM ' || v_source_stage_table ||
                                      ' STAGING_TABLE WHERE STAGING_TABLE.' || source_table_key_in || ' = DIM_TABLE.' || target_table_key_in ||
                                      ' AND NVL(STAGING_TABLE.EDW_IUD_FLAG, ''X'') = '''|| CON_EDW_IUD_FLAG ||
                                      ''' AND STAGING_TABLE.EDW_UPDATE_DATE_TIME >= TO_DATE('''|| v_last_deleted_date || ''', ''MM/DD/YYYY HH24:MI:SS'')';
          IF table_type_in = 'DIMTYP1' THEN
          query_update_dim1           := 'UPDATE ' || v_target_dim_table || ' DIM_TABLE' ||
                                      ' SET DIM_TABLE.DELETE_FLAG = ''' || CON_DELETED_FLAG || ''', DIM_TABLE.EDW_UPDATE_DATE_TIME = SYSDATE, DIM_TABLE.EDW_UPDATED_BY = ''ETL'''||
                                      ' WHERE (DIM_TABLE.DELETE_FLAG = ''N'' OR DIM_TABLE.DELETE_FLAG IS NULL)' ||
                                      ' AND EXISTS (' || query_fetch_deleted_recs || ')';
          DBMS_OUTPUT.PUT_LINE ('Query : ' || query_update_dim1);
              EXECUTE IMMEDIATE query_update_dim1;
              v_update_count := SQL%ROWCOUNT;

          ELSIF table_type_in = 'DIMTYP2' THEN
          query_update_dim2           := 'UPDATE ' || v_target_dim_table || ' DIM_TABLE' ||
                                      ' SET DIM_TABLE.CURRENT_FLAG = ''' || CON_CURRENT_FLAG || ''', DIM_TABLE.EDW_END_DATE = TRUNC(SYSDATE), ' ||
                                      ' EDW_UPDATE_DATE_TIME = SYSDATE, EDW_UPDATED_BY = ''ETL'''||
                                      ' WHERE DIM_TABLE.CURRENT_FLAG = ''Y'' AND EXISTS (' || query_fetch_deleted_recs || ')';

              EXECUTE IMMEDIATE query_update_dim2;
              v_update_count := SQL%ROWCOUNT;

            ELSIF table_type_in = 'DIMTYP6' THEN
            query_update_dim6           := 'UPDATE ' || v_target_dim_table || ' DIM_TABLE' ||
                                      ' SET  DIM_TABLE.EDW_END_DATE = TRUNC(SYSDATE) , ' ||
                                      ' DIM_TABLE.DELETE_FLAG = ''' || CON_DELETED_FLAG || ''', DIM_TABLE.EDW_UPDATE_DATE_TIME = SYSDATE, DIM_TABLE.EDW_UPDATED_BY = ''ETL'''||
                                      ' WHERE DIM_TABLE.EDW_END_DATE = TO_DATE(''12/31/2099'',''MM/DD/YYYY'') AND EXISTS (' || query_fetch_deleted_recs || ')';

              EXECUTE IMMEDIATE query_update_dim6;
              v_update_count := SQL%ROWCOUNT;

          END IF;
          COMMIT;
          DBMS_OUTPUT.PUT_LINE ('Results : ' || v_update_count);

          --IF v_update_count > 0 THEN
              UPDATE_LAST_DELETED_DATE(v_source_stage_table, delete_control_id_in);
          --END IF;

      EXCEPTION
          WHEN OTHERS THEN
            ROLLBACK;
            RAISE;
      END UPDATE_DIMENSION_TABLES;

      PROCEDURE UPDATE_LAST_DELETED_DATE (source_stage_table_in IN VARCHAR2, delete_control_id_in IN NUMBER) AS
      query_max_updated_query   CLOB;
      v_max_updated_date        DATE;
      BEGIN
          query_max_updated_query := 'SELECT MAX(STAGE_TABLE.EDW_UPDATE_DATE_TIME) FROM ' || source_stage_table_in || ' STAGE_TABLE ';

          EXECUTE IMMEDIATE query_max_updated_query INTO v_max_updated_date;

          UPDATE EDW_ODS_DWH_DELETES_CONTROL
                  SET EDW_UPDATE_DATE_TIME = SYSDATE, EDW_UPDATED_BY = 'ETL', LAST_DELETED_DATE = v_max_updated_date
          WHERE DELETE_CONTROL_ID = delete_control_id_in;

          COMMIT;
      EXCEPTION
          WHEN OTHERS THEN
            ROLLBACK;
            RAISE;
      END UPDATE_LAST_DELETED_DATE;

      PROCEDURE ERROR_LOG (delete_record_key_in IN NUMBER, table_schema_in   IN VARCHAR2, target_table_in   IN VARCHAR2,
                              error_message_in IN VARCHAR2, error_backtrace_in IN VARCHAR2 := NULL) AS

        PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
          INSERT INTO edw_ods_dwh_deletes_log VALUES (delete_record_key_in, target_table_in, table_schema_in, SYSDATE, 'ETL',
                                                        error_message_in, error_backtrace_in);
          COMMIT;
          RAISE_APPLICATION_ERROR(-20000, error_message_in);
      EXCEPTION
          WHEN OTHERS THEN
            RAISE;
            END ERROR_LOG;
    END EDW_ODS_DELETE_RECORDS_PKG;

Body:
Your error is, as the ORA-00913 error message states, that in one of your statements you are passing too many values.

Cause:

As an example, if you have the table:

CREATE TABLE table_name (a NUMBER, b NUMBER);

And you do either of:

INSERT INTO table_name VALUES (1,2,3);
INSERT INTO table_name (a,b) VALUES (1,2,3);

Then you get the error:

ORA-00913: too many values

As you are trying to insert three values into two columns.

If you name all the columns:

INSERT INTO table_name (a,b,c) VALUES (1,2,3);

Then you will get a more expressive error message:

ORA-00904: "C": invalid identifier

Solution:

Go through every statement and explicitly name the columns you are inserting and make sure you are selecting the same number of columns.

For example, in the UPDATE_FACT_TABLES procedure you have:

query_insert_into_arc := 'INSERT INTO ' || v_target_arc_table || ' SELECT * FROM ' || v_target_fact_table ||
                         ' FACT_TABLE WHERE EXISTS (' || query_fetch_deleted_recs || ')';

It would be better to be:

query_insert_into_arc := 'INSERT INTO ' || v_target_arc_table || ' (col1, col2, col3, col4)
                      || ' SELECT other_col1, other_col2, other_col3, other_col3'
                      || ' FROM ' || v_target_fact_table || ' FACT_TABLE'
                      || ' WHERE EXISTS (' || query_fetch_deleted_recs || ')';

Then you know which columns are being inserted where and you will get a more detailed error message if you are trying to insert into a column that does not exist.

You also do not need to use:

EXCEPTION
  WHEN OTHERS THEN
    ROLLBACK;
    RAISE;

As the default behaviour is to rollback the transaction when an exception is raised.

Additionally, you should not raise an exception in your autonomous transaction as you are already raising the exception in the non-autonomous procedure.

PROCEDURE ERROR_LOG (
  delete_record_key_in IN NUMBER,
  table_schema_in      IN VARCHAR2,
  target_table_in      IN VARCHAR2,
  error_message_in     IN VARCHAR2,
  error_backtrace_in   IN VARCHAR2 := NULL
)
AS
  PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
  INSERT INTO edw_ods_dwh_deletes_log (
    delete_record_key, -- Give the columns their proper names
    target_table,
    table_schema,
    change_date,
    col1,
    error_message,
    error_backtrace
  ) VALUES (
    delete_record_key_in,
    target_table_in,
    table_schema_in,
    SYSDATE,
    'ETL',
    error_message_in,
    error_backtrace_in
  );
  COMMIT;
  -- Remove raising the exception.
END ERROR_LOG;


问:
implicit "popd" on batch exit
Is there a way to undo all pushd at the end of script. What I have is:

```<code>pushd somwhere
rem doing stuff
goto end

:end
popd
goto :EOF
</code>```

What I'd like to have is:

```<code>setlocal
pushd somwhere
rem doing stuff
goto :EOF
</code>```

But that doesn't work, the directory stays "pushd". Another try where I can't say how many pushd will occur would be:

```<code>set CurrentDir=%CD%
rem doing a lot of pushd and popd
pushd somwhere

:POPBACK
if /i not "%CD%" == "%CurrentDir%" popd & goto POPBACK
</code>```

But that looks like I can easily get stuck at :POPBACK. Adding a counter to exit that loop is a bit uncertain at which dir I end up.

In that context I'd like to know if a can see the stack of pushd directories. The only thing I found was $+ in prompt $P$+$G which adds a '+' for each pushd directory e.g. D:\CMD++>. But I can't see a way how to make use of that.

EDIT:
I just noticed there is something wrong with the $+ of prompt that confused me.
The setlocal in the example above actually makes the script return to the initial directory, but the prompt shows a '+' indicating a missing popd.

```<code>D:\CMD>test.cmd
D:\CMD>prompt $P$+$g
D:\CMD>setlocal
D:\CMD>pushd e:\DATA
e:\DATA+>goto :EOF
D:\CMD+>popd
D:\CMD>
</code>```

EDIT:
Due to the hint to the difference between local environment and directory stack I expanded the example form above, pushing to C:\DATA before calling the script. the script returns to where it has been called from (C:\DATA). So far so good. The first popd shows no effect as it removes the last pushd from stack but not changing the directory, since the directory change has been undone by the (implicit) endlocal. The second popd returns to initial directory as expected.

```<code>D:\CMD>pushd C:\DATA
C:\DATA+>d:\cmd\test.cmd
C:\DATA+>prompt $P$+$g
C:\DATA+>setlocal
C:\DATA+>pushd e:\DATA
e:\DATA++>goto :EOF
C:\DATA++>popd
C:\DATA+>popd
D:\CMD>
</code>```

答:
The pushd command without any arguments lists the contents of the directory stack, which can be made use of, by writing the list with output redirection > to a (temporary) file, which is then read by a for /F loop, and to determine how many popd commands are necessary.

In a batch-file:

pushd > "tempfile.tmp" && (
    for /F "usebackq delims=" %%P in ("tempfile.tmp") do popd
    del "tempfile.tmp"
)
```
<p>Directly in cmd:</p>
<pre class="lang-cmd prettyprint-override"><code>pushd > "tempfile.tmp" && (for /F "usebackq delims=" %P in ("tempfile.tmp") do @popd) & del "tempfile.tmp"
</code>```

Note, that you cannot use for /F "delims=" %P in ('pushd') do ( … ), because for /F would execute pushd in a new instance of cmd.exe, which has got its own new pushd/popd stack.

One way to prevent residues from the pushd/popd stack is to simply avoid pushd and to use cd /D instead within a localised environment (by setlocal/endlocal in a batch file), because, unlike popd, endlocal becomes implicitly executed whenever necessary (even if the batch file contains wrong syntax that leads to a fatal error that aborts execution, like rem %~). This of course only works when there are no UNC paths to be handled (that is, to be mapped to local paths).

It is advisable to use pushd/popd only in a limited code section with out any branches (by if, goto, etc.). Additionally, ensure to account for potential errors (using conditional execution here):

rem // First stack level:
pushd "D:\main" && (
    rem // Second stack level:
    pushd "D:\main\sub" && (
        rem /* If `D:\main\sub` does not exist, `pushd` would obviously fail;
        rem    to avoid unintended `popd`, use conditional execution `&&`: */
        popd
    )
    rem // We are still in directory `D:\main` here as expected.
    popd
)
```

Title: implicit "popd" on batch exit

Body:
Is there a way to undo all pushd at the end of script. What I have is:

pushd somwhere
rem doing stuff
goto end

:end
popd
goto :EOF

What I'd like to have is:

setlocal
pushd somwhere
rem doing stuff
goto :EOF

But that doesn't work, the directory stays "pushd". Another try where I can't say how many pushd will occur would be:

set CurrentDir=%CD%
rem doing a lot of pushd and popd
pushd somwhere

:POPBACK
if /i not "%CD%" == "%CurrentDir%" popd & goto POPBACK

But that looks like I can easily get stuck at :POPBACK. Adding a counter to exit that loop is a bit uncertain at which dir I end up.

In that context I'd like to know if a can see the stack of pushd directories. The only thing I found was $+ in prompt $P$+$G which adds a '+' for each pushd directory e.g. D:\CMD++>. But I can't see a way how to make use of that.

EDIT:
I just noticed there is something wrong with the $+ of prompt that confused me.
The setlocal in the example above actually makes the script return to the initial directory, but the prompt shows a '+' indicating a missing popd.

D:\CMD>test.cmd
D:\CMD>prompt $P$+$g
D:\CMD>setlocal
D:\CMD>pushd e:\DATA
e:\DATA+>goto :EOF
D:\CMD+>popd
D:\CMD>

EDIT:
Due to the hint to the difference between local environment and directory stack I expanded the example form above, pushing to C:\DATA before calling the script. the script returns to where it has been called from (C:\DATA). So far so good. The first popd shows no effect as it removes the last pushd from stack but not changing the directory, since the directory change has been undone by the (implicit) endlocal. The second popd returns to initial directory as expected.

D:\CMD>pushd C:\DATA
C:\DATA+>d:\cmd\test.cmd
C:\DATA+>prompt $P$+$g
C:\DATA+>setlocal
C:\DATA+>pushd e:\DATA
e:\DATA++>goto :EOF
C:\DATA++>popd
C:\DATA+>popd
D:\CMD>

Body:
The pushd command without any arguments lists the contents of the directory stack, which can be made use of, by writing the list with output redirection > to a (temporary) file, which is then read by a for /F loop, and to determine how many popd commands are necessary.

In a batch-file:

pushd > "tempfile.tmp" && (
    for /F "usebackq delims=" %%P in ("tempfile.tmp") do popd
    del "tempfile.tmp"
)

Directly in cmd:

pushd > "tempfile.tmp" && (for /F "usebackq delims=" %P in ("tempfile.tmp") do @popd) & del "tempfile.tmp"

Note, that you cannot use for /F "delims=" %P in ('pushd') do ( … ), because for /F would execute pushd in a new instance of cmd.exe, which has got its own new pushd/popd stack.

One way to prevent residues from the pushd/popd stack is to simply avoid pushd and to use cd /D instead within a localised environment (by setlocal/endlocal in a batch file), because, unlike popd, endlocal becomes implicitly executed whenever necessary (even if the batch file contains wrong syntax that leads to a fatal error that aborts execution, like rem %~). This of course only works when there are no UNC paths to be handled (that is, to be mapped to local paths).

It is advisable to use pushd/popd only in a limited code section with out any branches (by if, goto, etc.). Additionally, ensure to account for potential errors (using conditional execution here):

rem // First stack level:
pushd "D:\main" && (
    rem // Second stack level:
    pushd "D:\main\sub" && (
        rem /* If `D:\main\sub` does not exist, `pushd` would obviously fail;
        rem    to avoid unintended `popd`, use conditional execution `&&`: */
        popd
    )
    rem // We are still in directory `D:\main` here as expected.
    popd
)


问:
why android studio show error of "Missing constraints in constraintlayout"?
picture

This view is not constrained, it only has design time positions, so it will jump to (0,0) unless you add constraints

The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with design time attributes (such as layout_editor_absolute X.) These attributes are not applied at run time, so if you push your layout on a device, the widgets may appear in a different location than shown in the editor. To fix this, make sure a widget has both horizontal and vertical constraints by dragging from the edge connections

答:
enter image description here

First click on Linear layout in Component Tree and then click on infer constraints that is in right side from eye symbol in Activity Screen.

ContentLicense: CC BY-SA 3.0


问:
How can i disable end date on reactjs
i have a campaign date picker on my webpage. User should see all the dates for beginning of the campaign but when user pick a date for beginning it shouldn't pick end-date before today date. For example if my campaign beginning date is 06.01.2022 end-date value must be bigger than today date value some date like 10.02.2022 or bigger. Here is my code..</p>
```<code> <FormItem label={AddCampaignFormText.campaignStartAndEndDate} colSpan={{ span: 12 }}>
        <DatePicker.RangePicker
          name="campaignStartAndEndDate"
          validation={[{ required: true }]}
           disabledDate={disabledDate}
        />
      </FormItem>
</code>```

答:
If you're using RangePicker from Antd. here it will do this automatically by default without having to set a disabledDate prop value.

Any date you select first will automatically  disable all the dates before that. Same if you select End Date first, it will disable all dates after that by default

Title: How can i disable end date on reactjs

Body:
i have a campaign date picker on my webpage. User should see all the dates for beginning of the campaign but when user pick a date for beginning it shouldn't pick end-date before today date. For example if my campaign beginning date is 06.01.2022 end-date value must be bigger than today date value some date like 10.02.2022 or bigger. Here is my code..

 <FormItem label={AddCampaignFormText.campaignStartAndEndDate} colSpan={{ span: 12 }}>
        <DatePicker.RangePicker
          name="campaignStartAndEndDate"
          validation={[{ required: true }]}
           disabledDate={disabledDate}
        />
      </FormItem>


问:
How to access files stored in a password protected folder in windows
I need to save/access some text files under a password protected folder on the file system in windows, Is there any way I can access these files inside that password protected folder using groovy/java?</p>

答: depends on the mechanism of password protection. In general, decrypting / cracking a password protected folder / file requires lots of CPU time & power, or even not possible to be decrypted in forseeable future.</p>


问:
Pagination at top and bottom with DataTables
I'm using SB Admin 2 theme, with DataTables jQuery plugin. Is it possible to have pagination positioned at the top and at the bottom of a table, at the same time? If it is, how could I achieve it? This is what I currently have as a working code:

```<code><script>

$('#data-table').DataTable({
  responsive: true,
  "pageLength": 25,
  "columnDefs": [ {
  "targets"  : 'no-sort',
  "orderable": false,
  }],
  "language": {
          "lengthMenu": "Show _MENU_ items per page",
          "zeroRecords": "Nothing found. Please change your search term",
          "info": "Page _PAGE_ of _PAGES_",
          "infoEmpty": "No results",
          "infoFiltered": "(filtered out of _MAX_)",
    "search":       "Search:",
    "paginate": {
      "first":      "First",
      "last":       "Last",
      "next":       ">>",
      "previous":   "<<"
    }
  }
});

</script>
</code>```

I have tried using what the official site suggests (removing the code I posted, and then doing a simple copy/paste, and changing the id), but it did absolutely nothing. I'm guessing that I'm doing something wrong, but I have no idea what.

答:
```<code>var table = $('#example').DataTable({
    dom: "<'row'<'col-sm-3'l><'col-sm-3'f><'col-sm-6'p>>" +
         "<'row'<'col-sm-12'tr>>" +
         "<'row'<'col-sm-5'i><'col-sm-7'p>>",
});
</code>```

This Solution Work for me.

Body:
I'm using SB Admin 2 theme, with DataTables jQuery plugin. Is it possible to have pagination positioned at the top and at the bottom of a table, at the same time? If it is, how could I achieve it? This is what I currently have as a working code:

I have tried using what the official site suggests (removing the code I posted, and then doing a simple copy/paste, and changing the id), but it did absolutely nothing. I'm guessing that I'm doing something wrong, but I have no idea what.

Body:
var table = $('#example').DataTable({
    dom: "<'row'<'col-sm-3'l><'col-sm-3'f><'col-sm-6'p>>" +
         "<'row'<'col-sm-12'tr>>" +
         "<'row'<'col-sm-5'i><'col-sm-7'p>>",
});

This Solution Work for me.


问:
Replace WP logo with H1 using JS
I need to replace site_logo(); with the_title( '
', '
' ); using JS if possible, so that I don't edit the header.php directly. Thanks in advance.

答:
You can use replaceWith

$("h1").replaceWith('
replaceWith
');```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h1>Test</h1></code>```

Title: Replace WP logo with H1 using JS

Body:
You can use replaceWith

$("h1").replaceWith('<a href="http://example.com/"><h1 class="entry-title">replaceWith</h1></a>');

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h1>Test</h1>


问:
Gunicorn does not execute statements within main
```<code>from flask import Flask, request, jsonify

app = Flask(__name__)
@app.route('/api', methods=['POST'])
def predict():
    pass
    #Some statements to predict something

if __name__ == '__main__':
    print("Hello World")
    app.run(host='0.0.0.0', debug=True)
</code>```

When I run as
gunicorn -b 0.0.0.0 app:app I do not see the print statement. However when I run as python app.py, the "Hello World" gets printed. The app runs but it does not execute the print statement. Any idea what causes the Gunicorn to ignore what is within main()?

答:
When you run as gunicorn -b 0.0.0.0 app:app, gunicorn will only import the app from your app.py file. It will skip statements from the if __name__ == '__main__' block and hence you're not seeing the output from the print statement.

But when you run as python app.py, if __name__ == '__main__' block will be the entry point and hence print statement gets executed.

Also note that, the app.run(host='0.0.0.0', debug=True) line in if __name__ == '__main__' will start the development server and not the gunicorn server.

Attaching the link here for the similar question:
code before app.run() can not be run in gunicorn+flask

Body:
from flask import Flask, request, jsonify

app = Flask(__name__)
@app.route('/api', methods=['POST'])
def predict():
    pass
    #Some statements to predict something

if __name__ == '__main__':
    print("Hello World")
    app.run(host='0.0.0.0', debug=True)

When I run as
gunicorn -b 0.0.0.0 app:app I do not see the print statement. However when I run as python app.py, the "Hello World" gets printed. The app runs but it does not execute the print statement. Any idea what causes the Gunicorn to ignore what is within main()?


问:
How to prevent ArgumentError (A copy of PaymentFailed has been removed from the > module tree but is still active!) with StripeEvents / Webhooks?
I am using the StripeEvent gem to handle web hooks coming from Stripe.

In my Rails initializer I've got this:

```<code>StripeEvent.configure do |events|

  events.subscribe 'invoice.payment_succeeded', PaymentSucceeded.new
  events.subscribe 'invoice.payment_failed', PaymentFailed.new

end
</code>```

I've also got a folder app/stripe_events where I keep classes like these:

```<code>class PaymentFailed

  def call(event)
    StripeMailer.admin_payment_failed(event.data.object).deliver_now
  end

end
</code>```

The problem is that I keep getting this error every now and then:

ArgumentError (A copy of PaymentFailed has been removed from the
  module tree but is still active!)

I guess that's because everything inside app is constantly being reloaded by Rails while the StripeEvent.configure bits in the initializer are not?

How can this be prevented?

Thanks for any pointers.

答: In my case, I only get this error when I make a change to the event handler or config files. Restarting the server always fixes it.</p>

Body:
I am using the StripeEvent gem to handle web hooks coming from Stripe.

In my Rails initializer I've got this:

StripeEvent.configure do |events|

  events.subscribe 'invoice.payment_succeeded', PaymentSucceeded.new
  events.subscribe 'invoice.payment_failed', PaymentFailed.new

end

I've also got a folder app/stripe_events where I keep classes like these:

class PaymentFailed

  def call(event)
    StripeMailer.admin_payment_failed(event.data.object).deliver_now
  end

end

The problem is that I keep getting this error every now and then:

ArgumentError (A copy of PaymentFailed has been removed from the
  module tree but is still active!)

I guess that's because everything inside app is constantly being reloaded by Rails while the StripeEvent.configure bits in the initializer are not?

How can this be prevented?

Thanks for any pointers.


问:
Get All Shipping Classes in Woocommerce 3
I've been unable to crack this nut, but can't help feel that I'm missing something simple.

I'm developing a WooCommerce plugin that should provide a list of shipping classes on its admin settings page. The following code as suggested in another question's answer indicated that the following should work:

```<code>$shipping           = new \WC_Shipping();
$shipping_classes   = $shipping->get_shipping_classes();
var_dump($shipping_classes);
die();
</code>```

Unfortunately the output is an empty array.

I am using Wordpress 4.9.5 and WooCommerce 3.3.5. Thanks for any help!

UPDATE
I have the exact same problem as outlined here:
get_terms() returns Invalid Taxonomy and have provided a work-around. However, I do not feel that is a solution.

答:
Maybe someone is still looking for a solution :)</p>
```<code>$WC_Shipping = new WC_Shipping();
$shipping_classes = $WC_Shipping->get_shipping_classes();
var_dump($shipping_classes);
</code>```

Body:
I've been unable to crack this nut, but can't help feel that I'm missing something simple.

I'm developing a WooCommerce plugin that should provide a list of shipping classes on its admin settings page. The following code as suggested in another question's answer indicated that the following should work:

$shipping           = new \WC_Shipping();
$shipping_classes   = $shipping->get_shipping_classes();
var_dump($shipping_classes);
die();

Unfortunately the output is an empty array.

I am using Wordpress 4.9.5 and WooCommerce 3.3.5. Thanks for any help!

UPDATE
I have the exact same problem as outlined here:
get_terms() returns Invalid Taxonomy and have provided a work-around. However, I do not feel that is a solution.

Body:
Maybe someone is still looking for a solution :)

$WC_Shipping = new WC_Shipping();
$shipping_classes = $WC_Shipping->get_shipping_classes();
var_dump($shipping_classes);


问:
SQL select where associated columns set equals query set
I have table1 associated to table2 with ONE-TO-MANY relationship where table2 has columns "name" and "table1_id" foreign key refers to id of table1. So I want to know is it possible to select record from table1 where its names list is the same as list I need to check in query. Basically a have to compare two String sets and where they equals return the record. Preferable using "JOIN".

答:
```<code>select t1.id, 'match!'
from table1 t1
inner join (select t2.table1_id as table1_id
                  ,array_agg(t2.name) as names
            from table2 t2
            group by t2.table1_id
           ) as t2
  on t2.table1_id = t1.id
 and t2.names     = string_to_array(t1.names, ', '/*<--put the delimiter you use in your string here, include spaces if needed*/)
</code>```


问:
Send boxes to next line after three boxex in CSS
I am trying to make a box which will have photos of people but i want that once three boxes are added in one line then other boxes should go in next line and not adjust in the same line because the data will be dyanmic so i dont know how many boxes will be there , this what it looks like right now :-

now if i add the same div one more time this happens :-

here is my code from react jsx:-

```<code><div className={Profilecss.lowerpart_left_content} id={Profilecss.lowerpart_left_friends}>
            <div className={Profilecss.infobox} id={Profilecss.friends_upperpart}>
                <div id={Profilecss.friends_1}>
                  Friends
                </div>
                <div className={Profilecss.seemore} id={Profilecss.friends_2}>
                  See more
                </div>
              </div>
              <div className={Profilecss.infobox_lowerpart} id={Profilecss.friends_lowerpart}>
                <div className={Profilecss.friends}>
                  <div id={Profilecss.friend_photo}>s</div>
                  <div id={Profilecss.friend_name}>d</div>
                </div>
                <div className={Profilecss.friends}>
                  <div id={Profilecss.friend_photo}>s</div>
                  <div id={Profilecss.friend_name}>d</div>
                </div>
                <div className={Profilecss.friends}>
                  <div id={Profilecss.friend_photo}>s</div>
                  <div id={Profilecss.friend_name}>d</div>
                </div>
                <div className={Profilecss.friends}>
                  <div id={Profilecss.friend_photo}>s</div>
                  <div id={Profilecss.friend_name}>d</div>
                </div>
              </div>
            </div>
</code>```

this is not the whole code so maybe it can cause some problem

This is the CSS:-

```<code>#lowerpart_box{
    width: 55%;
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 2%;
    color: white;
}

.lowerpart_left_content{
    background-color: #242526;
    border-radius: 8px;
    min-height: 10%;
    max-height: 45%;
    margin-top: 5%;
}

#lowerpart_left_photos{
    display: grid;
    grid-template-rows: 1fr 3fr;
}

.infobox{
    display: flex;
    height: fit-content;
    width: 95%;
    gap: 50%;
    font-size: 1.2rem;
    padding: 1%;
    margin-left: 3%;
}

.seemore{
    color: blue;
}

#photo{
    border: 2px solid black;
    width: 35%;
    height: 100%;
}

.infobox_lowerpart{
    display: flex;
}

.friends{
    border: 2px solid black;
    display: grid;
    grid-template-rows: 3.5fr 1fr;
    width: 35%;
    max-height: 40vh;
    margin: 2%;
}
</code>```

答:
You are using display: flex on your infobox_lowerpart class. If you do not specify it, the flex will put all the components in the same row. You can use flex-wrap: wrap to avoid this.

You will also need to adjust your components' width.

Here's a working sandbox based on your code

Body:
I am trying to make a box which will have photos of people but i want that once three boxes are added in one line then other boxes should go in next line and not adjust in the same line because the data will be dyanmic so i dont know how many boxes will be there , this what it looks like right now :-

now if i add the same div one more time this happens :-

here is my code from react jsx:-

                  Friends

                  See more

s

d

s

d

s

d

s

d

this is not the whole code so maybe it can cause some problem

This is the CSS:-

#lowerpart_box{
    width: 55%;
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 2%;
    color: white;
}

.lowerpart_left_content{
    background-color: #242526;
    border-radius: 8px;
    min-height: 10%;
    max-height: 45%;
    margin-top: 5%;
}

#lowerpart_left_photos{
    display: grid;
    grid-template-rows: 1fr 3fr;
}

.infobox{
    display: flex;
    height: fit-content;
    width: 95%;
    gap: 50%;
    font-size: 1.2rem;
    padding: 1%;
    margin-left: 3%;
}

.seemore{
    color: blue;
}

#photo{
    border: 2px solid black;
    width: 35%;
    height: 100%;
}

.infobox_lowerpart{
    display: flex;
}

.friends{
    border: 2px solid black;
    display: grid;
    grid-template-rows: 3.5fr 1fr;
    width: 35%;
    max-height: 40vh;
    margin: 2%;
}


问:
Javascript: Uncaught TypeError: Cannot set property 'className' of undefined
I have a table with an onclick function on it. When clicked upon I get the following error:
Uncaught TypeError: Cannot set property 'className' of undefined

The strange thing is that 3 out of 5 rows the class is changed, but 2/5 are not. When clicked again on the row, one of the remaining two is changed and when clicked again the last one is changed. Here's my code:

HTML table

```<code><tr class='invoice-tr-standard row5' onClick="FormTRClick(event, '6', '5')"><td><input type='checkbox' name='strFormFactuur[]' value='19500' id='chk6'> <img src='../images/link.png' border='0'></td>
    <td><img src='../images/b_save.png' border='0' height='13px' style='cursor: pointer;' onClick="saveData('6', '?iID=19500&bType=0', 'all');")> <input type='image' src='../images/toevoegen.png' border='0' style='float: right; cursor: pointer;' name='FormDupliceer' value='19500'></td>
</tr>
<tr class='invoice-tr-standard row5' onClick="FormTRClick(event, '7', '5')"><td></td>
    <td><img src='../images/b_save.png' border='0' height='13px' style='cursor: pointer;' onClick="saveData('7', '?iID=36&bType=1', 'fltBedrag');"> <input type='image' src='../images/b_delete.png' border='0' style='float: right; cursor: pointer;' name='FormVerwijder' value='36'></td>
</tr>
<tr class='invoice-tr-standard row5' onClick="FormTRClick(event, '8', '5')"><td></td>
    <td><img src='../images/b_save.png' border='0' height='13px' style='cursor: pointer;' onClick="saveData('8', '?iID=37&bType=1', 'fltBedrag');"> <input type='image' src='../images/b_delete.png' border='0' style='float: right; cursor: pointer;' name='FormVerwijder' value='37'></td>
</tr>
<tr class='invoice-tr-standard row5' onClick="FormTRClick(event, '9', '5')"><td></td>
    <td><img src='../images/b_save.png' border='0' height='13px' style='cursor: pointer;' onClick="saveData('9', '?iID=38&bType=1', 'fltBedrag');"> <input type='image' src='../images/b_delete.png' border='0' style='float: right; cursor: pointer;' name='FormVerwijder' value='38'></td>
</tr>
<tr class='invoice-tr-standard row5' onClick="FormTRClick(event, '10', '5')"><td></td>
    <td><img src='../images/b_save.png' border='0' height='13px' style='cursor: pointer;' onClick="saveData('10', '?iID=66&bType=1', 'fltBedrag');"> <input type='image' src='../images/b_delete.png' border='0' style='float: right; cursor: pointer;' name='FormVerwijder' value='66'></td>
</tr>
</code>```

The javascript function FormTRClick():

```<code>function FormTRClick(event, uID, PCID) {
    var Object= event.target.tagName;
    if (Object == 'TD') {
        var Elements = document.getElementsByClassName('row' + PCID);
        var iNumElements = Elements.length;
        alert(iNumElements); // Outputs 5 as expected
        for (var i=0; i < iNumElements; i++) {
            Elements[i].className = "invoice-tr-clicked"; // Only changes 3 out of 5 on the first click
        }
    }
}
</code>```

Update

When using the following Elements[i].className += " invoice-tr-clicked"; instead of Elements[i].className = "invoice-tr-clicked";, the script works as it should. But when replacing (hence the =) I get the Cannot set property 'className' of undefined error.

答:
I've fixed it by replacing

```<code> Elements[i].className = "invoice-tr-clicked";
</code>```

with

```<code> Elements[i].className = "invoice-tr-clicked row" + PCID;
</code>```

Doesn't make any sense it works now, since the demo works without problems.

Body:
I have a table with an onclick function on it. When clicked upon I get the following error:
Uncaught TypeError: Cannot set property 'className' of undefined

The strange thing is that 3 out of 5 rows the class is changed, but 2/5 are not. When clicked again on the row, one of the remaining two is changed and when clicked again the last one is changed. Here's my code:

HTML table

<input type='checkbox' name='strFormFactuur[]' value='19500' id='chk6'>
     <input type='image' src='../images/toevoegen.png' border='0' style='float: right; cursor: pointer;' name='FormDupliceer' value='19500'>

     <input type='image' src='../images/b_delete.png' border='0' style='float: right; cursor: pointer;' name='FormVerwijder' value='36'>

     <input type='image' src='../images/b_delete.png' border='0' style='float: right; cursor: pointer;' name='FormVerwijder' value='37'>

     <input type='image' src='../images/b_delete.png' border='0' style='float: right; cursor: pointer;' name='FormVerwijder' value='38'>

     <input type='image' src='../images/b_delete.png' border='0' style='float: right; cursor: pointer;' name='FormVerwijder' value='66'>

The javascript function FormTRClick():

function FormTRClick(event, uID, PCID) {
    var Object= event.target.tagName;
    if (Object == 'TD') {
        var Elements = document.getElementsByClassName('row' + PCID);
        var iNumElements = Elements.length;
        alert(iNumElements); // Outputs 5 as expected
        for (var i=0; i < iNumElements; i++) {
            Elements[i].className = "invoice-tr-clicked"; // Only changes 3 out of 5 on the first click
        }
    }
}

Update

When using the following Elements[i].className += " invoice-tr-clicked"; instead of Elements[i].className = "invoice-tr-clicked";, the script works as it should. But when replacing (hence the =) I get the Cannot set property 'className' of undefined error.

Body:
I've fixed it by replacing

 Elements[i].className = "invoice-tr-clicked";

with

 Elements[i].className = "invoice-tr-clicked row" + PCID;

Doesn't make any sense it works now, since the demo works without problems.


问:
Tailwind grid_template_columns
How can we set individual column width in Tailwind?

For example in vanilla CSS I would

```<code>.grid-container {
  display: grid;
  grid-template-columns: 20% 80%;
}

<div class="grid-container">
  <div class="item1">1</div>
  <div class="item2">2</div>
</div>
</code>```

But, in Tailwind if you apply width to the columns, it breaks the grid.

答:
This is working for mine</p>
```<code><div class="grid grid-cols-6 gap-4">
   <div class="col-start-2 col-span-4">01</div>
   <div class="col-start-1 col-end-3">02</div>
</div>
</code>```

Title: Tailwind grid_template_columns

Body:
How can we set individual column width in Tailwind?

For example in vanilla CSS I would

.grid-container {
  display: grid;
  grid-template-columns: 20% 80%;
}

1

2

But, in Tailwind if you apply width to the columns, it breaks the grid.

Body:
This is working for mine

<div class="grid grid-cols-6 gap-4">
   <div class="col-start-2 col-span-4">01</div>
   <div class="col-start-1 col-end-3">02</div>
</div>


问:
jquery: $(window).scrollTop() but no $(window).scrollBottom()
I want to place an element to the bottom of the page whenever the user scrolls the page. It's like "fixed position" but I can't use "position: fixed" css as many of my clients' browser can't support that.

I noticed jquery can get current viewport's top position, but how can I get the bottom of the scroll viewport?

So I am asking how to know: $(window).scrollBottom()

答:
i try that and it work very well

scrollrev(){
    let x:any= document.getElementById('chat')
    x.scrollTop = -9000;
  }```

ContentLicense: CC BY-SA 2.5


问:
How to Multiply a value to the next value in a list in scheme?
Is there a way to multiply each value in a list,
however instead of getting another list (2 4 6) like so,
you get the multiplication of all values together.

```<code>(define (multi x y)
  (if (null? y)
     '()
     (* x (car y))))
(multi 2 '(1 2 3))
2 * 1 * 2 * 3
==> 6
</code>```

This may be very simple to some people, but I am having a coding block here, so please don't be rude in the comments. thank you.

答:
While fold is the function scheme provides for this kind of operation, it does not help you to understand how to do it yourself.

Lets start with a proper list:

```<code>(1 . (2 . (3 . ())))
</code>```

We wish to multiply all its elements together:

```<code>{(1 . (2 . (3 . ())))} => 1 * 2 * 3
</code>```

The way to think about lists is: If I can do something with the head in relation to the rest of the list, then I can do it to the whole list.

Let’s rewrite that multiplication:

```<code>{(1 . (2 . (3 . ())))} => (1 * {(2 . (3 . ()))})
                       => (1 * (2 * {(3 . ())}))
                       => (1 * (2 * (3 * {()})))
</code>```

We can turn that null into a 1 so that the multiplication works:

```<code>{(1 . (2 . (3 . ())))} => (1 * (2 * (3 *  1 )))
</code>```

Collapsing the sequence gives us:

```<code>(1 * (2 * 3))
(1 * 6)
6
</code>```

Since your function is not expected to take any arguments except the list, write it as such:

```<code>(define (multiply-list xs)
</code>```

Don’t forget to turn the '() into a 1:

```<code>  (if (null? xs)
      1
</code>```

Now we just need to handle the magic recursive part. Remember, if I can do something with the head...

```<code>      (* (car xs)
</code>```

...in relation to the rest — which must be collapsed by multiplying it...

```<code>         (multiply-list (cdr xs))
</code>```

...then you are done!

This assumes that it is valid for (multiply-list '()) → 1.

If it needs to become anything else (such as '() or 0) then you will have to make your recursive part a little more complicated. You will still need to check if the list is null and return the weird value, but then you must also make sure not to invoke recursion if you have reached the end of an initially non-empty list.

```<code>(define (multiply-list xs)
  (if (null? xs)
      0  ; or whatever weirdness is required to return if the initial list is empty
      (if (null? (cdr xs))  ; now we only want to recurse if there are more elements in the tail
          dont-recurse-here
          recurse-here)))
</code>```

Body:
Is there a way to multiply each value in a list,
however instead of getting another list (2 4 6) like so,
you get the multiplication of all values together.

(define (multi x y)
  (if (null? y)
     '()
     (* x (car y))))
(multi 2 '(1 2 3))
2 * 1 * 2 * 3
==> 6

This may be very simple to some people, but I am having a coding block here, so please don't be rude in the comments. thank you.

Body:
While fold is the function scheme provides for this kind of operation, it does not help you to understand how to do it yourself.

Lets start with a proper list:

(1 . (2 . (3 . ())))

We wish to multiply all its elements together:

{(1 . (2 . (3 . ())))} => 1 * 2 * 3

The way to think about lists is: If I can do something with the head in relation to the rest of the list, then I can do it to the whole list.

Let’s rewrite that multiplication:

{(1 . (2 . (3 . ())))} => (1 * {(2 . (3 . ()))})
                       => (1 * (2 * {(3 . ())}))
                       => (1 * (2 * (3 * {()})))

We can turn that null into a 1 so that the multiplication works:

{(1 . (2 . (3 . ())))} => (1 * (2 * (3 *  1 )))

Collapsing the sequence gives us:

(1 * (2 * 3))
(1 * 6)
6

Since your function is not expected to take any arguments except the list, write it as such:

(define (multiply-list xs)

Don’t forget to turn the '() into a 1:

  (if (null? xs)
      1

Now we just need to handle the magic recursive part. Remember, if I can do something with the head...

      (* (car xs)

...in relation to the rest — which must be collapsed by multiplying it...

         (multiply-list (cdr xs))

...then you are done!

This assumes that it is valid for (multiply-list '()) → 1.

If it needs to become anything else (such as '() or 0) then you will have to make your recursive part a little more complicated. You will still need to check if the list is null and return the weird value, but then you must also make sure not to invoke recursion if you have reached the end of an initially non-empty list.

(define (multiply-list xs)
  (if (null? xs)
      0  ; or whatever weirdness is required to return if the initial list is empty
      (if (null? (cdr xs))  ; now we only want to recurse if there are more elements in the tail
          dont-recurse-here
          recurse-here)))


问:
Sales without associated accounts with a Left Join?
I thought I understood how to do this, but I might be missing something. Would this not work?

```<code>SELECT COUNT(*)
FROM Sale A
LEFT JOIN Account B on A.Sale_id= B.Sale_id
WHERE account_id IS NULL
</code>```

答:
You can do this in one of the many ways. For Instance

Use NOT IN Operator

```<code>Select
     *
from Sale
where
    Sale_id NOT IN (SELECT DISTINCT(Sale_id) FROM Account)
</code>```

Subquery will return the sale ids which has records in Account Table. NOT IN operator returns all other records from Sale Table

Use LEFT JOIN

```<code>Select
   s.*
from Sale s left join Account a on s.Sale_id=a.Sale_id
where a.Sale_id is null
</code>```

Body:
I thought I understood how to do this, but I might be missing something. Would this not work?

SELECT COUNT(*)
FROM Sale A
LEFT JOIN Account B on A.Sale_id= B.Sale_id
WHERE account_id IS NULL

Body:
You can do this in one of the many ways. For Instance

Use NOT IN Operator

Select
     *
from Sale
where
    Sale_id NOT IN (SELECT DISTINCT(Sale_id) FROM Account)

Subquery will return the sale ids which has records in Account Table. NOT IN operator returns all other records from Sale Table

Use LEFT JOIN

Select
   s.*
from Sale s left join Account a on s.Sale_id=a.Sale_id
where a.Sale_id is null


问:
Code does not work in visual studio code but works in repl.it or any online complier. I pretty much get a runtime error on vscode and am forced to end
Here is the code:

```<code>#include <stdio.h>
#include <assert.h>
#include <stdbool.h>

// choose(n,m) returns how many ways there are to choose m items from
//   a set of n items
// requires: 0 <= m, 0 <= n
int choose(int n, int m)
{
    if (m == 0 || m == n)
    {
        return 1;
    } // base case

    // recursive step
    return (choose(n - 1, m) + choose(n - 1, m - 1)); // continues until we have exhausted the
    // number of possibilities to choose from, base case then terminates it
    // taken from the assignment sheet
}

// num_divisors_up_to_k(n,k) returns the number of positive divisors
//   of n that are less than or equal to k
// requires: 1 <= k <= n
int num_divisors_up_to_k(int n, int k)
{
    if (k == 0)
    {
        return 0;
    } // base case

    if (n % k == 0) // if divisible by k return 1 and call recursively
    {
        // call function again moving to next number
        return 1 + num_divisors_up_to_k(n, k - 1);
    }

    else // otherwise return 0 and call recursively
    {
        return 0 + num_divisors_up_to_k(n, k - 1); // next number
    }
}

// is_prime(n) returns true if n is a prime number and false otherwise
// requires: 1 <= n
bool is_prime(int n)
{

    if (n < 2) // 2 is the lowest prime number
    {
        return false;
    }

    for (int i = 2; (i * i) <= n; i++) // loop through each element
    {
        if (n % i == 0) // if divisible by i its not prime so return false
        {
            return false;
        }
    }
    return true; // num is prime
}

// collatz(n) returns the number of steps it takes to reach 1 by
//   by repeatedly applying the Collatz mapping on n; prints each
//   number in the sequence starting at n
// requires: 1 <= n
int collatz(int n)
{
    if (n == 1) // base case
    {

        return 0;
    }
    // print n
    printf("%d ", n);
    // even
    if (n % 2 == 0)
    {
        // adding 1 and calling collatz again with next value
        return 1 + collatz(n / 2);
    }
    else
    {
        // same thing as even just with the method for odd
        return 1 + collatz(3 * n + 1);
    }
}

int main()
{
    // collatz code
    int n;
    printf("enter number:\n");
    scanf("%d", &n);

    while (n == 1)
    {
        // cant be negative or 0
        if (n < 1)
        {
            printf("wrong input");
        }
        else
        {
            // else printing collatz sequence for input
            printf("collatz(%d): ", n);
            int steps = collatz(n);
            // print out number of steps
            printf("it took %d steps\n", steps);
        }
        // next input
        printf("enter number: \n");
    }
    // TESTS CASES

    // choose function
    assert(choose(2, 1) == 2);
    assert(choose(4, 2) == 6);
    assert(choose(10, 10) == 1);
    assert(choose(8, 2) == 28);
    assert(choose(0, 0) == 1);

    // num_divisors_up_to_k function
    assert(num_divisors_up_to_k(9, 9) == 3);
    assert(num_divisors_up_to_k(1, 1) == 1);
    assert(num_divisors_up_to_k(100, 100) == 9);
    assert(num_divisors_up_to_k(0, 0) == 0);

    // is_prime function
    assert(is_prime(10) == false);
    assert(is_prime(2) == true);
    assert(is_prime(7919) == true);
    assert(is_prime(479001599) == true);

    // collatz
    assert(collatz(5) == 5);
    assert(collatz(13) == 9);
    assert(collatz(1) == 0);

    printf("PASSED\n");
}
</code>```

Code does not work in visual studio code but works in repl.it or any online complier. I pretty much get a runtime error on vscode and am forced to end the program myself. im not very good with the technicality of IDE's and I know this code doesn't work as intended but I can't fix it unless I can properly compile it and see the output. if anyone can help me my discord tag is ansh#1234 or you can reply here. looking forward to making this work and thank you in advance

Here is the output on VSCode:

Here is the output on repl.it:

答:
There is configuration issue inyour Visual Studio Code setup. You should just run the program manually in a shell window by typing:

cd /Users/ansh/Desktop/c
gcc assignment1.c -o assignment1
./assignment1
```

Body:
Here is the code:

#include <stdio.h>
#include <assert.h>
#include <stdbool.h>

// choose(n,m) returns how many ways there are to choose m items from
//   a set of n items
// requires: 0 <= m, 0 <= n
int choose(int n, int m)
{
    if (m == 0 || m == n)
    {
        return 1;
    } // base case

    // recursive step
    return (choose(n - 1, m) + choose(n - 1, m - 1)); // continues until we have exhausted the
    // number of possibilities to choose from, base case then terminates it
    // taken from the assignment sheet
}

// num_divisors_up_to_k(n,k) returns the number of positive divisors
//   of n that are less than or equal to k
// requires: 1 <= k <= n
int num_divisors_up_to_k(int n, int k)
{
    if (k == 0)
    {
        return 0;
    } // base case

    if (n % k == 0) // if divisible by k return 1 and call recursively
    {
        // call function again moving to next number
        return 1 + num_divisors_up_to_k(n, k - 1);
    }

    else // otherwise return 0 and call recursively
    {
        return 0 + num_divisors_up_to_k(n, k - 1); // next number
    }
}

// is_prime(n) returns true if n is a prime number and false otherwise
// requires: 1 <= n
bool is_prime(int n)
{

    if (n < 2) // 2 is the lowest prime number
    {
        return false;
    }

    for (int i = 2; (i * i) <= n; i++) // loop through each element
    {
        if (n % i == 0) // if divisible by i its not prime so return false
        {
            return false;
        }
    }
    return true; // num is prime
}

// collatz(n) returns the number of steps it takes to reach 1 by
//   by repeatedly applying the Collatz mapping on n; prints each
//   number in the sequence starting at n
// requires: 1 <= n
int collatz(int n)
{
    if (n == 1) // base case
    {

        return 0;
    }
    // print n
    printf("%d ", n);
    // even
    if (n % 2 == 0)
    {
        // adding 1 and calling collatz again with next value
        return 1 + collatz(n / 2);
    }
    else
    {
        // same thing as even just with the method for odd
        return 1 + collatz(3 * n + 1);
    }
}

int main()
{
    // collatz code
    int n;
    printf("enter number:\n");
    scanf("%d", &n);

    while (n == 1)
    {
        // cant be negative or 0
        if (n < 1)
        {
            printf("wrong input");
        }
        else
        {
            // else printing collatz sequence for input
            printf("collatz(%d): ", n);
            int steps = collatz(n);
            // print out number of steps
            printf("it took %d steps\n", steps);
        }
        // next input
        printf("enter number: \n");
    }
    // TESTS CASES

    // choose function
    assert(choose(2, 1) == 2);
    assert(choose(4, 2) == 6);
    assert(choose(10, 10) == 1);
    assert(choose(8, 2) == 28);
    assert(choose(0, 0) == 1);

    // num_divisors_up_to_k function
    assert(num_divisors_up_to_k(9, 9) == 3);
    assert(num_divisors_up_to_k(1, 1) == 1);
    assert(num_divisors_up_to_k(100, 100) == 9);
    assert(num_divisors_up_to_k(0, 0) == 0);

    // is_prime function
    assert(is_prime(10) == false);
    assert(is_prime(2) == true);
    assert(is_prime(7919) == true);
    assert(is_prime(479001599) == true);

    // collatz
    assert(collatz(5) == 5);
    assert(collatz(13) == 9);
    assert(collatz(1) == 0);

    printf("PASSED\n");
}

Code does not work in visual studio code but works in repl.it or any online complier. I pretty much get a runtime error on vscode and am forced to end the program myself. im not very good with the technicality of IDE's and I know this code doesn't work as intended but I can't fix it unless I can properly compile it and see the output. if anyone can help me my discord tag is ansh#1234 or you can reply here. looking forward to making this work and thank you in advance

Here is the output on VSCode:

Here is the output on repl.it:


问:
Why is LazyHGrid not as high as its items?
I've got a LazyHGrid that shows multiple Text views in one row. That LazyHGrid is inside a VStack. However, the LazyHGrid is higher than it needs to be. What causes the extra space?

```<code>struct ContentView: View {

    let rows = [GridItem()]

    var body: some View {
        VStack {

            ScrollView(.horizontal) {
                LazyHGrid(rows: rows) {
                    ForEach(0..<10) { index in
                        Text("Test \(index)")
                            .padding()
                            .foregroundColor(Color.white)
                            .background(Color.black)
                    }
                }
            }
            .background(Color.green)

            ScrollView(.vertical) {
                VStack {
                    ForEach(0..<100) { index in
                        Text(String(index))
                            .frame(maxWidth: .infinity)
                    }
                }
            }
            .background(Color.blue)
        }
    }
}
</code>```

答:
This works: Reading the height of the cells with an overlay with GeometryReader

```<code>struct ContentView: View {

    let rows = [ GridItem() ]
    @State private var contentSize = CGFloat.zero

    var body: some View {
        VStack {

            ScrollView(.horizontal) {
                LazyHGrid(rows: rows) {
                    ForEach(0..<10) { index in
                            Text("Test \(index)")
                                .padding()
                                .foregroundColor(.white)
                                .background(.black)

                                .overlay(
                                    GeometryReader { geo in
                                        Color.clear.onAppear {
                                            contentSize = geo.size.height
                                        }
                                    }
                                )

                    }
                }
            }
            .frame(height: contentSize + 20)
            .background(Color.green)

            ScrollView(.vertical) {
                VStack {
                    ForEach(0..<100) { index in
                        Text(String(index))
                            .frame(maxWidth: .infinity)
                    }
                }
            }
            .background(Color.blue)
        }
    }
}
</code>```

Body:
I've got a LazyHGrid that shows multiple Text views in one row. That LazyHGrid is inside a VStack. However, the LazyHGrid is higher than it needs to be. What causes the extra space?

struct ContentView: View {

    let rows = [GridItem()]

    var body: some View {
        VStack {

            ScrollView(.horizontal) {
                LazyHGrid(rows: rows) {
                    ForEach(0..<10) { index in
                        Text("Test \(index)")
                            .padding()
                            .foregroundColor(Color.white)
                            .background(Color.black)
                    }
                }
            }
            .background(Color.green)

            ScrollView(.vertical) {
                VStack {
                    ForEach(0..<100) { index in
                        Text(String(index))
                            .frame(maxWidth: .infinity)
                    }
                }
            }
            .background(Color.blue)
        }
    }
}

Body:
This works: Reading the height of the cells with an overlay with GeometryReader

struct ContentView: View {

    let rows = [ GridItem() ]
    @State private var contentSize = CGFloat.zero

    var body: some View {
        VStack {

            ScrollView(.horizontal) {
                LazyHGrid(rows: rows) {
                    ForEach(0..<10) { index in
                            Text("Test \(index)")
                                .padding()
                                .foregroundColor(.white)
                                .background(.black)

                                .overlay(
                                    GeometryReader { geo in
                                        Color.clear.onAppear {
                                            contentSize = geo.size.height
                                        }
                                    }
                                )

                    }
                }
            }
            .frame(height: contentSize + 20)
            .background(Color.green)

            ScrollView(.vertical) {
                VStack {
                    ForEach(0..<100) { index in
                        Text(String(index))
                            .frame(maxWidth: .infinity)
                    }
                }
            }
            .background(Color.blue)
        }
    }
}


问:
Reverse ip, find domain names on ip address
How and from where websites like this http://www.yougetsignal.com/tools/web-sites-on-web-server/ are getting this information from? How can I develop such tool?

Thank you.

答:
From about section of Reverse IP Domain Check tool on yougetsignal:

A reverse IP domain check takes a domain name or IP address pointing
  to a web server and searches for other sites known to be hosted on
  that same web server. Data is gathered from search engine results,
  which are not guaranteed to be complete.


问:
what is the difference about import import {} import * as in typescript
when I write code using typescript, sometimes import module using type 1:

```<code>import foo from bar;
</code>```

sometimes import using type 2:

```<code>import {foo} from bar;
</code>```

sometimes import using type 3:

```<code>import * as foo from bar;
</code>```

what is the difference? when should using type 1,2,3?

答:
```<code>import foo from bar;
</code>```

works when in bar you do

```<code>export default .... // when exporting, there is no restriction about naming. You can `export default foo` but `import bar from bar`
</code>```
```<code>import { foo } from bar; // this is more restriced, and you need to precisely import the same name as you export
</code>```

works when you do

```<code>export const foo .....
</code>```

And regarding

```<code>import * as foo from bar
</code>```

It basically takes everything that is exported from bar and allows you to use it like this:

```<code>import * as foo from bar

foo.bar
foo.somethingElse

// bar

export const bar = ...
export const somethingElse...
</code>```

Body:
when I write code using typescript, sometimes import module using type 1:

import foo from bar;

sometimes import using type 2:

import {foo} from bar;

sometimes import using type 3:

import * as foo from bar;

what is the difference? when should using type 1,2,3?

Body:
import foo from bar;

works when in bar you do

export default .... // when exporting, there is no restriction about naming. You can `export default foo` but `import bar from bar`

import { foo } from bar; // this is more restriced, and you need to precisely import the same name as you export

works when you do

export const foo .....

And regarding

import * as foo from bar

It basically takes everything that is exported from bar and allows you to use it like this:

import * as foo from bar

foo.bar
foo.somethingElse

// bar

export const bar = ...
export const somethingElse...


问:
Why the Javascript Date() constructor prefixes the output year with a plus sign if the year is above 9999
The Date() constructor provides the following example outputs (notice dates above year 9999)

```<code>console.log(new Date(Date.UTC(2022,0,1)));  // output => 2022-01-01T00:00:00.000Z

console.log(new Date(Date.UTC(4000,0,1)));  // output => 4000-01-01T00:00:00.000Z

console.log(new Date(Date.UTC(9999,0,1)));  // output => 9999-01-01T00:00:00.000Z

console.log(new Date(Date.UTC(10000,0,1)));  // output => +010000-01-01T00:00:00.000Z

console.log(new Date(Date.UTC(20000,0,1)));  // output => +020000-01-01T00:00:00.000Z
</code>```

For years above 9999 the output is a 6 digit number string prefixed with a 'plus' sign.

Is this correct? If not:

What is significant about year 9999?

Why is the "+" sign added if the year is above 9999 while it is not added for lower years?

Tested with Chrome and Node and gives the same output.

Here are simple console outputs:

console.log(new Date(Date.UTC(2022,0,1)));  // output => 2022-01-01T00:00:00.000Z
console.log(new Date(Date.UTC(4000,0,1)));  // output => 4000-01-01T00:00:00.000Z
console.log(new Date(Date.UTC(9999,0,1)));  // output => 9999-01-01T00:00:00.000Z
console.log(new Date(Date.UTC(10000,0,1)));  // output => +010000-01-01T00:00:00.000Z
console.log(new Date(Date.UTC(20000,0,1)));  // output => +020000-01-01T00:00:00.000Z```

答:
Is this correct?

The short answer is "yes".

Nothing to do with the Date constructor. Dates are just an offset in milliseconds from the ECMAScript epoch (1970-01-01T00:00:00Z), that's it.

What you are seeing is the result of calling Date.prototype.toISOString which creates a string for the date represented by the Date instance's time value as specified by ECMA-262 Date Time String Format.

For expanded years of more than 4 digits, the year is preceded by "+" or "-" as appropriate.

Body:
The Date() constructor provides the following example outputs (notice dates above year 9999)

console.log(new Date(Date.UTC(2022,0,1)));  // output => 2022-01-01T00:00:00.000Z

console.log(new Date(Date.UTC(4000,0,1)));  // output => 4000-01-01T00:00:00.000Z

console.log(new Date(Date.UTC(9999,0,1)));  // output => 9999-01-01T00:00:00.000Z

console.log(new Date(Date.UTC(10000,0,1)));  // output => +010000-01-01T00:00:00.000Z

console.log(new Date(Date.UTC(20000,0,1)));  // output => +020000-01-01T00:00:00.000Z

For years above 9999 the output is a 6 digit number string prefixed with a 'plus' sign.

Is this correct? If not:

What is significant about year 9999?

Why is the "+" sign added if the year is above 9999 while it is not added for lower years?

Tested with Chrome and Node and gives the same output.

Here are simple console outputs:

console.log(new Date(Date.UTC(2022,0,1)));  // output => 2022-01-01T00:00:00.000Z
console.log(new Date(Date.UTC(4000,0,1)));  // output => 4000-01-01T00:00:00.000Z
console.log(new Date(Date.UTC(9999,0,1)));  // output => 9999-01-01T00:00:00.000Z
console.log(new Date(Date.UTC(10000,0,1)));  // output => +010000-01-01T00:00:00.000Z
console.log(new Date(Date.UTC(20000,0,1)));  // output => +020000-01-01T00:00:00.000Z